namespaces, identifiers: split validation

After review, there are cases where having common requirements for
namespaces and identifiers creates contention between applications.  One
example is that it is nice to have namespaces comply with domain name
requirement, but that does not allow underscores, which are required for
certain identifiers.

The namespaces validation has been reverted to be in line with RFC 1035.
Existing identifiers has been modified to allow simply alpha-numeric
identifiers, while limiting adjacent separators.

We may follow up tweaks for the identifier charset but this split should
remove the hard decisions.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2017-07-12 14:46:47 -07:00
parent c63b84dcbc
commit 9e5bd5a2dc
10 changed files with 162 additions and 32 deletions

View File

@@ -13,13 +13,12 @@ func TestValidIdentifiers(t *testing.T) {
"Default",
t.Name(),
"default-default",
"default--default",
"containerd.io",
"foo.boo",
"swarmkit.docker.io",
"zn--e9.org", // or something like it!
"0912341234",
"task.0.0123456789",
"underscores_are_allowed",
strings.Repeat("a", maxLength),
} {
t.Run(input, func(t *testing.T) {
@@ -32,6 +31,7 @@ func TestValidIdentifiers(t *testing.T) {
func TestInvalidIdentifiers(t *testing.T) {
for _, input := range []string{
"",
".foo..foo",
"foo/foo",
"foo/..",
@@ -39,7 +39,9 @@ func TestInvalidIdentifiers(t *testing.T) {
"foo.-boo",
"-foo.boo",
"foo.boo-",
"foo_foo.boo_underscores", // boo-urns?
"but__only_tasteful_underscores",
"zn--e9.org", // or something like it!
"default--default",
strings.Repeat("a", maxLength+1),
} {