From b94831a26e39383d01271ca07c2a4dbfba13d045 Mon Sep 17 00:00:00 2001 From: Gavin Jefferies Date: Fri, 22 Sep 2023 16:42:30 -0700 Subject: [PATCH] Revert "ROX-19609: add cluster name validation to infractl (#980)" This reverts commit 5128fa5b35755f96f782a6629851e5dd1e37c3cb. --- cmd/infractl/cluster/create/command.go | 26 +------------------------ cmd/infractl/cluster/create/create.bats | 18 ----------------- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/cmd/infractl/cluster/create/command.go b/cmd/infractl/cluster/create/command.go index 17821c0af..6d3959d8f 100644 --- a/cmd/infractl/cluster/create/command.go +++ b/cmd/infractl/cluster/create/command.go @@ -118,12 +118,7 @@ func run(ctx context.Context, conn *grpc.ClientConn, cmd *cobra.Command, args [] displayUserNotes(cmd, args, &req) if len(args) > 1 { - name := args[1] - err := validateName(name) - if err != nil { - return nil, err - } - req.Parameters["name"] = name + req.Parameters["name"] = args[1] } else { name, err := determineName(ctx, conn, args[0]) if err != nil { @@ -151,25 +146,6 @@ func run(ctx context.Context, conn *grpc.ClientConn, cmd *cobra.Command, args [] return prettyResourceByID(*clusterID), nil } -func validateName(name string) error { - if len(name) < 3 { - return errors.New("cluster name too short") - } - if len(name) > 28 { - return errors.New("cluster name too long") - } - - match, err := regexp.MatchString(`^(?:[a-z](?:[-a-z0-9]{0,28}[a-z0-9])?)$`, name) - if err != nil { - return err - } - if !match { - return errors.New("The name does not match the requirements. Only lowercase letters, numbers, and '-' allowed, must start with a letter and end with a letter or number.") - } - - return nil -} - func determineWorkingEnvironment() { workingEnvironment.gitTopLevel = "" workingEnvironment.tag = "" diff --git a/cmd/infractl/cluster/create/create.bats b/cmd/infractl/cluster/create/create.bats index 6baf35142..d432329df 100644 --- a/cmd/infractl/cluster/create/create.bats +++ b/cmd/infractl/cluster/create/create.bats @@ -123,24 +123,6 @@ setup() { assert_output --partial "parameter \"main-image\" was not provided" } -@test "provided name failed validation because too short" { - run infractl create test-qa-demo ab - assert_failure - assert_output --partial "Error: cluster name too short" -} - -@test "provided name failed validation because too long" { - run infractl create test-qa-demo this-name-will-be-too-loooooooooooooooooooong - assert_failure - assert_output --partial "Error: cluster name too long" -} - -@test "provided name failed validation because does not match regex" { - run infractl create test-qa-demo THIS-IN-INVALID - assert_failure - assert_output --partial "Error: The name does not match the requirements." -} - infractl() { "$ROOT"/bin/infractl -e localhost:8443 -k "$@" }