Changing role, env, and name to be string pointers. This is due to the fact that TaskQuery can now take nil pointers to ignore certain fields. This allows querying for all jobs of a certain environment, all jobs from a certain role, and all jobs with a certain name.

This commit is contained in:
Renan DelValle 2018-09-16 21:23:36 -07:00
parent ce71939546
commit 0a3288a1dd
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
5 changed files with 104 additions and 27 deletions

View file

@ -15,6 +15,14 @@ func init() {
stopCmd.AddCommand(stopMaintCmd)
stopMaintCmd.Flags().IntVar(&monitorInterval,"interval", 5, "Interval at which to poll scheduler.")
stopMaintCmd.Flags().IntVar(&monitorTimeout,"timeout", 50, "Time after which the monitor will stop polling and throw an error.")
// Stop update
stopCmd.AddCommand(stopUpdateCmd)
stopUpdateCmd.Flags().StringVarP(env, "environment", "e", "", "Aurora Environment")
stopUpdateCmd.Flags().StringVarP(role, "role", "r", "", "Aurora Role")
stopUpdateCmd.Flags().StringVarP(name, "name", "n", "", "Aurora Name")
}
var stopCmd = &cobra.Command{
@ -29,6 +37,13 @@ var stopMaintCmd = &cobra.Command{
Run: endMaintenance,
}
var stopUpdateCmd = &cobra.Command{
Use: "update [update ID]",
Short: "Stop update",
Long: `To be written.`,
Run: stopUpdate,
}
func endMaintenance(cmd *cobra.Command, args []string) {
fmt.Println("Setting hosts to NONE maintenance status.")
fmt.Println(args)
@ -57,3 +72,26 @@ func endMaintenance(cmd *cobra.Command, args []string) {
fmt.Println(result.String())
}
func stopUpdate(cmd *cobra.Command, args []string) {
if len(args) != 1 {
fmt.Println("Only a single update ID must be provided.")
os.Exit(1)
}
fmt.Printf("Stopping (aborting) update [%s/%s/%s] %s\n", *env, *role, *name, args[0])
resp, err := client.AbortJobUpdate(aurora.JobUpdateKey{
Job: &aurora.JobKey{Environment: *env, Role: *role, Name: *name},
ID: args[0],
},
"")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(resp.String())
}