Skip to content

Commit

Permalink
fix cobra annotation sharing bug (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
thetechnocrat-dev committed Jul 20, 2023
1 parent 87590b0 commit b9f68eb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
17 changes: 11 additions & 6 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import (
)

var (
toolPath string
inputDir string
autoRun bool
layers int
toolPath string
inputDir string
autoRun bool
layers int
annotationsForAutoRun *[]string
)

var createCmd = &cobra.Command{
Expand All @@ -33,7 +34,11 @@ var createCmd = &cobra.Command{
os.Exit(1)
}
if autoRun {
PlexRun(cid, outputDir, verbose, showAnimation, concurrency, *annotations)
_, _, err := PlexRun(cid, outputDir, verbose, showAnimation, concurrency, *annotationsForAutoRun)
if err != nil {
fmt.Println("Error:", err)
os.Exit(1)
}
}
},
}
Expand Down Expand Up @@ -87,7 +92,7 @@ func init() {
createCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose output")
createCmd.Flags().BoolVarP(&showAnimation, "showAnimation", "", true, "Show job processing animation")
createCmd.Flags().IntVarP(&concurrency, "concurrency", "c", 1, "Number of concurrent operations")
createCmd.Flags().StringArrayP("annotations", "a", []string{}, "Annotations to add to Bacalhau job")
annotationsForAutoRun = createCmd.Flags().StringArrayP("annotations", "a", []string{}, "Annotations to add to Bacalhau job")

rootCmd.AddCommand(createCmd)
}
9 changes: 5 additions & 4 deletions cmd/resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
)

var (
ioJsonPath string
retry bool
ioJsonPath string
retry bool
annotationsForResume *[]string
)

var resumeCmd = &cobra.Command{
Expand All @@ -22,7 +23,7 @@ var resumeCmd = &cobra.Command{
dry := true
upgradePlexVersion(dry)

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

rootCmd.AddCommand(resumeCmd)
Expand Down

0 comments on commit b9f68eb

Please sign in to comment.