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

fix(kafka create): sync marketplace provider with cloud provider #1792

Merged
merged 3 commits into from
Jan 11, 2023

Conversation

rkpattnaik780
Copy link
Contributor

Selection of marketplace provider should be dependent on the cloud provider.

Verification Steps

  1. Use mock server.
  2. Run Kafka create in interactive mode. User should not be able to select gcp as marketplace when aws is chosen as the cloud provider:
rhoas kafka create --dry-run -v

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation change
  • Other (please specify)

return nil, errors.New("standard instances are unavailable for the cloud provider, try another provider")
}

fmt.Println("Supported Billing Models - ", availableBillingModels)
Copy link
Contributor

Choose a reason for hiding this comment

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

Debugging print statements 🙃

availableBillingModels := FetchSupportedBillingModels(orgQuota, answers.CloudProvider)

if len(availableBillingModels) == 0 && len(orgQuota.MarketplaceQuotas) > 0 {
return nil, errors.New("standard instances are unavailable for the cloud provider, try another provider")
Copy link
Contributor

Choose a reason for hiding this comment

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

These error messages should be added to our lang files right? Also one line 263

}

if len(orgQuota.MarketplaceQuotas) == 0 {
return nil, errors.New("no marketplace quota available for given provider")
Copy link
Contributor

Choose a reason for hiding this comment

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

Localise

Comment on lines 350 to 360
func uniqueQuota(s []QuotaSpec) []QuotaSpec {
inResult := make(map[QuotaSpec]bool)
var result []QuotaSpec
for _, quota := range s {
if _, ok := inResult[quota]; !ok {
inResult[quota] = true
result = append(result, quota)
}
}
return result
}
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 small thing but I had to read this a few times to figure out what was happening (we are removing all duplicates from the slice). Maybe just giving this a rename would make it clearer for code reading in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

Something like, removeDuplicateQuotaSpec maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having unique as prefix makes more sense imo, I have added an inline description for the method. Can you check it and let me know wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, the comment is fine, I tend to rather document with the naming of things then comments as they can be outdated and not read most of the time.

I have a small rule, if my comment isnt 3 or more lines long it probably means the code can be made clearer without it (or there is something very niche happening that is just difficult so its fine).

But that is just how I go about it so this is fine 👍

@rkpattnaik780 rkpattnaik780 merged commit 152c36e into main Jan 11, 2023
@rkpattnaik780 rkpattnaik780 deleted the gcp_provider branch January 11, 2023 11:48
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.

2 participants