Skip to content

Commit

Permalink
change regex to support 1-63 and add new test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
karolgorc committed Oct 11, 2024
1 parent e1cc8ed commit 34f96b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mmv1/third_party/terraform/verify/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (

SubnetworkLinkRegex = "projects/(" + ProjectRegex + ")/regions/(" + RegionRegex + ")/subnetworks/(" + SubnetworkRegex + ")$"

RFC1035NameTemplate = "[a-z](?:[-a-z0-9]%v[a-z0-9])"
RFC1035NameTemplate = "[a-z]([-a-z0-9]%v[a-z0-9])?"
CloudIoTIdRegex = "^[a-zA-Z][-a-zA-Z0-9._+~%]{2,254}$"

// Format of default Compute service accounts created by Google
Expand Down
2 changes: 2 additions & 0 deletions mmv1/third_party/terraform/verify/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ func TestValidateRFC1035Name(t *testing.T) {
{TestName: "valid", Min: 6, Max: 30, Value: "a-valid-name0"},
{TestName: "valid lower bound", Min: 12, Max: 30, Value: "a-valid-name"},
{TestName: "valid upper bound", Min: 6, Max: 12, Value: "a-valid-name"},
{TestName: "valid shortest possible", Min: 1, Max: 63, Value: "a"},
{TestName: "valid longest possible", Min: 1, Max: 63, Value: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
{TestName: "valid with numbers", Min: 6, Max: 30, Value: "valid000-name"},
{TestName: "must start with a letter", Min: 6, Max: 10, Value: "0invalid", ExpectError: true},
{TestName: "cannot end with a dash", Min: 6, Max: 10, Value: "invalid-", ExpectError: true},
Expand Down

0 comments on commit 34f96b1

Please sign in to comment.