Skip to content

Commit

Permalink
fixup! amend! Rely on the 'component#GatherName' function instead of …
Browse files Browse the repository at this point in the history
…the Devfile metadata name
  • Loading branch information
rm3l committed Aug 29, 2022
1 parent 718a6ad commit 3f7ef4d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pkg/odo/cli/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,14 @@ func (lo *ListOptions) Complete(cmdline cmdline.Cmdline, args []string) (err err
return errors.New("KUBECONFIG not found. Unable to retrieve cluster information. Please set your Kubernetes configuration via KUBECONFIG env variable or ~/.kube/config")
}

// Create the local context and initial Kubernetes client configuration
lo.Context, err = genericclioptions.New(genericclioptions.NewCreateParameters(cmdline))
if err != nil {
return err
}

// Check for the Devfile and then retrieve all information regarding the local Devfile
lo.devfilePath = location.DevfileLocation("")
if util.CheckPathExists(lo.devfilePath) {
// Create the local context and initial Kubernetes client configuration
lo.Context, err = genericclioptions.New(genericclioptions.NewCreateParameters(cmdline).NeedDevfile(""))
if err != nil {
return err
}

// Set the project / namespace based on the devfile context
lo.project = lo.Context.GetProject()
Expand All @@ -100,7 +99,8 @@ func (lo *ListOptions) Complete(cmdline cmdline.Cmdline, args []string) (err err
}

// Create a local component from the parse devfile
componentName, err := lo.Context.Component()
var componentName string
componentName, err = lo.Context.Component()
if err != nil {
return err
}
Expand All @@ -113,6 +113,12 @@ func (lo *ListOptions) Complete(cmdline cmdline.Cmdline, args []string) (err err

lo.localComponent = localComponent

} else {
// Create the local context and initial Kubernetes client configuration
lo.Context, err = genericclioptions.New(genericclioptions.NewCreateParameters(cmdline))
if err != nil {
return err
}
}

// If the context is "" (devfile.yaml not found..), we get the active one from KUBECONFIG.
Expand Down

0 comments on commit 3f7ef4d

Please sign in to comment.