diff --git a/flux.go b/flux.go index 168d365f5..e27c5999e 100644 --- a/flux.go +++ b/flux.go @@ -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("^(|[a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)/([a-zA-Z0-9_.:-]+)$") UnqualifiedResourceIDRegexp = regexp.MustCompile("^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_.:-]+)$") ) diff --git a/resourceid_test.go b/resourceid_test.go index 49616d451..786792cc3 100644 --- a/resourceid_test.go +++ b/resourceid_test.go @@ -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", ":namespace/foo"}, } invalid := []test{ {"unqualified", "justname"},