Skip to content

Latest commit

 

History

History
95 lines (64 loc) · 6.6 KB

File metadata and controls

95 lines (64 loc) · 6.6 KB

5. Release

5.1 Make Direct Controller the Default for Beta

When a resource is promoted to Beta, the direct controller should typically become the default. This is achieved by ensuring the v1beta1 CRD does not contain the cnrm.cloud.google.com/tf2crd or cnrm.cloud.google.com/dcl2crd labels, and then regenerating the static controller configuration.

For detailed instructions, please see 4-add-controller.md, under "Scenario 3: Promoting an alpha direct resource to beta".

5.2 Bump from v1alpha1 to v1beta1

  • Copy-paste ./apis/service>/v1alpha1 to./apis/service>/v1beta1using git mv (this is for PR review) and make sure the ./apis/service>/v1alpha1 is still there.

    • NOTE: if you have more than one resource in your service, only copy the files relevant to your resource for now. You will need to re-run dev/tasks/generate-crds for the deepcopy file.
  • Update the new package version to v1beta1

  • Update all direct controller imports to use the v1beta1 api of your resource

  • For all the fixtures tests under pkg/test/resourcefixture/testdata make sure your resources use the v1beta1 version.

  • Add kubebuilder:storageversion tag to v1beta1 API. example

  • Run dev/tasks/generate-crds to patch your resource's CRD with the v1beta1 version.

5.3 Turn on doc auto-generation (direct resource only)

  • For resource that is purely direct controller based, add the resource name to pureDirectResources in IsPureDirectResource function in sets.go.

  • If the resource is found in the resource-autogen allowlist, remove it from the list.

5.4 Add samples

  1. Make sure a directory exist under config/samples/resources. For example, if the kind is spannerinstance, the directory should be config/samples/resources/spannerinstance.
  2. Make sure a a sample YAML file named <service>-<version>-<kind>.yaml exist under the directory.
  3. Look at example in pkg/test/resourcefixture/testdata/basic////-minimal/create.yaml to fill in the content for the sample YAML.
  4. Fulfill the following requirements for the sample YAML file (the path is in JSON format).
    • The .metadata.name is in the format <kind>-sample (lower case).
    • If the resource has a .spec.projectRef field, use projects/${PROJECT_ID?} literally as .spec.projectRef.external value.
  5. Enable your service API in SUPPORTED_SERVICES if it's not there.
  6. If the test takes more than 10 minutes to finish, add it to LONG_RUNNING_SAMPLES_TESTS_REGEX in ./scripts/shared-vars-public.sh.

Run/Disable Sample Tests

Run the sample

go test -v -tags=integration ./config/tests/samples/create -test.run TestAll -run-tests <your_sample_test_name>

your_sample_test_name is the sample suite directory name, i.e spannerinstance

Replace the environment variables to real values before running the tests.

Cloud Code Snippets

We have a script that generates snippet files for Cloud Code using our samples. If you created multiple samples (i.e. multiple samples subdirectories), you must tell the script which sample to use for generating snippets. Update the preferredSampleForResource map in pkg/snippet/snippetgeneration/snippetgeneration.go.

5.5 Add reference document

All beta resource can have a Google Reference documentation Connector reference doc. Please follow the steps to add the reference doc.

  1. Copy one of existing files under scripts/generate-google3-docs/resource-reference/templates, and name it like spanner_spannerinstance.tmpl, (i.e., _.tmpl).

  2. Add a paragraph to briefly introduce the resource at the very top of the file.

  3. If additional setup is necessary before the newly added resource can be applied successfully, and the setup can't be done via the Config Connector resources or features, add a "Prerequisites" section to explain the prerequisites steps, E.g. scripts/generate-google3-docs/resource-reference/generated/resource-docs/containerattached/containerattachedcluster.md and scripts/generate-google3-docs/resource-reference/generated/resource-docs/secretmanager/secretmanagersecret.md

  4. Update scripts/generate-google3-docs/resource-reference/overview.md by adding a row for your resource to the resource table. Note that {{spanner_name}} is the template variable for Cloud Spanner. The template variables for gcp product names can be found here.

  5. Update scripts/generate-google3-docs/resource-reference/_toc.yaml by adding an entry and path to the corresponding API section. If there is no entry for the API, add one.

  6. Run make resource-docs. You should see your resource generated to the scripts/generate-google3-docs/resource-reference/generated/resource-docs folder.

  7. Wait for the next Config Connector release, the release sheriff will publish the reference doc in Google based on the auto-generated doc folder.

5.6 Add reference document

Once you finish adding an Alpha resource, a Beta resource, or new fields to existing resources, you can add a releasenote for the next release. The release sheriff will publish the note.