add-fields-workflow
Note to AI Agents: You MUST read the YAML frontmatter above first. Only read the rest of this file if the
descriptionmatches your required task.
Prerequisites
- You must be operating in the
magic-modulesroot directory. - You must know the target resource (e.g.,
google_compute_instance) and the API field(s) to add.
Execution Steps
1. Context & Schema Investigation
Before you begin implementation, read the following documents:
docs/content/develop/add-fields.md— Complete procedural guide for adding fields to MMv1 and handwritten resources.docs/content/reference/field.md— Comprehensive MMv1 field configuration reference.docs/content/test/test.md- Complete procedural guide for adding tests.docs/content/reference/sample.md- Comprehensive MMv1 sample configuration reference..agents/knowledge/index.mdfor general information.
Resource Definition Locations:
- MMv1 generated resources:
mmv1/products/<product>/<resource>.yaml - Handwritten resources:
mmv1/third_party/terraform/services/<product>/resource_<product>_<resource>.go
Implement logic according to the API behavior and terraform best practices. Your code should match the style of the resource and product.
2. Add fields
Add the requested field(s) to the requested resource(s).
3. Add tests for the fields
Field tests should exist according to the following rules:
- Every field must be present in at least one test step.
- Every mutable field must have its value altered in an update step.
- It's preferable for optional fields to be missing in at least one step to ensure that they're truly optional.
Because you're adding fields to an existing resource, try to modify existing tests if possible rather than adding new tests.
Test Locations:
- Generated :
mmv1/templates/terraform/samples/services/<PRODUCT>/ - Handwritten resources:
mmv1/third_party/terraform/services/<PRODUCT>/resource_<product>_<resource>_test.go
4. Run Pre-Gen Checks
- Use run-pre-gen-checks. If issues are found, analyze and fix them.
5. Generate Provider
- Use generate-provider.
- Confirm that the provider was generated successfully.
6. Test and Debug
- Use
repo-syncto ensure the downstream repositories are in sync with magic-modules. - Use
generate-providerto generate the provider code into the downstream repositories. - Invoke
qa-test-runnerto run all acceptance tests for the modified resource. - Invoke
test-fixerto fix any issues found by theqa-test-runnerskill. Return to step 4 after any changes.
The Loop
Repeat steps 4-6 as needed until the primary task is complete.