-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor to use Cobra * backport meta tag parser fix * use correct flag for dynamic tasks * add help messages to commands
- Loading branch information
Showing
12 changed files
with
910 additions
and
817 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package cmd | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/hyperbadger/nomad-pipeline/pkg/controller" | ||
) | ||
|
||
var agentCmd = &cobra.Command{ | ||
Use: "agent", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cmd.Help() | ||
}, | ||
} | ||
|
||
var agentInitCmd = &cobra.Command{ | ||
Use: "init", | ||
Short: "Initialize job with nomad-pipeline hooks", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
pc := controller.NewPipelineController(cPath) | ||
|
||
update := pc.Init() | ||
if update { | ||
err := pc.UpdateJob() | ||
if err != nil { | ||
log.Fatalf("error updating job: %v", err) | ||
} | ||
} | ||
}, | ||
} | ||
|
||
var agentWaitCmd = &cobra.Command{ | ||
Use: "wait", | ||
Short: "Wait for previous task group(s)", | ||
Args: cobra.ArbitraryArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
pc := controller.NewPipelineController(cPath) | ||
|
||
pc.Wait(args) | ||
}, | ||
} | ||
|
||
var agentNextCmd = &cobra.Command{ | ||
Use: "next", | ||
Short: "Trigger next task group(s)", | ||
Args: cobra.ArbitraryArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
pc := controller.NewPipelineController(cPath) | ||
|
||
update := pc.Next(args, dynamicTasks) | ||
if update { | ||
err := pc.UpdateJob() | ||
if err != nil { | ||
log.Fatalf("error updating job: %v", err) | ||
} | ||
} | ||
}, | ||
} | ||
|
||
var dynamicTasks string | ||
|
||
func init() { | ||
agentNextCmd.Flags().StringVar(&dynamicTasks, "dynamic-tasks", "", "glob of task files relative to alloc dir") | ||
|
||
agentCmd.AddCommand(agentInitCmd) | ||
agentCmd.AddCommand(agentWaitCmd) | ||
agentCmd.AddCommand(agentNextCmd) | ||
|
||
rootCmd.AddCommand(agentCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "nomad-pipeline", | ||
Short: "Run pipeline-style workloads in Nomad", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cmd.Help() | ||
}, | ||
} | ||
|
||
var cPath string | ||
|
||
func init() { | ||
rootCmd.PersistentFlags().StringVar(&cPath, "config", "config.yaml", "path to config") | ||
} | ||
|
||
func Execute() { | ||
if err := rootCmd.Execute(); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.