Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Jun 3, 2022
1 parent 489855e commit ec92333
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions pkg/binding/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ func (o *BindingClient) GetBindingsFromDevfile(devfileObj parser.DevfileObj, con
return result, nil
}

// GetBinding returns the ServiceBinding retource with the given name
// GetBindingFromCluster returns the ServiceBinding resource with the given name
// from the cluster, from group binding.operators.coreos.com/v1alpha1 or servicebinding.io/v1alpha3
func (o *BindingClient) GetBinding(name string) (api.ServiceBinding, error) {
func (o *BindingClient) GetBindingFromCluster(name string) (api.ServiceBinding, error) {

bindingSB, err := o.kubernetesClient.GetBindingServiceBinding(name)
if err == nil {
Expand Down Expand Up @@ -275,8 +275,8 @@ func (o *BindingClient) getStatusFromBinding(name string) (*api.ServiceBindingSt
return nil, err
}

bindings := make([]string, 0, len(secret.Data))
if bindingSB.Spec.BindAsFiles {
bindings := make([]string, 0, len(secret.Data))
for k := range secret.Data {
bindingName := filepath.ToSlash(filepath.Join("${SERVICE_BINDING_ROOT}", name, k))
bindings = append(bindings, bindingName)
Expand All @@ -286,7 +286,6 @@ func (o *BindingClient) getStatusFromBinding(name string) (*api.ServiceBindingSt
}, nil
}

bindings := make([]string, 0, len(secret.Data))
for k := range secret.Data {
bindings = append(bindings, k)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/binding/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ type Client interface {
// GetBindingsFromDevfile returns the bindings defined in the devfile with the status extracted from cluster
GetBindingsFromDevfile(devfileObj parser.DevfileObj, context string) ([]api.ServiceBinding, error)

// GetBinding returns information about a binding in the cluster (either from group binding.operators.coreos.com or servicebinding.io)
GetBinding(name string) (api.ServiceBinding, error)
// GetBindingFromCluster returns information about a binding in the cluster (either from group binding.operators.coreos.com or servicebinding.io)
GetBindingFromCluster(name string) (api.ServiceBinding, error)
}
8 changes: 4 additions & 4 deletions pkg/odo/cli/describe/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var describeBindingExample = ktemplates.Examples(`
# Describe the bindings in the current devfile
%[1]s
# Describe a binding in the cluster
# Describe a binding on the cluster
%[1]s --name frontend
`)

Expand Down Expand Up @@ -75,7 +75,7 @@ func (o *BindingOptions) Validate() (err error) {
}

func (o *BindingOptions) Run(ctx context.Context) error {
if len(o.nameFlag) == 0 {
if o.nameFlag == "" {
bindings, err := o.runWithoutName()
if err != nil {
return err
Expand All @@ -94,7 +94,7 @@ func (o *BindingOptions) Run(ctx context.Context) error {

// Run contains the logic for the odo command
func (o *BindingOptions) RunForJsonOutput(ctx context.Context) (out interface{}, err error) {
if len(o.nameFlag) == 0 {
if o.nameFlag == "" {
return o.runWithoutName()
}
return o.runWithName()
Expand All @@ -105,7 +105,7 @@ func (o *BindingOptions) runWithoutName() ([]api.ServiceBinding, error) {
}

func (o *BindingOptions) runWithName() (api.ServiceBinding, error) {
return o.clientset.BindingClient.GetBinding(o.nameFlag)
return o.clientset.BindingClient.GetBindingFromCluster(o.nameFlag)
}

// NewCmdBinding implements the binding odo sub-command
Expand Down

0 comments on commit ec92333

Please sign in to comment.