Skip to content

Create generate.sh and types.go files for apigateway APIGatewayAPIConfig #7286

@justinsb

Description

@justinsb

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 to apis/apigateway/v1alpha1/generate.sh which includes APIGatewayAPIConfig.
    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.sh file. You should do this by running both chmod +x apis/apigateway/v1alpha1/generate.sh and git add --chmod=+x apis/apigateway/v1alpha1/generate.sh.

  • 3. Generate Scaffolding:
    Run apis/apigateway/v1alpha1/generate.sh. This should create apis/apigateway/v1alpha1/apigatewayapiconfig_types.go.

  • 4. Iterate on Types:
    Validate the generated CRD by running dev/tasks/diff-crds. This tool prints any differences between the current branch and the master branch for the generated CRD.
    Modify apis/apigateway/v1alpha1/apigatewayapiconfig_types.go until 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-crds should not show differences (or minimal acceptable ones like descriptions).
    • Changes to the schema (fields added/removed) are NOT acceptable.
  • 5. Copyright Headers:
    Ensure that new files have the correct copyright header:

    // Copyright 2026 Google LLC

    Please 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.observedGeneration should be an int64.

  • 8. Generate Mappers:

    • Running dev/tasks/generate-types-and-mappers will generate the mapper code once the apis/apigateway/v1alpha1/apigatewayapiconfig_types.go file is generating an equivalent CRD.
    • Run make all-binary to ensure the generated mapper code compiles. Please fix any issue discovered by this compilation.

This issue is part of Epic #5954.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions