From c8865f11c51a57ed4ce9da54a353f39818c99e51 Mon Sep 17 00:00:00 2001 From: mitch-hamm <150183009+mitch-hamm@users.noreply.github.com> Date: Fri, 8 Mar 2024 09:58:42 -0600 Subject: [PATCH] Add name length check (#29) --- cloud/resource_cloud_environment.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cloud/resource_cloud_environment.go b/cloud/resource_cloud_environment.go index 0b688e3..68221ac 100644 --- a/cloud/resource_cloud_environment.go +++ b/cloud/resource_cloud_environment.go @@ -27,6 +27,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +const maxNameLength = 28 + func resourceCloudEnvironment() *schema.Resource { return &schema.Resource{ CreateContext: resourceCloudEnvironmentCreate, @@ -120,6 +122,10 @@ func resourceCloudEnvironmentCreate(ctx context.Context, d *schema.ResourceData, return diag.FromErr(fmt.Errorf("ERROR_INIT_CLIENT_ON_CLOUD_ENVIRONMENT: %w", err)) } + if len(name) > maxNameLength { + return diag.FromErr(fmt.Errorf("ERROR_INIT_CLIENT_ON_CLOUD_ENVIRONMENT: name must be less than %d characters", maxNameLength)) + } + cloudEnvironment := &cloudv1alpha1.CloudEnvironment{ TypeMeta: metav1.TypeMeta{ Kind: "CloudEnvironment",