-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathcluster_edit.go
More file actions
41 lines (34 loc) · 1.16 KB
/
cluster_edit.go
File metadata and controls
41 lines (34 loc) · 1.16 KB
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
package cmd
import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/k3d"
"github.com/spf13/cobra"
)
var cluster_editCmd = &cobra.Command{
Use: "edit CLUSTER",
Short: "[EXPERIMENTAL] Edit cluster(s).",
Aliases: []string{"update"},
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(cluster_editCmd).Standalone()
cluster_editCmd.Flags().StringSlice("port-add", []string{}, "[EXPERIMENTAL] Map ports from the node containers (via the serverlb) to the host (Format: `[HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER]`)")
clusterCmd.AddCommand(cluster_editCmd)
carapace.Gen(cluster_editCmd).FlagCompletion(carapace.ActionMap{
"port-add": carapace.ActionMultiPartsN("@", 2, func(c carapace.Context) carapace.Action {
cluster := ""
if len(c.Args) > 0 {
cluster = c.Args[0]
}
switch len(c.Parts) {
case 0:
return carapace.ActionValues()
default:
return k3d.ActionNodes(k3d.NodeOpts{Cluster: cluster, Running: true, Stopped: true}).UniqueList(",") // TODO nodefilter?
}
}),
})
carapace.Gen(cluster_editCmd).PositionalCompletion(
k3d.ActionClusters(),
)
}