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

Switch to the new API for marking as required the fields for some resources #490

Merged
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 config/cloudcomposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ func Configure(p *config.Provider) {
r.References["private_environment_config.cloud_composer_connection_subnetwork"] = config.Reference{
Type: "github.com/upbound/provider-gcp/apis/compute/v1beta1.Subnetwork",
}
config.MarkAsRequired(r.TerraformResource, "region")
r.MarkAsRequired("region")
})
}
2 changes: 1 addition & 1 deletion config/cloudscheduler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ func Configure(p *config.Provider) {
// Note(donovanmuller): What about support for 'pubsub/v1beta1.LiteTopic' reference?
Type: "github.com/upbound/provider-gcp/apis/pubsub/v1beta1.Topic",
}
config.MarkAsRequired(r.TerraformResource, "region")
r.MarkAsRequired("region")
})
}
24 changes: 10 additions & 14 deletions config/compute/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func Configure(p *config.Provider) { //nolint: gocyclo
// all resources separately and no complex logic here.

p.AddResourceConfigurator("google_compute_autoscaler", func(r *config.Resource) {
config.MarkAsRequired(r.TerraformResource, "zone")
r.MarkAsRequired("zone")
})

p.AddResourceConfigurator("google_compute_backend_service", func(r *config.Resource) {
Expand Down Expand Up @@ -168,7 +168,7 @@ func Configure(p *config.Provider) { //nolint: gocyclo
r.References["boot_disk.initialize_params.image"] = config.Reference{
Type: "Image",
}
config.MarkAsRequired(r.TerraformResource, "zone")
r.MarkAsRequired("zone")
})

p.AddResourceConfigurator("google_compute_instance_iam_member", func(r *config.Resource) {
Expand Down Expand Up @@ -210,7 +210,7 @@ func Configure(p *config.Provider) { //nolint: gocyclo
Type: "Network",
Extractor: common.PathSelfLinkExtractor,
}
config.MarkAsRequired(r.TerraformResource, "zone")
r.MarkAsRequired("zone")
})

p.AddResourceConfigurator("google_compute_global_address", func(r *config.Resource) {
Expand Down Expand Up @@ -248,7 +248,7 @@ func Configure(p *config.Provider) { //nolint: gocyclo
Type: "TargetPool",
Extractor: common.PathSelfLinkExtractor,
}
config.MarkAsRequired(r.TerraformResource, "zone")
r.MarkAsRequired("zone")
})

p.AddResourceConfigurator("google_compute_interconnect_attachment", func(r *config.Resource) {
Expand All @@ -268,11 +268,11 @@ func Configure(p *config.Provider) { //nolint: gocyclo
Type: "Subnetwork",
Extractor: common.ExtractResourceIDFuncPath,
}
config.MarkAsRequired(r.TerraformResource, "zone")
r.MarkAsRequired("zone")
})

p.AddResourceConfigurator("google_compute_resource_policy", func(r *config.Resource) {
config.MarkAsRequired(r.TerraformResource, "region")
r.MarkAsRequired("region")
})

p.AddResourceConfigurator("google_compute_target_pool", func(r *config.Resource) {
Expand All @@ -281,7 +281,7 @@ func Configure(p *config.Provider) { //nolint: gocyclo
r.References["health_checks"] = config.Reference{
Type: "HTTPHealthCheck",
}
config.MarkAsRequired(r.TerraformResource, "region")
r.MarkAsRequired("region")
})

p.AddResourceConfigurator("google_compute_network_endpoint", func(r *config.Resource) {
Expand Down Expand Up @@ -351,7 +351,7 @@ func Configure(p *config.Provider) { //nolint: gocyclo
Type: "TargetPool",
Extractor: common.PathSelfLinkExtractor,
}
config.MarkAsRequired(r.TerraformResource, "region")
r.MarkAsRequired("region")
})

p.AddResourceConfigurator("google_compute_region_target_http_proxy", func(r *config.Resource) {
Expand All @@ -378,7 +378,7 @@ func Configure(p *config.Provider) { //nolint: gocyclo
config.MarkAsRequired(r.TerraformResource, "region")
})
p.AddResourceConfigurator("google_compute_region_autoscaler", func(r *config.Resource) {
config.MarkAsRequired(r.TerraformResource, "region")
r.MarkAsRequired("region")
})

p.AddResourceConfigurator("google_compute_region_disk", func(r *config.Resource) {
Expand All @@ -399,10 +399,6 @@ func Configure(p *config.Provider) { //nolint: gocyclo
config.MarkAsRequired(r.TerraformResource, "region")
})

p.AddResourceConfigurator("google_compute_region_per_instance_config", func(r *config.Resource) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this resource no longer exist? Is this unnecessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I deleted this statement because this configuration does not have an effect. The region field is generated as a Reference field, and we mark the reference fields as Optional regardless of their status in the scheme. Also, as can be seen, even though the configuration was deleted, no diff occurred after generation. This shows that this configuration block has no function.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for the explanation.

config.MarkAsRequired(r.TerraformResource, "region")
})

p.AddResourceConfigurator("google_compute_region_ssl_certificate", func(r *config.Resource) {
config.MarkAsRequired(r.TerraformResource, "region")
})
Expand Down Expand Up @@ -473,7 +469,7 @@ func Configure(p *config.Provider) { //nolint: gocyclo
r.References["nat_subnets"] = config.Reference{
Type: "Subnetwork",
}
config.MarkAsRequired(r.TerraformResource, "region")
r.MarkAsRequired("region")
})

p.AddResourceConfigurator("google_compute_route", func(r *config.Resource) {
Expand Down
2 changes: 1 addition & 1 deletion config/datacatalog/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ import (
// ResourceConfigurators.
func Configure(p *config.Provider) {
p.AddResourceConfigurator("google_data_catalog_entry_group", func(r *config.Resource) {
config.MarkAsRequired(r.TerraformResource, "region")
r.MarkAsRequired("region")
})
}
2 changes: 1 addition & 1 deletion config/externalname.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ var terraformPluginSDKExternalNameConfigs = map[string]config.ExternalName{
// Imported by using the following format: projects/{{project}}/regions/{{region}}/targetPools/{{name}}
"google_compute_target_pool": config.TemplatedStringAsIdentifier("name", "projects/{{ .setup.configuration.project }}/regions/{{ .parameters.region }}/targetPools/{{ .external_name }}"),
// Imported by using the following format: projects/{{project}}/zones/{{zone}}/instanceGroupManagers/{{name}}
"google_compute_instance_group_manager": config.TemplatedStringAsIdentifier("name", "projects/{{ .setup.configuration.project }}/zones/{{ .parameters.zone }}/targetPools/{{ .external_name }}"),
"google_compute_instance_group_manager": config.TemplatedStringAsIdentifier("name", "projects/{{ if .parameters.project }}{{ .parameters.project }}{{ else }}{{ .setup.configuration.project }}{{ end }}/zones/{{ .parameters.zone }}/instanceGroupManagers/{{ .external_name }}"),
// Imported by using the following format: projects/{{project}}/zones/{{zone}}/instances/{{instance}} roles/compute.osLogin user:[email protected]
"google_compute_instance_iam_member": config.IdentifierFromProvider,
// Imported by using the following format: projects/{{project}}/regions/{{region}}/interconnectAttachments/{{name}}
Expand Down
6 changes: 0 additions & 6 deletions examples/composer/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,3 @@ metadata:
spec:
forProvider:
region: us-east1
config:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did we have to remove this configuration?

Copy link
Collaborator Author

@sergenyalcin sergenyalcin Mar 20, 2024

Choose a reason for hiding this comment

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

I checked the registry documentation, and this usage is no longer valid. Also, there was a basic usage in the example of registry. I changed this example to a basic one to avoid leading the user to the view that the config block is required. In this context, we can consider providing different example manifests for different purposes and use cases, which we discussed before.

When the relevant configuration is used in this form, error messages related to the cloud provider's own version change are seen. This points to a behavioral change in the cloud provider for the relevant resource. The relevant behavior change is not mentioned in the underlying provider documentation. In this context, we cannot rely on the relevant documentation to detect such behavioral changes in future underlying provider version updates. However, it may be possible to try to detect changes in the underlying provider's dependency on cloud providers.

- nodeConfig:
- ipAllocationPolicy:
- useIpAliases: true
clusterIpv4CidrBlock: 10.80.0.0/14
servicesIpv4CidrBlock: 10.84.0.0/20
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
dario.cat/mergo v1.0.0
github.com/crossplane/crossplane-runtime v1.15.1
github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79
github.com/crossplane/upjet v1.1.5
github.com/crossplane/upjet v1.1.6
github.com/hashicorp/terraform-json v0.18.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0
github.com/hashicorp/terraform-provider-google v1.20.1-0.20240304172718-a9e2f2c89f14
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ github.com/crossplane/crossplane-runtime v1.15.1 h1:g1h75tNYOQT152IUNxs8ZgSsRFQK
github.com/crossplane/crossplane-runtime v1.15.1/go.mod h1:kRcJjJQmBFrR2n/KhwL8wYS7xNfq3D8eK4JliEScOHI=
github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79 h1:HigXs5tEQxWz0fcj8hzbU2UAZgEM7wPe0XRFOsrtF8Y=
github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79/go.mod h1:+e4OaFlOcmr0JvINHl/yvEYBrZawzTgj6pQumOH1SS0=
github.com/crossplane/upjet v1.1.5 h1:Ad/fOoPqib9WlbgZ7/bkMfyvDFymodKiJBkDklQQyvE=
github.com/crossplane/upjet v1.1.5/go.mod h1:0bHLtnejZ9bDeyXuBb9MSOQLvKo3+aoTeUBO8N0dGSA=
github.com/crossplane/upjet v1.1.6 h1:0Sx6P+Y3OJK6AnXl7W83F3GXxORnC2fnOzEfxK1OCqs=
github.com/crossplane/upjet v1.1.6/go.mod h1:0bHLtnejZ9bDeyXuBb9MSOQLvKo3+aoTeUBO8N0dGSA=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
github.com/dave/jennifer v1.4.1 h1:XyqG6cn5RQsTj3qlWQTKlRGAyrTcsk1kUmWdZBzRjDw=
Expand Down
Loading