Skip to content

Commit

Permalink
refactor: Switch Description to MarkdownDescription. Fix str_iterativ…
Browse files Browse the repository at this point in the history
…e_replace.
  • Loading branch information
skyzyx committed Mar 11, 2024
1 parent c30a8ba commit 3211d1b
Show file tree
Hide file tree
Showing 19 changed files with 120 additions and 114 deletions.
12 changes: 6 additions & 6 deletions corefuncprovider/env_ensure_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ func (d *envEnsureDataSource) Schema( // lint:no_dupe
`)),
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Description: "The name of the environment variable to check.",
Required: true,
MarkdownDescription: "The name of the environment variable to check.",
Required: true,
},
"pattern": schema.StringAttribute{
Description: "A valid Go ([re2](https://github.com/google/re2/wiki/Syntax)) regular expression pattern.",
Optional: true,
MarkdownDescription: "A valid Go ([re2](https://github.com/google/re2/wiki/Syntax)) regular expression pattern.",
Optional: true,
},
"value": schema.StringAttribute{
Description: "The value of the environment variable, if it exists.",
Computed: true,
MarkdownDescription: "The value of the environment variable, if it exists.",
Computed: true,
},
},
}
Expand Down
8 changes: 4 additions & 4 deletions corefuncprovider/homedir_expand_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ func (d *homedirExpandDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"path": schema.StringAttribute{
Description: "The path to expand.",
Required: true,
MarkdownDescription: "The path to expand.",
Required: true,
},
"value": schema.StringAttribute{
Description: "The path with the home directory expanded.",
Computed: true,
MarkdownDescription: "The path with the home directory expanded.",
Computed: true,
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions corefuncprovider/homedir_get_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ func (d *homedirGetDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"value": schema.StringAttribute{
Description: "The value of the home directory.",
Computed: true,
MarkdownDescription: "The value of the home directory.",
Computed: true,
},
},
}
Expand Down
12 changes: 6 additions & 6 deletions corefuncprovider/int_leftpad_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ func (d *intLeftpadDataSource) Schema( // lint:no_dupe
`)),
Attributes: map[string]schema.Attribute{
"num": schema.Int64Attribute{
Description: "The integer to pad with zeroes.",
Required: true,
MarkdownDescription: "The integer to pad with zeroes.",
Required: true,
},
"pad_width": schema.Int64Attribute{
Description: "The max number of zeroes to pad the integer with.",
Required: true,
MarkdownDescription: "The max number of zeroes to pad the integer with.",
Required: true,
},
"value": schema.StringAttribute{
Description: "The value of the string.",
Computed: true,
MarkdownDescription: "The value of the string.",
Computed: true,
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions corefuncprovider/runtime_cpuarch_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func (d *runtimeCpuarchDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"value": schema.StringAttribute{
Description: "Returns the CPU architecture for which the provider was compiled.",
Computed: true,
MarkdownDescription: "Returns the CPU architecture for which the provider was compiled.",
Computed: true,
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions corefuncprovider/runtime_goroot_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func (d *runtimeGorootDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"value": schema.StringAttribute{
Description: "Returns the GOROOT path for the current system, if one exists.",
Computed: true,
MarkdownDescription: "Returns the GOROOT path for the current system, if one exists.",
Computed: true,
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions corefuncprovider/runtime_numcpus_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ func (d *runtimeNumcpusDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"value": schema.Int64Attribute{
Description: "The number of CPU cores (logical CPUs) for the current system.",
Computed: true,
MarkdownDescription: "The number of CPU cores (logical CPUs) for the current system.",
Computed: true,
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions corefuncprovider/runtime_os_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ func (d *runtimeOsDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"value": schema.StringAttribute{
Description: "Returns the operating system for which the provider was compiled.",
Computed: true,
MarkdownDescription: "Returns the operating system for which the provider was compiled.",
Computed: true,
},
},
}
Expand Down
10 changes: 5 additions & 5 deletions corefuncprovider/str_camel_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ func (d *strCamelDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"string": schema.StringAttribute{
Description: "The string to convert to `camelCase`.",
Required: true,
MarkdownDescription: "The string to convert to `camelCase`.",
Required: true,
},
// "acronym_caps": schema.BoolAttribute{
// Description: "Whether or not to keep acronyms as uppercase. A value of `true` means that acronyms " +
// MarkdownDescription: "Whether or not to keep acronyms as uppercase. A value of `true` means that acronyms " +
// "will be converted to uppercase. A value of `false` means that acronyms will using typical " +
// "casing. The default value is `false`.",
// Optional: true,
// },
"value": schema.StringAttribute{
Description: "The value of the string.",
Computed: true,
MarkdownDescription: "The value of the string.",
Computed: true,
},
},
}
Expand Down
8 changes: 4 additions & 4 deletions corefuncprovider/str_constant_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ func (d *strConstantDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"string": schema.StringAttribute{
Description: "The string to convert to `CONSTANT_CASE`.",
Required: true,
MarkdownDescription: "The string to convert to `CONSTANT_CASE`.",
Required: true,
},
"value": schema.StringAttribute{
Description: "The value of the string.",
Computed: true,
MarkdownDescription: "The value of the string.",
Computed: true,
},
},
}
Expand Down
29 changes: 17 additions & 12 deletions corefuncprovider/str_iterative_replace_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"strings"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down Expand Up @@ -89,26 +88,32 @@ func (d *strIterativeReplaceDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"string": schema.StringAttribute{
Description: "The string upon which replacements should be applied.",
Required: true,
MarkdownDescription: "The string upon which replacements should be applied.",
Required: true,
},
"replacements": schema.ListAttribute{
Description: strings.TrimSpace(dedent.Dedent(`
"replacements": schema.ListNestedAttribute{
MarkdownDescription: strings.TrimSpace(dedent.Dedent(`
A list of maps. Each map has an ` + "`" + `old` + "`" + ` and ` + "`" + `new` + "`" +
` key. ` + "`" + `old` + "`" + ` represents the existing string to be replaced, and ` + "`" +
`new` + "`" + ` represents the replacement string.
`)),
Required: true,
ElementType: types.ObjectType{
AttrTypes: map[string]attr.Type{
"old": types.StringType,
"new": types.StringType,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"old": schema.StringAttribute{
MarkdownDescription: "The substring to be replaced.",
Required: true,
},
"new": schema.StringAttribute{
MarkdownDescription: "The replacement substring.",
Required: true,
},
},
},
Required: true,
},
"value": schema.StringAttribute{
Description: "The value of the string.",
Computed: true,
MarkdownDescription: "The value of the string.",
Computed: true,
},
},
}
Expand Down
11 changes: 6 additions & 5 deletions corefuncprovider/str_iterative_replace_data_source_fixture.tftpl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
data "corefunc_str_iterative_replace" "replacements" {
string = "{{ .Input }}"
replacements = [
{{- with .Replacements }}{{- range . }}

replacements {
old = "{{- .Old -}}"
new = "{{- .New -}}"
}
{
old = "{{- .Old -}}"
new = "{{- .New -}}"
},
{{- end }}{{- end }}
]
}
#=> {{ .Expected }}
8 changes: 4 additions & 4 deletions corefuncprovider/str_kebab_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ func (d *strKebabDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"string": schema.StringAttribute{
Description: "The string to convert to `kebab-case`.",
Required: true,
MarkdownDescription: "The string to convert to `kebab-case`.",
Required: true,
},
"value": schema.StringAttribute{
Description: "The value of the string.",
Computed: true,
MarkdownDescription: "The value of the string.",
Computed: true,
},
},
}
Expand Down
16 changes: 8 additions & 8 deletions corefuncprovider/str_leftpad_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ func (d *strLeftpadDataSource) Schema( // lint:no_dupe
`)),
Attributes: map[string]schema.Attribute{
"pad_width": schema.Int64Attribute{
Description: "The max number of padding characters to pad the string with.",
Required: true,
MarkdownDescription: "The max number of padding characters to pad the string with.",
Required: true,
},
"string": schema.StringAttribute{
Description: "The string to pad with padding characters.",
Required: true,
MarkdownDescription: "The string to pad with padding characters.",
Required: true,
},
"pad_char": schema.StringAttribute{
Description: "The padding character to use. Only supports a single byte. If more than one byte is provided, only the first byte will be used. The default value is a space character.", // lint:ignore_length
Optional: true,
MarkdownDescription: "The padding character to use. Only supports a single byte. If more than one byte is provided, only the first byte will be used. The default value is a space character.", // lint:ignore_length
Optional: true,
},
"value": schema.StringAttribute{
Description: "The value of the string.",
Computed: true,
MarkdownDescription: "The value of the string.",
Computed: true,
},
},
}
Expand Down
10 changes: 5 additions & 5 deletions corefuncprovider/str_pascal_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ func (d *strPascalDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"string": schema.StringAttribute{
Description: "The string to convert to `PascalCase`.",
Required: true,
MarkdownDescription: "The string to convert to `PascalCase`.",
Required: true,
},
"acronym_caps": schema.BoolAttribute{
Description: "Whether or not to keep acronyms as uppercase. A value of `true` means that acronyms " +
MarkdownDescription: "Whether or not to keep acronyms as uppercase. A value of `true` means that acronyms " +
"will be converted to uppercase. A value of `false` means that acronyms will using typical " +
"casing. The default value is `false`.",
Optional: true,
},
"value": schema.StringAttribute{
Description: "The value of the string.",
Computed: true,
MarkdownDescription: "The value of the string.",
Computed: true,
},
},
}
Expand Down
8 changes: 4 additions & 4 deletions corefuncprovider/str_snake_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ func (d *strSnakeDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"string": schema.StringAttribute{
Description: "The string to convert to `snake_case`.",
Required: true,
MarkdownDescription: "The string to convert to `snake_case`.",
Required: true,
},
"value": schema.StringAttribute{
Description: "The value of the string.",
Computed: true,
MarkdownDescription: "The value of the string.",
Computed: true,
},
},
}
Expand Down
14 changes: 7 additions & 7 deletions corefuncprovider/truncate_label_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,30 +109,30 @@ func (d *truncateLabelDataSource) Schema(
`)),
Attributes: map[string]schema.Attribute{
"max_length": schema.Int64Attribute{
Description: "The maximum allowed length of the combined label. " +
MarkdownDescription: "The maximum allowed length of the combined label. " +
"Minimum value is `1`. The default value is `64`.",
Optional: true,
Validators: []validator.Int64{
int64validator.AtLeast(1),
},
},
"prefix": schema.StringAttribute{
Description: "The prefix to prepend to the label.",
Required: true,
MarkdownDescription: "The prefix to prepend to the label.",
Required: true,
Validators: []validator.String{
stringvalidator.LengthBetween(0, validatorMaxLength),
},
},
"label": schema.StringAttribute{
Description: "The label itself.",
Required: true,
MarkdownDescription: "The label itself.",
Required: true,
Validators: []validator.String{
stringvalidator.LengthBetween(0, validatorMaxLength),
},
},
"value": schema.StringAttribute{
Description: "The value of the truncated label.",
Computed: true,
MarkdownDescription: "The value of the truncated label.",
Computed: true,
},
},
}
Expand Down
Loading

0 comments on commit 3211d1b

Please sign in to comment.