Skip to content

Commit e5f9d4c

Browse files
authored
Merge pull request #115 from joshbeard/changelog-type-optional
fix: changelog 'type' is optional
2 parents c3dadf9 + 9f72b4c commit e5f9d4c

File tree

2 files changed

+2
-27
lines changed

2 files changed

+2
-27
lines changed

docs/resources/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ resource "readme_changelog" "example" {
4545

4646
- `hidden` (Boolean) Whether the changelog is hidden. This can alternatively be set using the `hidden` front matter key.
4747
- `title` (String) __REQUIRED.__ The title of the changelog. This can alternatively be set using the `title` front matter key.
48-
- `type` (String) __REQUIRED.__ The type of changelog. This can alternatively be set using the `type` front matter key. Valid values: added, fixed, improved, deprecated, removed
48+
- `type` (String) The type of changelog. This can alternatively be set using the `type` front matter key. Valid values: added, fixed, improved, deprecated, removed
4949

5050
### Read-Only
5151

readme/changelog_resource.go

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -182,31 +182,6 @@ func (r changelogResource) ValidateConfig(
182182
return
183183
}
184184
}
185-
186-
if data.Type.IsNull() {
187-
// check front matter for 'type'.
188-
typeMatter, diag := frontmatter.GetValue(ctx, data.Body.ValueString(), "Type")
189-
if diag != "" {
190-
resp.Diagnostics.AddAttributeError(
191-
path.Root("type"),
192-
"Error checking front matter during validation.",
193-
diag,
194-
)
195-
196-
return
197-
}
198-
199-
// Fail if type is not set in front matter or the attribute.
200-
if typeMatter == (reflect.Value{}) {
201-
resp.Diagnostics.AddAttributeError(
202-
path.Root("type"),
203-
"Missing required attribute.",
204-
"'type' must be set using the attribute or in the body front matter.",
205-
)
206-
207-
return
208-
}
209-
}
210185
}
211186

212187
// Create creates the changelog and sets the initial Terraform state.
@@ -417,7 +392,7 @@ func (r *changelogResource) Schema(_ context.Context, _ resource.SchemaRequest,
417392
},
418393
},
419394
"type": schema.StringAttribute{
420-
Description: "__REQUIRED.__ The type of changelog. This can alternatively be set using the `type` front matter key. " +
395+
Description: "The type of changelog. This can alternatively be set using the `type` front matter key. " +
421396
"Valid values: added, fixed, improved, deprecated, removed",
422397
Computed: true,
423398
Optional: true,

0 commit comments

Comments
 (0)