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

OCM-11887 | Show all WIF configs in interactive dropdown #677

Merged
merged 1 commit into from
Oct 17, 2024
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
2 changes: 1 addition & 1 deletion cmd/ocm/create/cluster/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ func promptWifConfig(fs *pflag.FlagSet, connection *sdk.Connection) error {
}

// if the flag was not set, prompt the user
wifConfigs, err := provider.GetUnusedWifConfigs(connection.ClustersMgmt().V1())
wifConfigs, err := provider.GetWifConfigs(connection.ClustersMgmt().V1())
if err != nil {
return err
}
Expand Down
9 changes: 1 addition & 8 deletions pkg/provider/wif_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
)

const unusedWifsQuery = "cluster.id is null"

func getWifConfigs(client *cmv1.Client, filter string) (wifConfigs []*cmv1.WifConfig, err error) {
collection := client.GCP().WifConfigs()
page := 1
Expand Down Expand Up @@ -40,11 +38,6 @@ func GetWifConfigs(client *cmv1.Client) (wifConfigs []*cmv1.WifConfig, err error
return getWifConfigs(client, "")
}

// GetUnusedWifConfigs returns the WIF configurations that are not associated with any cluster
func GetUnusedWifConfigs(client *cmv1.Client) (wifConfigs []*cmv1.WifConfig, err error) {
return getWifConfigs(client, unusedWifsQuery)
}

// GetWifConfig returns the WIF configuration where the key is the wif config id or name
func GetWifConfig(client *cmv1.Client, key string) (wifConfig *cmv1.WifConfig, err error) {
query := fmt.Sprintf(
Expand All @@ -68,7 +61,7 @@ func GetWifConfig(client *cmv1.Client, key string) (wifConfig *cmv1.WifConfig, e
// GetWifConfigNameOptions returns the wif config options for the cluster
// with display name as the value and id as the description
func GetWifConfigNameOptions(client *cmv1.Client) (options []arguments.Option, err error) {
wifConfigs, err := GetUnusedWifConfigs(client)
wifConfigs, err := getWifConfigs(client, "")
if err != nil {
err = fmt.Errorf("failed to retrieve WIF configurations: %s", err)
return
Expand Down
Loading