Skip to content

Commit af56e5f

Browse files
committed
Adds --force / -f flag that is being passed to artifact CLI
1 parent 71f4b4b commit af56e5f

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

cmd/gen-pipeline-report.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,6 @@ Nm for N months
9898
Ny for N years
9999
`
100100
genPipelineReportCmd.Flags().StringP("expire-in", "", "", desc)
101+
genPipelineReportCmd.Flags().BoolP("force", "f", false, "force artifact push, passes -f flag to artifact CLI")
101102
rootCmd.AddCommand(genPipelineReportCmd)
102103
}

cmd/publish.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func init() {
132132

133133
desc := `Skips uploading raw XML files`
134134
publishCmd.Flags().BoolP("no-raw", "", false, desc)
135+
publishCmd.Flags().BoolP("force", "f", false, "force artifact push, passes -f flag to artifact CLI")
135136

136137
desc = `Removes the files after the given amount of time.
137138
Nd for N days

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030

3131
var cfgFile string
3232

33-
var versionString = "0.4.5"
33+
var versionString = "0.4.6"
3434

3535
// rootCmd represents the base command when called without any subcommands
3636
var rootCmd = &cobra.Command{

pkg/cli/cli.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ func writeToFile(data []byte, file *os.File) (string, error) {
165165

166166
// PushArtifacts publishes artifacts to semaphore artifact storage
167167
func PushArtifacts(level string, file string, destination string, cmd *cobra.Command) (string, error) {
168+
force, err := cmd.Flags().GetBool("force")
169+
if err != nil {
170+
logger.Error("Reading flag error: %v", err)
171+
return "", err
172+
}
173+
168174
verbose, err := cmd.Flags().GetBool("verbose")
169175
if err != nil {
170176
logger.Error("Reading flag error: %v", err)
@@ -187,6 +193,10 @@ func PushArtifacts(level string, file string, destination string, cmd *cobra.Com
187193
artifactsPush.Args = append(artifactsPush.Args, "--expire-in", expireIn)
188194
}
189195

196+
if force {
197+
artifactsPush.Args = append(artifactsPush.Args, "-f")
198+
}
199+
190200
output, err := artifactsPush.CombinedOutput()
191201

192202
logger.Info("Pushing artifacts:\n$ %s", artifactsPush.String())

0 commit comments

Comments
 (0)