Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1851 from weaveworks/issue/1843-cluster-scope-sen…
Browse files Browse the repository at this point in the history
…tinel

Admit "<cluster>" when parsing ResourceIDs
  • Loading branch information
squaremo authored Mar 21, 2019
2 parents 88402e3 + 74575ae commit 48966b9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ var (
ErrInvalidServiceID = errors.New("invalid service ID")

LegacyServiceIDRegexp = regexp.MustCompile("^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$")
// The namespace and name commponents are (apparently
// The namespace and name components are (apparently
// non-normatively) defined in
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/architecture/identifiers.md
// In practice, more punctuation is used than allowed there;
// specifically, people use underscores as well as dashes and dots, and in names, colons.
ResourceIDRegexp = regexp.MustCompile("^([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)/([a-zA-Z0-9_.:-]+)$")
ResourceIDRegexp = regexp.MustCompile("^(<cluster>|[a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)/([a-zA-Z0-9_.:-]+)$")
UnqualifiedResourceIDRegexp = regexp.MustCompile("^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_.:-]+)$")
)

Expand Down
1 change: 1 addition & 0 deletions resourceid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func TestResourceIDParsing(t *testing.T) {
{"dots", "namespace:kind/name.with.dots"},
{"colons", "namespace:kind/name:with:colons"},
{"punctuation in general", "name-space:ki_nd/punc_tu:a.tion-rules"},
{"cluster-scope resource", "<cluster>:namespace/foo"},
}
invalid := []test{
{"unqualified", "justname"},
Expand Down

0 comments on commit 48966b9

Please sign in to comment.