@@ -20,6 +20,10 @@ const (
20
20
21
21
RFC1035NameTemplate = "[a-z](?:[-a-z0-9]{%d,%d}[a-z0-9])"
22
22
CloudIoTIdRegex = "^[a-zA-Z][-a-zA-Z0-9._+~%]{2,254}$"
23
+
24
+ // Format of default Compute service accounts created by Google
25
+ // ${PROJECT_ID}[email protected] where PROJECT_ID is an int64 (max 20 digits)
26
+ ComputeServiceAccountNameRegex = "[0-9]{1,20}[email protected] "
23
27
)
24
28
25
29
var (
29
33
// 4 and 28 since the first and last character are excluded.
30
34
ServiceAccountNameRegex = fmt .Sprintf (RFC1035NameTemplate , 4 , 28 )
31
35
32
- ProjectNameInDNSFormRegex = "[-a-z0-9\\ .]{1,63}"
33
- ServiceAccountLinkRegex = "projects/" + ProjectRegex + "/serviceAccounts/" + ServiceAccountNameRegex + "@" + ProjectNameInDNSFormRegex + "\\ .iam\\ .gserviceaccount\\ .com$"
36
+ ServiceAccountLinkRegexPrefix = "projects/" + ProjectRegex + "/serviceAccounts/"
37
+ PossibleServiceAccountNames = []string {
38
+ AppEngineServiceAccountNameRegex ,
39
+ ComputeServiceAccountNameRegex ,
40
+ CreatedServiceAccountNameRegex ,
41
+ }
42
+ ServiceAccountLinkRegex = ServiceAccountLinkRegexPrefix + "(" + strings .Join (PossibleServiceAccountNames , "|" ) + ")"
43
+
44
+ // Format of service accounts created through the API
45
+ CreatedServiceAccountNameRegex = fmt .Sprintf (RFC1035NameTemplate , 4 , 28 ) + "@" + ProjectNameInDNSFormRegex + "\\ .iam\\ .gserviceaccount\\ .com$"
46
+ ProjectNameInDNSFormRegex = "[-a-z0-9\\ .]{1,63}"
47
+
48
+ // Format of default App Engine service accounts created by Google
49
+ AppEngineServiceAccountNameRegex = ProjectRegex + "@appspot.gserviceaccount.com"
34
50
)
35
51
36
52
var rfc1918Networks = []string {
0 commit comments