forked from Azure/acs-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
orchestrators.go
55 lines (44 loc) · 1.21 KB
/
orchestrators.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package cmd
import (
"fmt"
"github.com/Azure/acs-engine/pkg/api"
"github.com/Azure/acs-engine/pkg/helpers"
"github.com/spf13/cobra"
)
const (
cmdName = "orchestrators"
cmdShortDescription = "provide info about supported orchestrators"
cmdLongDescription = "provide info about versions of supported orchestrators"
)
type orchestratorsCmd struct {
// user input
orchestrator string
version string
}
func newOrchestratorsCmd() *cobra.Command {
oc := orchestratorsCmd{}
command := &cobra.Command{
Use: cmdName,
Short: cmdShortDescription,
Long: cmdLongDescription,
RunE: func(cmd *cobra.Command, args []string) error {
return oc.run(cmd, args)
},
}
f := command.Flags()
f.StringVar(&oc.orchestrator, "orchestrator", "", "orchestrator name (optional) ")
f.StringVar(&oc.version, "version", "", "orchestrator version (optional)")
return command
}
func (oc *orchestratorsCmd) run(cmd *cobra.Command, args []string) error {
orchs, err := api.GetOrchestratorVersionProfileListVLabs(oc.orchestrator, oc.version)
if err != nil {
return err
}
data, err := helpers.JSONMarshalIndent(orchs, "", " ", false)
if err != nil {
return err
}
fmt.Println(string(data))
return nil
}