Skip to content

Commit

Permalink
add check for already-configured metrics endpoint + fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ennyjfrick committed Dec 13, 2024
1 parent 36897e1 commit a20904b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/provider/metrics_endpoint_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,14 @@ func (r *metricsEndpointResource) Configure(_ context.Context, req resource.Conf
}

r.client = cli

return
}

// Metadata returns the resource type name.
func (r *metricsEndpointResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_metrics_endpoint"
}

// Schema defines the schema for the resource
// Schema defines the schema for the resource.
func (r *metricsEndpointResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "Configures a Temporal Cloud account's metrics",
Expand Down Expand Up @@ -121,6 +119,11 @@ func (r *metricsEndpointResource) Create(ctx context.Context, req resource.Creat
return
}

if accResp.GetAccount().GetMetrics().GetUri() != "" {
resp.Diagnostics.AddError("Metrics endpoint already configured.", fmt.Sprintf("account metrics endpoint already configured with url %q, remove the existing metrics configuration to manage it with Terraform", accResp.GetAccount().GetMetrics().GetUri()))
return
}

certs, err := base64.StdEncoding.DecodeString(plan.AcceptedClientCA.ValueString())
if err != nil {
resp.Diagnostics.AddError("Invalid (base64 encoded) accepted_client_ca", err.Error())
Expand Down

0 comments on commit a20904b

Please sign in to comment.