Skip to content

Commit

Permalink
parametrize deprecation docs with resource name
Browse files Browse the repository at this point in the history
  • Loading branch information
jooola committed Nov 21, 2024
1 parent e5f3432 commit 716c311
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
6 changes: 3 additions & 3 deletions docs/data-sources/server_type.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ resource "hcloud_server" "main" {
- `architecture` (String) Architecture of the cpu for a Server of this type.
- `cores` (Number) Number of cpu cores for a Server of this type.
- `cpu_type` (String) Type of cpu for a Server of this type.
- `deprecation_announced` (String) Date of the resource deprecation announcement.
- `deprecation_announced` (String) Date of the Server Type deprecation announcement.
- `description` (String) Description of the Server Type.
- `disk` (Number) Disk size in GB for a Server of this type.
- `included_traffic` (Number, Deprecated)
- `is_deprecated` (Boolean) Whether the resource is deprecated.
- `is_deprecated` (Boolean) Whether the Server Type is deprecated.
- `memory` (Number) Memory in GB for a Server of this type.
- `storage_type` (String) Type of boot drive for a Server of this type.
- `unavailable_after` (String) Date of the resource removal. After this date, the resource cannot be used anymore.
- `unavailable_after` (String) Date of the Server Type removal. After this date, the Server Type cannot be used anymore.
6 changes: 3 additions & 3 deletions docs/data-sources/server_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ Read-Only:
- `architecture` (String) Architecture of the cpu for a Server of this type.
- `cores` (Number) Number of cpu cores for a Server of this type.
- `cpu_type` (String) Type of cpu for a Server of this type.
- `deprecation_announced` (String) Date of the resource deprecation announcement.
- `deprecation_announced` (String) Date of the Server Type deprecation announcement.
- `description` (String) Description of the Server Type.
- `disk` (Number) Disk size in GB for a Server of this type.
- `id` (Number) ID of the Server Type.
- `included_traffic` (Number, Deprecated)
- `is_deprecated` (Boolean) Whether the resource is deprecated.
- `is_deprecated` (Boolean) Whether the Server Type is deprecated.
- `memory` (Number) Memory in GB for a Server of this type.
- `name` (String) Name of the Server Type.
- `storage_type` (String) Type of boot drive for a Server of this type.
- `unavailable_after` (String) Date of the resource removal. After this date, the resource cannot be used anymore.
- `unavailable_after` (String) Date of the Server Type removal. After this date, the Server Type cannot be used anymore.
17 changes: 9 additions & 8 deletions internal/deprecation/deprecation_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package deprecation

import (
"context"
"fmt"
"time"

"github.com/hashicorp/terraform-plugin-framework/attr"
Expand Down Expand Up @@ -46,35 +47,35 @@ func AttrTypes() map[string]attr.Type {
}
}

func DataSourceSchema() map[string]datasourceschema.Attribute {
func DataSourceSchema(resource string) map[string]datasourceschema.Attribute {
return map[string]datasourceschema.Attribute{
"is_deprecated": datasourceschema.BoolAttribute{
MarkdownDescription: "Whether the resource is deprecated.",
MarkdownDescription: fmt.Sprintf("Whether the %s is deprecated.", resource),
Computed: true,
},
"deprecation_announced": datasourceschema.StringAttribute{
MarkdownDescription: "Date of the resource deprecation announcement.",
MarkdownDescription: fmt.Sprintf("Date of the %s deprecation announcement.", resource),
Computed: true,
},
"unavailable_after": datasourceschema.StringAttribute{
MarkdownDescription: "Date of the resource removal. After this date, the resource cannot be used anymore.",
MarkdownDescription: fmt.Sprintf("Date of the %s removal. After this date, the %s cannot be used anymore.", resource, resource),
Computed: true,
},
}
}

func ResourceSchema() map[string]resourceschema.Attribute {
func ResourceSchema(resource string) map[string]resourceschema.Attribute {
return map[string]resourceschema.Attribute{
"is_deprecated": resourceschema.BoolAttribute{
MarkdownDescription: "Whether the resource is deprecated.",
MarkdownDescription: fmt.Sprintf("Whether the %s is deprecated.", resource),
Computed: true,
},
"deprecation_announced": resourceschema.StringAttribute{
MarkdownDescription: "Date of the resource deprecation announcement.",
MarkdownDescription: fmt.Sprintf("Date of the %s deprecation announcement.", resource),
Computed: true,
},
"unavailable_after": resourceschema.StringAttribute{
MarkdownDescription: "Date of the resource removal. After this date, the resource cannot be used anymore.",
MarkdownDescription: fmt.Sprintf("Date of the %s removal. After this date, the %s cannot be used anymore.", resource, resource),
Computed: true,
},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/servertype/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func getCommonDataSchema(readOnly bool) map[string]schema.Attribute {
DeprecationMessage: "The field is deprecated and will always report 0 after 2024-08-05.",
},
},
deprecation.DataSourceSchema(),
deprecation.DataSourceSchema("Server Type"),
)
}

Expand Down

0 comments on commit 716c311

Please sign in to comment.