Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 25, 2023
1 parent bda51cc commit 06348f4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 18 deletions.
44 changes: 44 additions & 0 deletions completers/k3d_completer/cmd/cluster_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,48 @@ func init() {
cluster_createCmd.Flags().StringSliceP("volume", "v", []string{}, "Mount volumes into the nodes (Format: `[SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]]`")
cluster_createCmd.Flags().Bool("wait", false, "Wait for the server(s) to be ready before returning. Use '--timeout DURATION' to not wait forever.")
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(),
"host-alias": carapace.ActionValues(),
"image": carapace.ActionValues(),
"k3s-arg": carapace.ActionValues(),
"k3s-node-label": carapace.ActionValues(),
"lb-config-override": carapace.ActionValues(),
"network": carapace.ActionValues(),
"port": carapace.ActionValues(),
"registry-config": carapace.ActionValues(),
"registry-create": carapace.ActionValues(),
"registry-use": carapace.ActionValues(),
"runtime-label": carapace.ActionValues(),
"runtime-ulimit": carapace.ActionValues(),
"servers": carapace.ActionValues(),
"servers-memory": carapace.ActionValues(),
"subnet": carapace.ActionValues(),
"timeout": carapace.ActionValues(),
"token": carapace.ActionValues(),
"volume": carapace.ActionValues(),
})
}

func x() {
// KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]
carapace.ActionMultiPartsN("@", 2, func(c carapace.Context) carapace.Action {
switch len(c.Parts) {
case 0:
return carapace.ActionMultiPartsN("=", 2, func(c carapace.Context) carapace.Action {
switch len(c.Parts) {
case 0:
return carapace.ActionValues("TODO:key")
default:
return carapace.ActionValues("TODO:value")
}
})
default:
return carapace.ActionValues("TODO:nodefilter").List(";")
}
}).List(",")
}
10 changes: 10 additions & 0 deletions completers/k3d_completer/cmd/node_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-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

Expand All @@ -28,4 +29,13 @@ func init() {
node_createCmd.Flags().StringP("token", "t", "", "Override cluster token (required when connecting to an external cluster)")
node_createCmd.Flags().Bool("wait", false, "Wait for the node(s) to be ready before returning.")
nodeCmd.AddCommand(node_createCmd)

// TODO
carapace.Gen(node_createCmd).FlagCompletion(carapace.ActionMap{
// "cluster": carapace.ActionValues(),
// "image": carapace.ActionValues(),
"k3s-arg": bridge.ActionCarapaceBin("k3s").Split(), // TODO verify
// "network": carapace.ActionValues(),
"role": carapace.ActionValues("server", "agent"),
})
}
6 changes: 6 additions & 0 deletions completers/k3d_completer/cmd/node_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ func init() {
node_listCmd.Flags().Bool("no-headers", false, "Disable headers")
node_listCmd.Flags().StringP("output", "o", "", "Output format. One of: json|yaml")
nodeCmd.AddCommand(node_listCmd)

carapace.Gen(node_listCmd).FlagCompletion(carapace.ActionMap{
"output": carapace.ActionValues("json", "yaml"),
})

// TODO positional
}
18 changes: 0 additions & 18 deletions completers/k3d_completer/cmd/registry_.go

This file was deleted.

0 comments on commit 06348f4

Please sign in to comment.