Part of epic #5954.
Task
Create Go types for the Terraform resource AccessContextManagerAccessLevelCondition.
Group: accesscontextmanager.cnrm.cloud.google.com
Kind: AccessContextManagerAccessLevelCondition
Version: v1alpha1
How to Create a CRD for an existing terraform resource
As part of moving resources from terraform controllers to direct controllers, we want to create a normal CRD using the controller-runtime framework.
These direct CRDs are defined with Go types under apis/<service>/<version>/<kind>_types.go. The service should not include the cnrm.cloud.google.com suffix, just the first component.
When we initially create the direct CRD, we want to make sure that we keep the same schema as the old Terraform CRD, for compatibility and so we can roll back. Ideally the generated CRD (under config/crds) does not change.
We accept some changes, more details below. You can easily see changes by running dev/tasks/diff-crds after running generate.sh.
For a CRD we are migrating from Terraform or DCL, we do not (initially) need a Mapper or Fuzzer; we accept or reject the PR based on the CRD definition. So send the generated mapper functions in your PR, but don't worry about a fuzzer yet.
Checklist for Coding Agent
We are able to generate a good starting point with some tooling we have created.
Acceptance Criteria (CRITICAL)
Running dev/tasks/diff-crds MUST NOT show differences (except for the acceptable changes listed below).
Acceptable changes:
- Field descriptions can change, particularly for metadata.
status.observedGeneration will now be an int64.
Unacceptable changes:
- Changes to the schema itself, such as a field being added or removed, are NOT acceptable.
It is absolutely critical that running dev/tasks/diff-crds does not show differences in the schema.
Part of epic #5954.
Task
Create Go types for the Terraform resource
AccessContextManagerAccessLevelCondition.Group:
accesscontextmanager.cnrm.cloud.google.comKind:
AccessContextManagerAccessLevelConditionVersion:
v1alpha1How to Create a CRD for an existing terraform resource
As part of moving resources from terraform controllers to direct controllers, we want to create a normal CRD using the
controller-runtimeframework.These direct CRDs are defined with Go types under
apis/<service>/<version>/<kind>_types.go. The service should not include thecnrm.cloud.google.comsuffix, just the first component.When we initially create the direct CRD, we want to make sure that we keep the same schema as the old Terraform CRD, for compatibility and so we can roll back. Ideally the generated CRD (under
config/crds) does not change.We accept some changes, more details below. You can easily see changes by running
dev/tasks/diff-crdsafter runninggenerate.sh.For a CRD we are migrating from Terraform or DCL, we do not (initially) need a Mapper or Fuzzer; we accept or reject the PR based on the CRD definition. So send the generated mapper functions in your PR, but don't worry about a fuzzer yet.
Checklist for Coding Agent
We are able to generate a good starting point with some tooling we have created.
generate.shscript located inapis/accesscontextmanager/v1alpha1/generate.sh. (Please readapis/bigtable/v1alpha1/generate.shfor a good example to follow).AccessContextManagerAccessLevelCondition) togenerate-types.generate.shscript. It should generate the shared typestypes.generated.goand a scaffolding for the types that cannot be generated,apis/accesscontextmanager/v1alpha1/accesscontextmanageraccesslevelcondition_types.go.dev/tasks/diff-crds. You will likely see some changes. Iterate on the types until they match.types.generated.go. Focus on<Kind>Specand<Kind>Status(there is often a good starting point for the Spec and Schema types generated undertypes.generated.go).Acceptance Criteria (CRITICAL)
Running
dev/tasks/diff-crdsMUST NOT show differences (except for the acceptable changes listed below).Acceptable changes:
status.observedGenerationwill now be anint64.Unacceptable changes:
It is absolutely critical that running
dev/tasks/diff-crdsdoes not show differences in the schema.