File tree Expand file tree Collapse file tree 5 files changed +23
-4
lines changed Expand file tree Collapse file tree 5 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -13,11 +13,16 @@ const (
13
13
SpaceSnippet = "(?:[a-z0-9]+(?:-[a-z0-9]+)*)"
14
14
)
15
15
16
- var validSpace = regexp .MustCompile ("^" + SpaceSnippet + "$" )
16
+ var (
17
+ validSpace = regexp .MustCompile ("^" + UUIDv7Snippet + "$" )
18
+ // Deprecated: Juju 4.0 should have space IDs in the form of UUIDv7.
19
+ fallbackValidSpace = regexp .MustCompile ("^" + SpaceSnippet + "$" )
20
+ )
17
21
18
22
// IsValidSpace reports whether name is a valid space name.
19
23
func IsValidSpace (name string ) bool {
20
- return validSpace .MatchString (name )
24
+ return validSpace .MatchString (name ) ||
25
+ fallbackValidSpace .MatchString (name )
21
26
}
22
27
23
28
type SpaceTag struct {
Original file line number Diff line number Diff line change @@ -60,6 +60,9 @@ var parseSpaceTagTests = []struct {
60
60
}, {
61
61
tag : "space-1" ,
62
62
expected : names .NewSpaceTag ("1" ),
63
+ }, {
64
+ tag : "space-0195847b-95bb-7ca1-a7ee-2211d802d5b3" ,
65
+ expected : names .NewSpaceTag ("0195847b-95bb-7ca1-a7ee-2211d802d5b3" ),
63
66
}, {
64
67
tag : "-space1" ,
65
68
err : names .InvalidTagError ("-space1" , "" ),
Original file line number Diff line number Diff line change @@ -10,11 +10,16 @@ import (
10
10
11
11
const SubnetTagKind = "subnet"
12
12
13
- var validSubnet = regexp .MustCompile ("^" + NumberSnippet + "$" )
13
+ var (
14
+ validSubnet = regexp .MustCompile ("^" + UUIDv7Snippet + "$" )
15
+ // Deprecated: Juju 4.0 should have subnet IDs in the form of UUIDv7.
16
+ fallbackValidSubnet = regexp .MustCompile ("^" + NumberSnippet + "$" )
17
+ )
14
18
15
19
// IsValidSubnet returns whether id is a valid subnet id.
16
20
func IsValidSubnet (id string ) bool {
17
- return validSubnet .MatchString (id )
21
+ return validSubnet .MatchString (id ) ||
22
+ fallbackValidSubnet .MatchString (id )
18
23
}
19
24
20
25
type SubnetTag struct {
Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ var parseSubnetTagTests = []struct {
38
38
}, {
39
39
tag : "subnet-16" ,
40
40
expected : names .NewSubnetTag ("16" ),
41
+ }, {
42
+ tag : "subnet-0195847b-95bb-7ca1-a7ee-2211d802d5b3" ,
43
+ expected : names .NewSubnetTag ("0195847b-95bb-7ca1-a7ee-2211d802d5b3" ),
41
44
}, {
42
45
tag : "subnet-foo" ,
43
46
err : names .InvalidTagError ("subnet-foo" , names .SubnetTagKind ),
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ const (
19
19
// NumberSnippet is a non-compiled regexp that can be composed with other
20
20
// snippets for validating small number sequences.
21
21
NumberSnippet = "(?:0|[1-9][0-9]*)"
22
+ // UUIDv7Snippet is a non-compiled regexp that can be composed with other
23
+ // snippets for validating UUID v7 strings.
24
+ UUIDv7Snippet = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
22
25
)
23
26
24
27
var (
You can’t perform that action at this time.
0 commit comments