Skip to content
Merged
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
9 changes: 5 additions & 4 deletions cmd/cluster/from_infra_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package cluster
import (
"encoding/json"
"fmt"
"os"
"sort"
"strings"

sdk "github.com/openshift-online/ocm-sdk-go"
amv1 "github.com/openshift-online/ocm-sdk-go/accountsmgmt/v1"
v1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
Expand All @@ -11,9 +15,6 @@ import (
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"os"
"sort"
"strings"
)

type fromInfraIdOptions struct {
Expand Down Expand Up @@ -72,7 +73,7 @@ func (ops *fromInfraIdOptions) run(cmd *cobra.Command, args []string) error {
}
clusters, err := utils.ApplyFilters(
ocmClient,
[]string{fmt.Sprintf("name like '%s%%'", clusterName)},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chamalabey do you know why we're not directly returning the output from this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@typeid Is it possible for this call to return more than one result (list of clusters)? Line 80 is handling this scenario in a for loop. Either way we might need to check whether if there is more than one result and return only one. Please let me know your thought ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chamalabey reopened, feel free to resolve this question then we can get this merged

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure infra_id's are unique, so there shouldn't really be more than one result, but nonetheless not a blocker so LGTM 🙂

[]string{fmt.Sprintf("infra_id like '%s%%'", clusterName)},
)
if err != nil {
return fmt.Errorf("could not retrieve clusters for %s", infraId)
Expand Down