Skip to content

Commit

Permalink
Merge 04aba8b into 1c6767e
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy authored Aug 4, 2023
2 parents 1c6767e + 04aba8b commit 5aa2c44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
7 changes: 6 additions & 1 deletion cmd/odo/odo.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
)

func main() {
// We need to reinitialize this global variable in case flags are defined by third-party packages
// (for example vendor/sigs.k8s.io/controller-runtime/pkg/client/config/config.go)
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)

// Create a context ready for receiving telemetry data
// and save into it configuration based on environment variables
ctx := segment.NewContext(context.Background())
Expand Down Expand Up @@ -54,8 +58,9 @@ func main() {

// add the completion flags to the root command, though they won't appear in completions
root.Flags().AddGoFlagSet(flag.CommandLine)

// override usage so that flag.Parse uses root command's usage instead of default one when invoked with -h
flag.Usage = func() {
flag.CommandLine.Usage = func() {
_ = root.Help()
}

Expand Down
12 changes: 0 additions & 12 deletions pkg/odo/cli/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package list

import (
"context"
"errors"
"fmt"

"github.com/spf13/cobra"
Expand All @@ -24,8 +23,6 @@ import (
"github.com/redhat-developer/odo/pkg/odo/util"
odoutil "github.com/redhat-developer/odo/pkg/odo/util"

dfutil "github.com/devfile/library/v2/pkg/util"

ktemplates "k8s.io/kubectl/pkg/util/templates"
)

Expand Down Expand Up @@ -62,15 +59,6 @@ func (o *ListOptions) SetClientset(clientset *clientset.Clientset) {

// Complete ...
func (lo *ListOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {

// Check to see if KUBECONFIG exists, and if not, error the user that we would not be able to get cluster information
// Do this before anything else, or else we will just error out with the:
// invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
// instead
if !dfutil.CheckKubeConfigExist() {
return errors.New("KUBECONFIG not found. Unable to retrieve cluster information. Please set your Kubernetes configuration via KUBECONFIG env variable or ~/.kube/config")
}

// If the namespace flag has been passed, we will search there.
// if it hasn't, we will search from the default project / namespace.
if lo.namespaceFlag != "" {
Expand Down

0 comments on commit 5aa2c44

Please sign in to comment.