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

Admit "<cluster>" when parsing ResourceIDs #1851

Merged
merged 1 commit into from
Mar 21, 2019
Merged
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
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