-
Notifications
You must be signed in to change notification settings - Fork 329
Create generate.sh and types.go files for apigateway APIGatewayAPIConfig #7286
Description
As part of moving resources from terraform controllers to direct controllers (Epic #5954), we need to create the Go types for APIGatewayAPIConfig.
Currently, APIGatewayAPIConfig is managed by the Terraform controller (marked with tf2crd=true). The goal is to create the Go types in apis/apigateway/v1alpha1/ so that we can eventually migrate the controller implementation to the "direct" approach.
Instructions
-
1. Create a generate.sh:
Create or append toapis/apigateway/v1alpha1/generate.shwhich includesAPIGatewayAPIConfig.
Example:go run . generate-types \ --service google.cloud.apigateway.v1 \ --api-version apigateway.cnrm.cloud.google.com/v1alpha1 \ --resource APIGatewayAPIConfig:ApiConfig \ --include-skipped-output go run . generate-mapper \ --service google.cloud.apigateway.v1 \ --api-version apigateway.cnrm.cloud.google.com/v1alpha1 \ --include-skipped-output
-
2. Set the write permission on the new
apis/apigateway/v1alpha1/generate.shfile. You should do this by running bothchmod +x apis/apigateway/v1alpha1/generate.shandgit add --chmod=+x apis/apigateway/v1alpha1/generate.sh. -
3. Generate Scaffolding:
Runapis/apigateway/v1alpha1/generate.sh. This should createapis/apigateway/v1alpha1/apigatewayapiconfig_types.go. -
4. Iterate on Types:
Validate the generated CRD by runningdev/tasks/diff-crds. This tool prints any differences between the current branch and the master branch for the generated CRD.
Modifyapis/apigateway/v1alpha1/apigatewayapiconfig_types.gountil the CRD matches the existing one. You should aim to minimize or eliminate any diffs detected by the tool. If diffs are found, you may need to add back missing fields or remove incorrectly added fields.Critical Acceptance Criteria:
- Running
dev/tasks/diff-crdsshould not show differences (or minimal acceptable ones like descriptions). - Changes to the schema (fields added/removed) are NOT acceptable.
- Running
-
5. Copyright Headers:
Ensure that new files have the correct copyright header:// Copyright 2026 Google LLCPlease do not change the copyright on existing files.
-
6. Labels:
Ensure the controller-runtime annotations match the existing CRD labels, including:// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true" // +kubebuilder:metadata:labels="cnrm.cloud.google.com/system=true" // +kubebuilder:metadata:labels="cnrm.cloud.google.com/stability-level=stable" // +kubebuilder:metadata:labels="cnrm.cloud.google.com/tf2crd=true"
The goal is to maintain these annotations, not add an annotation if it is missing.
-
7. Status:
status.observedGenerationshould be anint64. -
8. Generate Mappers:
- Running
dev/tasks/generate-types-and-mapperswill generate the mapper code once theapis/apigateway/v1alpha1/apigatewayapiconfig_types.gofile is generating an equivalent CRD. - Run
make all-binaryto ensure the generated mapper code compiles. Please fix any issue discovered by this compilation.
- Running
This issue is part of Epic #5954.