Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix minimal build issue #1066

Merged
merged 1 commit into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions pkg/opni/commands/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package commands

import (
"fmt"
"github.com/rancher/opni/plugins/metrics/pkg/apis/remoteread"
"os"
"strings"
"time"
Expand Down Expand Up @@ -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
}
44 changes: 44 additions & 0 deletions pkg/opni/commands/completion_plugins.go
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 2 additions & 0 deletions pkg/opni/commands/import_progress.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !noplugins

package commands

import (
Expand Down