Skip to content

Commit

Permalink
Merge pull request #2149 from rsteube/minikube-integrate-file
Browse files Browse the repository at this point in the history
minikube: integrate file completion
  • Loading branch information
rsteube authored Jan 8, 2024
2 parents 921dd75 + 6bfc5fb commit 9284c0d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
12 changes: 5 additions & 7 deletions completers/minikube_completer/cmd/image_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/docker"
"github.com/rsteube/carapace/pkg/util"
"github.com/rsteube/carapace/pkg/condition"
"github.com/spf13/cobra"
)

Expand All @@ -22,11 +22,9 @@ func init() {
imageCmd.AddCommand(image_loadCmd)

carapace.Gen(image_loadCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if util.HasPathPrefix(c.Value) {
return carapace.ActionFiles()
}
return docker.ActionRepositoryTags()
}),
carapace.Batch(
carapace.ActionFiles(),
docker.ActionRepositoryTags().Unless(condition.CompletingPath),
).ToA(),
)
}
21 changes: 8 additions & 13 deletions completers/minikube_completer/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/rsteube/carapace-bin/completers/minikube_completer/cmd/action"
"github.com/rsteube/carapace-bin/pkg/actions/os"
"github.com/rsteube/carapace-bin/pkg/actions/tools/docker"
"github.com/rsteube/carapace/pkg/util"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -100,22 +99,18 @@ func init() {
carapace.Gen(startCmd).FlagCompletion(carapace.ActionMap{
"addons": action.ActionAddons().UniqueList(","),
"base-image": docker.ActionRepositoryTags(),
"cni": carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if util.HasPathPrefix(c.Value) {
return carapace.ActionFiles()
}
return carapace.ActionValues("auto", "bridge", "calico", "cilium", "flannel", "kindnet")
}),
"cni": carapace.Batch(
carapace.ActionFiles(),
carapace.ActionValues("auto", "bridge", "calico", "cilium", "flannel", "kindnet"),
).ToA(),
"container-runtime": carapace.ActionValues("docker", "cri-o", "containerd"),
"cri-socket": carapace.ActionFiles(),
"driver": carapace.ActionValues("virtualbox", "vmwarefusion", "kvm2", "vmware", "none", "docker", "podman", "ssh", "auto-detect"),
"host-only-nic-type": carapace.ActionValues("Am79C970A", "Am79C973", "82540EM", "82543GC", "82545EM", "virtio"),
"hyperkit-vpnkit-sock": carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if util.HasPathPrefix(c.Value) {
return carapace.ActionFiles()
}
return carapace.ActionValues("auto")
}),
"hyperkit-vpnkit-sock": carapace.Batch(
carapace.ActionFiles(),
carapace.ActionValues("auto"),
).ToA(),
"image-mirror-country": os.ActionLanguages(), // TODO country codes the same?
"mount-string": carapace.ActionMultiParts(":", func(c carapace.Context) carapace.Action {
switch len(c.Parts) {
Expand Down

0 comments on commit 9284c0d

Please sign in to comment.