The MockGCP provides the test coverage and helps you develop the direct resource in the follow up steps. The reason we needs the Terraform/DCL-based Alpha resource here is that it is a pre-exist cheap option to help you develop the Mock GCP faster, you don't need or relies on the Terraform/DCL based Alpha resource in the follow up steps.
Follow deep-dives Step 1
-
The 1st git-commit shall contain
create.yaml
andupdate.yaml
files with exactly the same config. -
The 2nd git-commit shall have
update.yaml
changing all the mutable fields, reflected in the git-diff based on the first commit. -
The 3rd git-commit (or N-th git-commit) shall run against real GCP. The generated
_generated_object_<resource>.golden.yaml
and_http.log
is the golden log reflecting the real GCP. The_generated_object_<resource>.golden.yaml
matches thespec
inupdate.yaml
-
The 4rd git-commit (or N+1-th git-commit) shall run against the Mock GCP. The git-diff shows
_generated_object_<resource>.golden.yaml
is unchanged, and the_http.log
is as much like the real GCP as possible. -
If the resource has dependencies (
dependencies.yaml
), we suggest cover all the referenced fields. If the dependency resource does not have mockGCP, you need to implement those dependencies' MockGCP methods as well.
Follow deep-dives Step 2
The PR shall contain the types and deepcopy codes. It shall follow the direct resource recommended styles and conventions. It can change the existing fields since it is Alpha.
- Make sure the generated code is placed under
./apis/<service>/v1alpha1
. If not, please check your flags. - Add
cnrm.cloud.google.com/dcl2crd: "true"
orcnrm.cloud.google.com/tf2crd: "true"
to the API tag example, to continue using Terraform-based controllers. This relies on the existing Terraform-based controller to validate your API.
- If the config/crds is not changed after running
dev/tasks/generate-crds
, we requirethe _generated_object_<resource>.golden.yaml
unchanged. - If the API is updated, we require the
create.yaml
andupdate.yaml
changes. Also, theconfig/crds
and_generated_object_<resource>.golden.yaml
shall match the corresponding changes after running.
Follow deep-dives Step 3
This PR adds the direct mapper. You can do this together with the previous step or the next step if no additional manual changes are needed.
Follow deep-dives Step 4.
- Remove the
cnrm.cloud.google.com/dcl2crd: "true"
orcnrm.cloud.google.com/tf2crd: "true"
from the API tag example, and rerundev/tasks/generate-crds
.
Now, everything is on the direct reconciliation and the resource no longer depends on the Terraform or DCL based controllers. To verify the direct controller, the the _generated_object_<resource>.golden.yaml
should be unchanged.
- We suggest to have the roundtrip fuzz tests to cover all the fields in
spec
andstatus.observedState
fields example (For mapper) - We require removing the
cnrm.cloud.google.com/dcl2crd: "true"
orcnrm.cloud.google.com/tf2crd: "true"
tags from the API and the presubmit test passes withoutthe _generated_object_<resource>.golden.yaml
change.