Skip to content

Commit a7d50e3

Browse files
Add size validatation to accepted ca certs fields (#352)
* Add a min size validation to the accepted client CA * another minor update --------- Co-authored-by: Brian Kassouf <[email protected]>
1 parent 3af84a8 commit a7d50e3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

internal/provider/metrics_endpoint_resource.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import (
88
"github.com/google/uuid"
99

1010
"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
11+
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
1112
"github.com/hashicorp/terraform-plugin-framework/path"
1213
"github.com/hashicorp/terraform-plugin-framework/resource"
1314
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
1415
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
1516
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
17+
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1618
"github.com/hashicorp/terraform-plugin-framework/types"
1719

1820
accountv1 "go.temporal.io/cloud-sdk/api/account/v1"
@@ -83,6 +85,9 @@ func (r *metricsEndpointResource) Schema(ctx context.Context, _ resource.SchemaR
8385
CustomType: internaltypes.EncodedCAType{},
8486
Description: "The Base64-encoded CA cert in PEM format used to authenticate clients connecting to the metrics endpoint.",
8587
Required: true,
88+
Validators: []validator.String{
89+
stringvalidator.LengthAtLeast(1),
90+
},
8691
},
8792
"uri": schema.StringAttribute{
8893
Description: "The Prometheus metrics endpoint URI",

internal/provider/namespace_resource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"google.golang.org/protobuf/proto"
3838

3939
"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
40+
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
4041
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
4142

4243
"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
@@ -195,6 +196,9 @@ func (r *namespaceResource) Schema(ctx context.Context, _ resource.SchemaRequest
195196
CustomType: internaltypes.EncodedCAType{},
196197
Description: "The Base64-encoded CA cert in PEM format that clients use when authenticating with Temporal Cloud. This is a required field when a Namespace uses mTLS authentication.",
197198
Optional: true,
199+
Validators: []validator.String{
200+
stringvalidator.LengthAtLeast(1),
201+
},
198202
},
199203
"retention_days": schema.Int64Attribute{
200204
Description: "The number of days to retain workflow history. Any changes to the retention period will be applied to all new running workflows.",

0 commit comments

Comments
 (0)