Skip to content

Commit 54a0086

Browse files
authored
fix: handle server side default for security token (#53)
It turns out that if you leave the value unset, the server will generate one for you. We need to mark it computed to accept the value. We should also allow the old behaviour of setting an emtpy string. I ran the acceptance tests locally and they finally passed.
1 parent 5645140 commit 54a0086

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

internal/provider/stream_resource.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,10 @@ func (r *StreamResource) Schema(ctx context.Context, req resource.SchemaRequest,
308308
},
309309

310310
"security_token": schema.StringAttribute{
311+
// If unset, the server will generate one for you
311312
Optional: true,
312313
Sensitive: true,
314+
Computed: true,
313315
Validators: []validator.String{
314316
securityTokenValidator,
315317
},

internal/validators/stream_validators.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ var (
185185
}
186186

187187
SecurityTokenValidator = StringRegexpValidator{
188-
regexp: regexp.MustCompile(`^.{32,64}$`),
188+
regexp: regexp.MustCompile(`^(.{32,64}|)$`),
189189
message: "security token must be between 32-64 characters",
190190
}
191191

0 commit comments

Comments
 (0)