Adding fetch jobs command. Currently only takes into account the role.
This commit is contained in:
parent
09469f3216
commit
3341fe8e11
1 changed files with 38 additions and 0 deletions
38
cmd/fetch.go
38
cmd/fetch.go
|
@ -22,6 +22,10 @@ func init() {
|
||||||
|
|
||||||
// Fetch Leader
|
// Fetch Leader
|
||||||
fetchCmd.AddCommand(leaderCmd)
|
fetchCmd.AddCommand(leaderCmd)
|
||||||
|
|
||||||
|
// Fetch jobs
|
||||||
|
fetchCmd.AddCommand(fetchJobsCmd)
|
||||||
|
fetchJobsCmd.Flags().StringVarP(&role, "role", "r", "", "Aurora Role")
|
||||||
}
|
}
|
||||||
|
|
||||||
var fetchCmd = &cobra.Command{
|
var fetchCmd = &cobra.Command{
|
||||||
|
@ -45,6 +49,13 @@ var leaderCmd = &cobra.Command{
|
||||||
Run: fetchLeader,
|
Run: fetchLeader,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var fetchJobsCmd = &cobra.Command{
|
||||||
|
Use: "jobs",
|
||||||
|
Short: "Fetch a list of task Aurora running under a role.",
|
||||||
|
Long: `To be written.`,
|
||||||
|
Run: fetchJobs,
|
||||||
|
}
|
||||||
|
|
||||||
func fetchTasks(cmd *cobra.Command, args []string) {
|
func fetchTasks(cmd *cobra.Command, args []string) {
|
||||||
fmt.Printf("Fetching job configuration for [%s/%s/%s] \n", env, role, name)
|
fmt.Printf("Fetching job configuration for [%s/%s/%s] \n", env, role, name)
|
||||||
|
|
||||||
|
@ -79,3 +90,30 @@ func fetchLeader(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
fmt.Print(url)
|
fmt.Print(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Expand this to be able to filter by job name and environment.
|
||||||
|
func fetchJobs(cmd *cobra.Command, args []string) {
|
||||||
|
fmt.Printf("Fetching tasks under role: %s \n", role)
|
||||||
|
|
||||||
|
if role == "" {
|
||||||
|
fmt.Println("Role must be specified.")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if role == "*" {
|
||||||
|
fmt.Println("Warning: This is an expensive operation.")
|
||||||
|
role = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
_, result, err := client.GetJobs(role)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Print("error: %+v\n", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
for jobConfig, _ := range result.GetConfigs() {
|
||||||
|
fmt.Println(jobConfig)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue