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 3768 | Feat | Filtered OCM versions for marketplace gcp clusters #556

Merged
merged 3 commits into from
Sep 28, 2023

Conversation

tirthct
Copy link
Contributor

@tirthct tirthct commented Sep 26, 2023

Changed

  • Added gcpMarketplaceEnabled flag for filtering out supported versions of OCM CLI

Tested

  • Only supported versions should be visible for gcp marketplace clusters : tested

Comment on lines 50 to 56
filter := "enabled = 'true'"
filter := fmt.Sprintf("enabled = 'true' AND gcp_marketplace_enabled = '%s'", gcpMarketplaceEnabled)
if channelGroup != "" {
filter = fmt.Sprintf("%s AND channel_group = '%s'", filter, channelGroup)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be probably safer to only set the gcp_marketplace_enabled restriction if a value is explicitly provided (like channel group).

I would keep filter := "enabled = 'true'" as the base query only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed


fs.StringVar(
&args.gcpMarketplaceEnabled,
"gcp-marketplace-enabled",
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a long name for the flag. Maybe gcp-marketplace or marketplace-gcp (to match the subscription type value) would be enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

versions []string, defaultVersion string, err error) {
collection := client.Versions()
page := 1
size := 100
filter := "enabled = 'true'"
filter = fmt.Sprintf("%s AND gcp_marketplace_enabled = '%s'", filter, gcpMarketplaceEnabled)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should filter for gcp_marketplace_enabled as long the flag is explicitly set.

You can probably achieve this by using a pointer and checking for nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

@@ -400,16 +401,16 @@ func GetDefaultClusterFlavors(connection *sdk.Connection, flavour string) (dMach
}

func getVersionOptions(connection *sdk.Connection) ([]arguments.Option, error) {
options, _, err := getVersionOptionsWithDefault(connection, "")
options, _, err := getVersionOptionsWithDefault(connection, "", "false")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should set the default value to this flag

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to nil

fs.StringVar(
&args.gcpMarketplace,
"gcp-marketplace",
"false",
Copy link
Contributor

Choose a reason for hiding this comment

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

is this the default value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, changed to an empty string

Comment on lines 555 to 560
gcpMarketplaceEnabled := strconv.FormatBool(isGcpMarketplaceSubscriptionType)
versions, defaultVersion, err := getVersionOptionsWithDefault(connection, args.channelGroup,
&gcpMarketplaceEnabled)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will cause filtering by gcp_marketplace_enabled = 'false' when selecting billing models other than marketplace-gcp - which is not the goal, PTAL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed the logic

@@ -400,16 +401,16 @@ func GetDefaultClusterFlavors(connection *sdk.Connection, flavour string) (dMach
}

func getVersionOptions(connection *sdk.Connection) ([]arguments.Option, error) {
options, _, err := getVersionOptionsWithDefault(connection, "")
options, _, err := getVersionOptionsWithDefault(connection, "", nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

since the default value of the flag is an empty string, does it make sense to use the same pattern here and change the type from *string to string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, changed to keep a string instead of *string


fs.StringVar(
&args.gcpMarketplace,
"gcp-marketplace",
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be marketplace-gcp instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

@cristianoveiga
Copy link
Contributor

LGTM

@gdbranco gdbranco merged commit 5d97615 into openshift-online:main Sep 28, 2023
4 checks passed
@tirthct tirthct deleted the ocm-3768 branch September 28, 2023 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants