From f5487552d785792009f5786e85b0079232d23955 Mon Sep 17 00:00:00 2001 From: joshmeranda Date: Tue, 14 Feb 2023 08:30:34 -0500 Subject: [PATCH] fix minimal build issue --- pkg/opni/commands/completion.go | 34 ------------------- pkg/opni/commands/completion_plugins.go | 44 +++++++++++++++++++++++++ pkg/opni/commands/import_progress.go | 2 ++ 3 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 pkg/opni/commands/completion_plugins.go diff --git a/pkg/opni/commands/completion.go b/pkg/opni/commands/completion.go index 8a7baf0e52..44689da4df 100644 --- a/pkg/opni/commands/completion.go +++ b/pkg/opni/commands/completion.go @@ -2,7 +2,6 @@ package commands import ( "fmt" - "github.com/rancher/opni/plugins/metrics/pkg/apis/remoteread" "os" "strings" "time" @@ -211,36 +210,3 @@ func completeBootstrapTokens(cmd *cobra.Command, args []string, toComplete strin } return comps, cobra.ShellCompDirectiveNoFileComp } - -func completeImportTargets(cmd *cobra.Command, args []string, toComplete string, _ ...func(token *corev1.BootstrapToken) bool) ([]string, cobra.ShellCompDirective) { - if err := importPreRunE(cmd, nil); err != nil { - return nil, cobra.ShellCompDirectiveError | cobra.ShellCompDirectiveNoFileComp - } - - var cluster string - if len(args) >= 1 { - cluster = args[1] - } - - targetList, err := remoteReadClient.ListTargets(cmd.Context(), &remoteread.TargetListRequest{ - ClusterId: cluster, - }) - if err != nil { - return nil, cobra.ShellCompDirectiveNoFileComp - } - - var targets []string - for _, target := range targetList.Targets { - name := target.Meta.Name - - if slices.Contains(args, name) { - continue - } - - if strings.HasPrefix(name, toComplete) { - targets = append(targets, name) - } - } - - return targets, cobra.ShellCompDirectiveNoFileComp -} diff --git a/pkg/opni/commands/completion_plugins.go b/pkg/opni/commands/completion_plugins.go new file mode 100644 index 0000000000..3cd0713f95 --- /dev/null +++ b/pkg/opni/commands/completion_plugins.go @@ -0,0 +1,44 @@ +//go:build !noplugins + +package commands + +import ( + corev1 "github.com/rancher/opni/pkg/apis/core/v1" + "github.com/rancher/opni/plugins/metrics/pkg/apis/remoteread" + "github.com/spf13/cobra" + "golang.org/x/exp/slices" + "strings" +) + +func completeImportTargets(cmd *cobra.Command, args []string, toComplete string, _ ...func(token *corev1.BootstrapToken) bool) ([]string, cobra.ShellCompDirective) { + if err := importPreRunE(cmd, nil); err != nil { + return nil, cobra.ShellCompDirectiveError | cobra.ShellCompDirectiveNoFileComp + } + + var cluster string + if len(args) >= 1 { + cluster = args[1] + } + + targetList, err := remoteReadClient.ListTargets(cmd.Context(), &remoteread.TargetListRequest{ + ClusterId: cluster, + }) + if err != nil { + return nil, cobra.ShellCompDirectiveNoFileComp + } + + var targets []string + for _, target := range targetList.Targets { + name := target.Meta.Name + + if slices.Contains(args, name) { + continue + } + + if strings.HasPrefix(name, toComplete) { + targets = append(targets, name) + } + } + + return targets, cobra.ShellCompDirectiveNoFileComp +} diff --git a/pkg/opni/commands/import_progress.go b/pkg/opni/commands/import_progress.go index 7d51bed999..19cf12cd9d 100644 --- a/pkg/opni/commands/import_progress.go +++ b/pkg/opni/commands/import_progress.go @@ -1,3 +1,5 @@ +//go:build !noplugins + package commands import (