Skip to content

Commit acde84f

Browse files
apricotejooola
andauthored
docs: add guidelines for deprecating attributes (#1313)
Co-authored-by: Jonas Lammler <[email protected]>
1 parent 49e6dd7 commit acde84f

File tree

1 file changed

+49
-8
lines changed

1 file changed

+49
-8
lines changed

README.md

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,28 @@
1010
- [Terraform](https://developer.hashicorp.com/terraform/install) or [OpenTofu](https://opentofu.org/docs/intro/install/)
1111
- Our provider tests run with Terraform or OpenTofu releases that are supported upstream.
1212
- Our provider should work with any tool that supports the [terraform plugin protocol version 6](https://developer.hashicorp.com/terraform/plugin/terraform-plugin-protocol#protocol-version-6).
13-
- [Go](https://go.dev/doc/install) 1.21.x (to build the provider plugin)
13+
- [Go](https://go.dev/doc/install) (to build the provider plugin)
1414

15-
## API Stability
15+
## Development
16+
17+
### API Stability
1618

1719
This Go module implements a Terraform Provider for Hetzner Cloud
1820
Services. We thus guarantee backwards compatibility only for use through
1921
Terraform HCL. The actual _Go code_ in this repository _may change
2022
without a major version increase_.
2123

22-
Currently the code is mostly located in the `hcloud` package. In the
24+
Currently, the code is mostly located in the `hcloud` package. In the
2325
long term we want to move most of the `hcloud` package into individual
2426
sub-packages located in the `internal` directory. The goal is a
2527
structure similar to HashiCorp's [Terraform Provider
2628
Scaffolding](https://github.com/hashicorp/terraform-provider-scaffolding)
2729

28-
## Using the provider
30+
### Using the provider
2931

3032
If you are building the provider, follow the instructions to [install it as a plugin](https://www.terraform.io/docs/plugins/basics.html#installing-a-plugin). After placing it into your plugins directory, run `terraform init` to initialize it.
3133

32-
## Building the provider
34+
### Building the provider
3335

3436
Clone repository to: `$GOPATH/src/github.com/hetznercloud/terraform-provider-hcloud`
3537

@@ -45,7 +47,7 @@ $ cd $GOPATH/src/github.com/hetznercloud/terraform-provider-hcloud
4547
$ make build
4648
```
4749

48-
## Developing the provider
50+
### Developing the provider
4951

5052
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.14+ is _required_). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`.
5153

@@ -86,7 +88,7 @@ $ go test -v -timeout=30m -parallel=8 ./internal/server
8688
# ...
8789
```
8890

89-
## Running a local build
91+
### Running a local build
9092

9193
Choose a terraform cli config file path:
9294

@@ -133,7 +135,7 @@ You should see the following warning:
133135
134136
```
135137

136-
## Releasing experimental features
138+
### Releasing experimental features
137139

138140
To publish experimental features as part of regular releases:
139141

@@ -159,3 +161,42 @@ To publish experimental features as part of regular releases:
159161
experimental.Product.AppendDiagnostic(&resp.Diagnostics)
160162
}
161163
```
164+
165+
### Deprecating attributes
166+
167+
When deprecating an attributes:
168+
169+
1. Mark the attribute in the schema as deprecated (for SDKv2, the docs template may also need updating), in the message explain the deprecation and link to changelog, for example:
170+
171+
```go
172+
func Resource() *schema.Resource {
173+
return &schema.Resource{
174+
// ...
175+
Schema: map[string]*schema.Schema{
176+
"datacenter": {
177+
// ...
178+
Deprecated: "The datacenter attribute is deprecated and will be removed after 1 July 2026. Please use the location attribute instead. See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.",
179+
// ...
180+
},
181+
},
182+
}
183+
}
184+
```
185+
186+
2. - For inputs: Implement backwards-compatible behaviour if possible
187+
- For output: Keep writing the attribute for as long as it is returned from the API. Once it is no longer
188+
returned the code should return the user config/previous state if available, or `""` (SDKv2) / `null` (Plugin Framework).
189+
190+
3. In the resource and datasource docs, add a `## Deprecations` section with a subsection for this field, explaining the behaviour and urging users to upgrade to a compatible version, for example:
191+
192+
```md
193+
### `datacenter` attribute
194+
195+
The `datacenter` attribute is deprecated, use the `ABC` attribute instead.
196+
197+
See our the [API changelog](https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters) for more details.
198+
199+
-> Please upgrade to `v1.W.0+` of the provider to avoid issues once the Hetzner Cloud API no longer returns the `XYZ` attribute.
200+
```
201+
202+
4. Highlight the deprecation in the Release Notes.

0 commit comments

Comments
 (0)