Skip to content

Commit 806a25a

Browse files
authored
docs: add provider-wide best practices section to CONTRIBUTING.md (#6573)
1 parent 22bfc73 commit 806a25a

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

CONTRIBUTING.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,48 @@ Thank you for contributing! Here you will find the information on what to includ
6666
* For PRs that follow the guidelines, we expect to review and merge very quickly.
6767
* PRs that do not follow the guidelines is annotated with what they are missing. A community or core team member may be able to swing around and help finish up the work, but these PRs generally hang out much longer until completed and merged.
6868

69+
---
70+
71+
# **Provider-wide Best Practices (Mandatory for all PRs)**
72+
73+
### Schema Rules
74+
- **Required** fields must be supplied by the user; if changing them requires recreation, mark as **ForceNew**.
75+
- **Optional** fields must not be sent when unset; avoid sending empty strings.
76+
- **Computed** fields are assigned only in `Read`, never in Create/Update.
77+
- **Optional + Computed** fields are used when APIs provide defaults or canonicalized values.
78+
- **Sensitive** must be applied to passwords, tokens, and secret fields.
79+
- **ForceNew** must be used for:
80+
- identity fields (instance, region, zone, VPC, subnet, binding IDs)
81+
- create-only parameters (clone-from, image IDs, snapshot IDs)
82+
- structural choices (mode, type, topology, binding)
83+
84+
### CRUD Lifecycle Guidance
85+
- **Create:** Only send meaningful values. Always return to `Read` afterwards.
86+
- **Read:** Canonicalize; normalize sets/lists; clear ID on 404.
87+
- **Update:** Only update attributes supported by API. Never simulate recreate inside Update.
88+
- **Delete:** Treat 404 as success. Always clear ID.
89+
90+
### Diff & Normalization
91+
- Avoid `DiffSuppressFunc` unless equivalence is provably correct.
92+
- Normalize unordered results in **Read** using sorted lists/sets.
93+
- Don’t ignore user changes unless API truly ignores them.
94+
95+
### Validation
96+
- Always use validators for string length, patterns, enums.
97+
- Fail early when invalid input is easier for user to correct.
98+
99+
### Acceptance Tests
100+
- Include idempotency checks: second apply should produce **0 changes**.
101+
- Always include a `CheckDestroy`.
102+
- Never rely solely on state; verify against API responses.
103+
- Randomize resource names to avoid collisions.
104+
105+
### Documentation
106+
- Every schema change must update docs in the same PR.
107+
- New resources require a complete doc page + examples.
108+
109+
---
110+
69111
### Checklists for contribution
70112

71113
There are different kinds of contribution, each of which has its own standards for a speedy review. The following sections describe the guidelines for each type of the contribution.
@@ -278,6 +320,7 @@ The `IBM Cloud Provider for Terraform` release can be mainly classified in to th
278320
- Dev release
279321
280322
### Production release
323+
281324
Typically, the production release of the `IBM Cloud Provider for Terraform` will be made, once in a month. The release can be major or minor based on the PR's commited. The production release is targetted from branch **release**. Once the release is published, users can download the binary from [Terraform registry](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest).
282325
283326
#### How to use this provider
@@ -306,6 +349,7 @@ Typically, the pre-production releases of the `IBM Cloud Provider for Terraform`
306349
~> **Note** A pre-release version is a version number that contains a suffix introduced by a dash, such as **1.38.0-pre**. A pre-release version can be selected only by an exact version constraint (the = operator or no operator). Pre-release versions do not match inexact operators such as `>=`, `~>`, etc.
307350
308351
#### How to use this provider
352+
309353
To install Terraform 0.13 or higher version provider, copy and paste this code into your Terraform configuration. Then, run `terraform init`.
310354
311355
```terraform
@@ -325,7 +369,7 @@ provider "ibm" {
325369
326370
### Dev release
327371
328-
The individual developers or the IBM Cloud Service team can make their own `dev` releases, from their respective Git repository (forked from https://github.com/IBM-Cloud/terraform-provider-ibm).
372+
The individual developers or the IBM Cloud Service team can make their own `dev` releases, from their respective Git repository (forked from [https://github.com/IBM-Cloud/terraform-provider-ibm](https://github.com/IBM-Cloud/terraform-provider-ibm)).
329373
330374
Note: You can use the existing GitHub actions to run the release workflows, in your forked repository. You can prepare a `dev` release by adding a new version tag in your repository.
331375
@@ -347,6 +391,7 @@ Note: You can use the existing GitHub actions to run the release workflows, in y
347391
- On Windows, the file must be named **terraform.rc** and placed in the relevant user's %APPDATA% directory.
348392
- On all other systems, the file must be named **.terraformrc** (note the leading period) and placed directly in the home directory of the relevant user.
349393
- Add below content to CLI configuration file
394+
350395
```terraform
351396
provider_installation {
352397
filesystem_mirror {
@@ -358,3 +403,4 @@ Note: You can use the existing GitHub actions to run the release workflows, in y
358403
}
359404
}
360405
```
406+

0 commit comments

Comments
 (0)