Skip to content

Commit

Permalink
Static SANs must be a list (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
areed authored Oct 9, 2023
1 parent 5753bab commit 8435566
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.4.1

BUG FIXES:
* smallstep_workload.static_sans is a list of strings not a set since the first is used as the Common Name.

## 0.4.0

FEATURES:
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/workload.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ resource "smallstep_workload" "redis" {
For example, if the device instance data in the collection is `{"internal_host": "foo.internal", "external_host", "foo.example.com"}` at the time the workload certificate is issued and this field is set to `["internal_host", "external_host"]`, then the certificate would include the SANs `foo.internal` and `foo.example.com`.
- `hooks` (Attributes) The collection of commands to run when a certificate for a managed endpoint is signed or renewed. (see [below for nested schema](#nestedatt--hooks))
- `reload_info` (Attributes) The properties used to reload a service. (see [below for nested schema](#nestedatt--reload_info))
- `static_sans` (Set of String) SANs that will be added to every certificate issued for this workload. The first will be used as the default Common Name.
- `static_sans` (List of String) SANs that will be added to every certificate issued for this workload. The first will be used as the default Common Name.

### Read-Only

Expand Down
4 changes: 2 additions & 2 deletions internal/provider/workload/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Model struct {
Hooks types.Object `tfsdk:"hooks"`
AdminEmails types.Set `tfsdk:"admin_emails"`
DeviceMetadataKeySANs types.Set `tfsdk:"device_metadata_key_sans"`
StaticSANs types.Set `tfsdk:"static_sans"`
StaticSANs types.List `tfsdk:"static_sans"`
}

func fromAPI(ctx context.Context, workload *v20230301.Workload, state utils.AttributeGetter) (*Model, diag.Diagnostics) {
Expand Down Expand Up @@ -72,7 +72,7 @@ func fromAPI(ctx context.Context, workload *v20230301.Workload, state utils.Attr
},
}

model.StaticSANs, d = utils.ToOptionalSet(ctx, workload.StaticSANs, state, path.Root("static_sans"))
model.StaticSANs, d = utils.ToOptionalList(ctx, workload.StaticSANs, state, path.Root("static_sans"))
diags.Append(d...)
if diags.HasError() {
return nil, diags
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/workload/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp
setplanmodifier.UseStateForUnknown(),
},
},
"static_sans": schema.SetAttribute{
"static_sans": schema.ListAttribute{
MarkdownDescription: props["staticSANs"],
ElementType: types.StringType,
Optional: true,
Expand Down

0 comments on commit 8435566

Please sign in to comment.