Skip to content

Commit b9f68eb

Browse files
fix cobra annotation sharing bug (#518)
1 parent 87590b0 commit b9f68eb

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

cmd/create.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import (
1313
)
1414

1515
var (
16-
toolPath string
17-
inputDir string
18-
autoRun bool
19-
layers int
16+
toolPath string
17+
inputDir string
18+
autoRun bool
19+
layers int
20+
annotationsForAutoRun *[]string
2021
)
2122

2223
var createCmd = &cobra.Command{
@@ -33,7 +34,11 @@ var createCmd = &cobra.Command{
3334
os.Exit(1)
3435
}
3536
if autoRun {
36-
PlexRun(cid, outputDir, verbose, showAnimation, concurrency, *annotations)
37+
_, _, err := PlexRun(cid, outputDir, verbose, showAnimation, concurrency, *annotationsForAutoRun)
38+
if err != nil {
39+
fmt.Println("Error:", err)
40+
os.Exit(1)
41+
}
3742
}
3843
},
3944
}
@@ -87,7 +92,7 @@ func init() {
8792
createCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose output")
8893
createCmd.Flags().BoolVarP(&showAnimation, "showAnimation", "", true, "Show job processing animation")
8994
createCmd.Flags().IntVarP(&concurrency, "concurrency", "c", 1, "Number of concurrent operations")
90-
createCmd.Flags().StringArrayP("annotations", "a", []string{}, "Annotations to add to Bacalhau job")
95+
annotationsForAutoRun = createCmd.Flags().StringArrayP("annotations", "a", []string{}, "Annotations to add to Bacalhau job")
9196

9297
rootCmd.AddCommand(createCmd)
9398
}

cmd/resume.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import (
1010
)
1111

1212
var (
13-
ioJsonPath string
14-
retry bool
13+
ioJsonPath string
14+
retry bool
15+
annotationsForResume *[]string
1516
)
1617

1718
var resumeCmd = &cobra.Command{
@@ -22,7 +23,7 @@ var resumeCmd = &cobra.Command{
2223
dry := true
2324
upgradePlexVersion(dry)
2425

25-
_, err := Resume(ioJsonPath, outputDir, verbose, showAnimation, retry, concurrency, *annotations)
26+
_, err := Resume(ioJsonPath, outputDir, verbose, showAnimation, retry, concurrency, *annotationsForResume)
2627
if err != nil {
2728
fmt.Println("Error:", err)
2829
}
@@ -51,7 +52,7 @@ func init() {
5152
resumeCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose output")
5253
resumeCmd.Flags().BoolVarP(&showAnimation, "showAnimation", "", true, "Show job processing animation")
5354
resumeCmd.Flags().IntVarP(&concurrency, "concurrency", "c", 1, "Number of concurrent operations")
54-
resumeCmd.Flags().StringArrayP("annotations", "a", []string{}, "Annotations to add to Bacalhau job")
55+
annotationsForResume = resumeCmd.Flags().StringArrayP("annotations", "a", []string{}, "Annotations to add to Bacalhau job")
5556
resumeCmd.Flags().BoolVarP(&retry, "retry", "", true, "Retry failed jobs")
5657

5758
rootCmd.AddCommand(resumeCmd)

0 commit comments

Comments
 (0)