Skip to content

Commit

Permalink
Add name length check (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitch-hamm authored Mar 8, 2024
1 parent b15d325 commit c8865f1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cloud/resource_cloud_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit c8865f1

Please sign in to comment.