Skip to content

Add cloud quota preferences#761

Merged
sergenyalcin merged 7 commits intocrossplane-contrib:mainfrom
jacobstr:koobz/cloud-quotas
Oct 22, 2025
Merged

Add cloud quota preferences#761
sergenyalcin merged 7 commits intocrossplane-contrib:mainfrom
jacobstr:koobz/cloud-quotas

Conversation

@jacobstr
Copy link
Copy Markdown
Contributor

Description of your changes

Addresses #550. Bulk of the content was this diff in the first commit, everything else was code generation.

Fixes #550

I have:

  • Read and followed Crossplane's [contribution process].
  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

I intend to respond with a comment as outlined here https://github.com/crossplane/upjet/blob/main/docs/adding-new-resource.md#automated-tests---uptest

@jacobstr jacobstr changed the title Koobz/cloud quotas Add cloud quota preferences Mar 21, 2025
Comment thread config/externalname.go Outdated
"google_tags_tag_value": config.IdentifierFromProvider,

// cloudquotas
"google_cloud_quotas_quota_preference": config.TemplatedStringAsIdentifier("name", "{{ .parameters.parent }}/locations/global/quotaPreferences/{{ .external_name }}"),
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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, it seems okay, but since we are using the name parameter in the external name here, it would be a good idea to mark it as required. Here is an example configuration:

r.MarkAsRequired("region")

Also, it would be good to move the cloudquotas group to the lines with cloud groups in alphabetical order.

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.

Done. I believe :) See 190ed4b.

I was anticipating that adding this would affect the code generation and, in turn, mark it as required in the openapi schema at https://github.com/jacobstr/provider-upjet-gcp/blob/1db2f529d96c09b7de407c4775a9d1c3a8440a78/package/crds/cloudquotas.gcp.upbound.io_quotapreferences.yaml#L232

Comment thread config/overrides.go

"google_essential_contacts_contact$": ReplaceGroupWords("", 2),

"google_cloud_quotas.+$": ReplaceGroupWords("", 2),
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.

This little bit is underdocumented in the https://github.com/crossplane/upjet/blob/main/docs/adding-new-resource.md#gcp guide fwiw, but adding this induced the code generation for a new provider as well.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When we don't add this, which group does it add the resource to?

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.

cloud.gcp.upbound.io/v1beta1

@jacobstr
Copy link
Copy Markdown
Contributor Author

/test-examples="examples/cloudquotas/v1beta1/quotapreference.yaml"

1 similar comment
@turkenf
Copy link
Copy Markdown
Collaborator

turkenf commented Mar 21, 2025

/test-examples="examples/cloudquotas/v1beta1/quotapreference.yaml"

@jacobstr jacobstr force-pushed the koobz/cloud-quotas branch from cd1f919 to 7be31c1 Compare March 21, 2025 15:55
dimensions:
region: us-east1
parent: projects/my-project-name
quotaConfig:
Copy link
Copy Markdown
Contributor Author

@jacobstr jacobstr Mar 21, 2025

Choose a reason for hiding this comment

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

The code gen was producing an array here and that was leading to test failures. I inspected the generated code and the QuotaConfigParameters property is not a slice.

Seems like something to nip in the bud lest the code gen want to clobber my bespoke tuning?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a missing/not handled issue in our code generation pipeline. I opened an issue for this on Upjet after you came across this, feel free to leave a comment there.

However, from what I see here, you have removed the generated example. Changing the generated examples is not recommended and will cause errors in the CI pipeline. After running make generate, please leave the generated example as is and make the corrections in the copied one.

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.

Pardon the laaate response here. The generated examples are the ones in examples-generated? So leave those intact and modify examples.

Double checking because we're commenting on examples folder. I had not committed the generated example. Just committed a moment ago.

Copy link
Copy Markdown
Collaborator

@turkenf turkenf left a comment

Choose a reason for hiding this comment

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

Welcome, Jacob Straszynski! 😊

Thanks so much for your first contribution with this PR — I appreciate your effort and patience. I've left a few comments for you to consider.

Comment thread config/externalname.go Outdated
"google_tags_tag_value": config.IdentifierFromProvider,

