/
cluster.go
52 lines (43 loc) · 1.2 KB
/
cluster.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
package cmd
import (
"github.com/astronomerio/astro-cli/cluster"
"github.com/astronomerio/astro-cli/config"
"github.com/spf13/cobra"
)
var (
clusterRootCmd = &cobra.Command{
Use: "cluster",
Aliases: []string{"cl"},
Short: "Manage Astronomer EE clusters",
Long: "Clusteres represent a single installation of the Astronomer Enterprise platform",
}
clusterListCmd = &cobra.Command{
Use: "list",
Aliases: []string{"ls"},
Short: "List known Astronomer Enterprise clusters",
Long: "List known Astronomer Enterprise clusters",
RunE: clusterList,
}
clusterSwitchCmd = &cobra.Command{
Use: "switch",
Aliases: []string{"sw"},
Short: "Switch to a different cluster context",
Long: "Switch to a different cluster context",
RunE: clusterSwitch,
Args: cobra.ExactArgs(1),
}
)
func init() {
// deployment root
RootCmd.AddCommand(clusterRootCmd)
clusterRootCmd.AddCommand(clusterListCmd)
clusterRootCmd.AddCommand(clusterSwitchCmd)
}
func clusterList(cmd *cobra.Command, args []string) error {
cluster.ListClusters()
return nil
}
func clusterSwitch(cmd *cobra.Command, args []string) error {
c := config.Cluster{Domain: args[0]}
return c.SwitchCluster()
}