Updating to the latest version of gorealis and introducing the fect command to get task configurations.

This commit is contained in:
Renan DelValle 2018-01-25 15:31:43 -08:00
parent 92fa1f140c
commit d38f2f967a
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
3 changed files with 53 additions and 28 deletions

48
cmd/fetch.go Normal file
View file

@ -0,0 +1,48 @@
package cmd
import (
"fmt"
"os"
"github.com/paypal/gorealis/gen-go/apache/aurora"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(fetchCmd)
// Sub-commands
fetchCmd.AddCommand(taskConfigCmd)
taskConfigCmd.Flags().StringVarP(&env, "environment", "e", "", "Aurora Environment")
taskConfigCmd.Flags().StringVarP(&role, "role", "r", "", "Aurora Role")
taskConfigCmd.Flags().StringVarP(&name, "name", "n", "", "Aurora Name")
}
var fetchCmd = &cobra.Command{
Use: "fetch",
Short: "Fetch information from Aurora",
}
var taskConfigCmd = &cobra.Command{
Use: "config" ,
Short: "Fetch a list of task configurations from Aurora.",
Long: `To be written.`,
Run: fetchTasks,
}
func fetchTasks(cmd *cobra.Command, args []string) {
fmt.Printf("Fetching job configuration for [%s/%s/%s] \n", env, role, name)
//TODO: Add filtering down by status
taskQuery := &aurora.TaskQuery{Environment: env, Role: role, JobName: name}
tasks, err := client.GetTasksWithoutConfigs(taskQuery)
if err != nil {
fmt.Printf("error: %+v\n", err.Error())
os.Exit(1)
}
for _, t := range tasks {
fmt.Println(t)
}
}