// cloudquotas
"google_cloud_quotas_quota_preference": config.TemplatedStringAsIdentifier("name", "{{ .parameters.parent }}/locations/global/quotaPreferences/{{ .external_name }}"),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, it seems okay, but since we are using the name parameter in the external name here, it would be a good idea to mark it as required. Here is an example configuration:

r.MarkAsRequired("region")

Also, it would be good to move the cloudquotas group to the lines with cloud groups in alphabetical order.

Comment thread config/overrides.go

"google_essential_contacts_contact$": ReplaceGroupWords("", 2),

"google_cloud_quotas.+$": ReplaceGroupWords("", 2),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When we don't add this, which group does it add the resource to?

dimensions:
region: us-east1
parent: projects/my-project-name
quotaConfig:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a missing/not handled issue in our code generation pipeline. I opened an issue for this on Upjet after you came across this, feel free to leave a comment there.

However, from what I see here, you have removed the generated example. Changing the generated examples is not recommended and will cause errors in the CI pipeline. After running make generate, please leave the generated example as is and make the corrections in the copied one.

@github-actions
Copy link
Copy Markdown

This provider repo does not have enough maintainers to address every pull request. Since there has been no activity in the last 90 days it is now marked as stale. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.

@github-actions github-actions Bot added the stale label Jul 10, 2025
@jacobstr
Copy link
Copy Markdown
Contributor Author

/fresh

@github-actions github-actions Bot removed the stale label Jul 11, 2025
@turkenf
Copy link
Copy Markdown
Collaborator

turkenf commented Jul 22, 2025

/test-examples="examples/cloudquotas/v1beta1/quotapreference.yaml"

@jacobstr
Copy link
Copy Markdown
Contributor Author

Hrm I see the job failed:

case.go:363: QuotaPreference.cloudquotas.gcp.upbound.io "preference" is invalid: [spec.forProvider.quotaConfig.preferredValue: Invalid value: "integer": spec.forProvider.quotaConfig.preferredValue in body must be of type string: "integer", <nil>: Invalid value: "null": some validation rules were not checked because the object was invalid; correct the existing errors to complete validation]

The file example does have a quotaConfig.preferredValue https://github.com/crossplane-contrib/provider-upjet-gcp/blob/koobz/cloud-quotas/examples/cloudquotas/v1beta1/quotapreference.yaml#L16

@jeanduplessis
Copy link
Copy Markdown
Collaborator

@jacobstr, now that the v2 version is out, we're keen to include this PR in the next release of this provider. Can you please rebase it on the latest code from the main? If you can't continue contributing to this one, we'd be happy to take it over for you.

Initial steps to get the code gen goodness going. I'm aiming to produce
a cloudquotas provider for the family as well.

Signed-off-by: Jacob Straszynski <jacob.straszynski@planet.com>
Signed-off-by: Jacob Straszynski <jacob.straszynski@planet.com>
Unsure why the code generation made this example a list instead of an
object. I suppose terraform allows multiple blocks for some resources,
but it doesn't look like a good fit here.

Signed-off-by: Jacob Straszynski <jacob.straszynski@planet.com>
Signed-off-by: Jacob Straszynski <jacob.straszynski@planet.com>
Based on feedback from @turkenf

  since we are using the name parameter in the external name here, it
  would be a good idea to mark it as required.

Signed-off-by: Jacob Straszynski <jacob.straszynski@planet.com>
Signed-off-by: Jacob Straszynski <jacob.straszynski@planet.com>
Signed-off-by: Sergen Yalçın <yalcinsergen97@gmail.com>
@sergenyalcin
Copy link
Copy Markdown
Collaborator

@jacobstr, thanks for your work on this PR. We'd like to get this merged and make sure you get credit for it. We'll take it from here by updating it to resolve conflicts with main and fixing the tests. Appreciate your contribution!

Signed-off-by: Sergen Yalçın <yalcinsergen97@gmail.com>
@sergenyalcin
Copy link
Copy Markdown
Collaborator

/test-examples="examples/cloudquotas/cluster/v1beta1/quotapreference.yaml"

@sergenyalcin sergenyalcin merged commit 0022ac4 into crossplane-contrib:main Oct 22, 2025
9 checks passed
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.

Request for quota resource

4 participants