Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Feb 15, 2024
1 parent ace6f38 commit 0e948c7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
16 changes: 12 additions & 4 deletions completers/k3d_completer/cmd/cluster_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/k3d"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -48,10 +49,17 @@ func init() {
clusterCmd.AddCommand(cluster_createCmd)

carapace.Gen(cluster_createCmd).FlagCompletion(carapace.ActionMap{
"api-port": carapace.ActionValues(), // TODO
"config": carapace.ActionFiles(),
"env": carapace.ActionValues(),
"gpus": carapace.ActionValues(),
"api-port": carapace.ActionValues(), // TODO
"config": carapace.ActionFiles(),
"env": carapace.ActionMultiPartsN("@", 2, func(c carapace.Context) carapace.Action {
switch len(c.Parts) {
case 0:
return carapace.ActionValues() // KEY=VALUE
default:
return k3d.ActionNodeFilter().List(";")
}
}),
"gpus": carapace.ActionValues(), // TODO
"host-alias": carapace.ActionValues(),
"image": carapace.ActionValues(),
"k3s-arg": carapace.ActionValues(),
Expand Down
17 changes: 17 additions & 0 deletions pkg/actions/tools/k3d/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,20 @@ func ActionNodes(opts NodeOpts) carapace.Action {
return carapace.ActionStyledValuesDescribed(vals...)
})
}

func ActionNodeGroups() carapace.Action {
return carapace.ActionValues("server", "servers", "agent", "agents", "loadbalancer", "all")
}

func ActionNodeFilter() carapace.Action { // TODO limit to specific cluster
return carapace.ActionMultiPartsN(":", 3, func(c carapace.Context) carapace.Action {
switch len(c.Parts) {
case 0:
return ActionNodeGroups()
case 1:
return carapace.ActionValues() // TODO subset
default:
return carapace.ActionValues() // TODO suffix
}
})
}

0 comments on commit 0e948c7

Please sign in to comment.