Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ func ValidateWorkloadIdentityPoolId(v interface{}, k string) (ws []string, error
"%q (%q) can not start with \"gcp-\"", k, value))
}

if strings.HasSuffix(value, defaultWorkloadIdentityPoolIdSuffix) {
value = strings.TrimRight(value, defaultWorkloadIdentityPoolIdSuffix)
}
value = strings.TrimSuffix(value, defaultWorkloadIdentityPoolIdSuffix)

if !regexp.MustCompile(workloadIdentityPoolIdRegexp).MatchString(value) {
errors = append(errors, fmt.Errorf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestValidateIAMBetaWorkloadIdentityPoolId(t *testing.T) {
{TestName: "long", Value: "12345678901234567890123456789012"},
{TestName: "has a hyphen", Value: "foo-bar"},
{TestName: "default pool format", Value: "foo-bar.svc.id.goog"},
{TestName: "default pool format with base name ending in a suffix character", Value: "goods.svc.id.goog"},

// With errors
{TestName: "empty", Value: "", ExpectError: true},
Expand All @@ -26,6 +27,7 @@ func TestValidateIAMBetaWorkloadIdentityPoolId(t *testing.T) {
{TestName: "has an backslash", Value: "foo\bar", ExpectError: true},
{TestName: "too short", Value: "foo", ExpectError: true},
{TestName: "too long", Value: strings.Repeat("f", 33), ExpectError: true},
{TestName: "too long with suffix", Value: strings.Repeat("a", 32) + "g.svc.id.goog", ExpectError: true},
}

es := verify.TestStringValidationCases(x, iambeta.ValidateWorkloadIdentityPoolId)
Expand Down
Loading