Allow dash in resource labels.

This commit is contained in:
Roman Tkachenko 2018-11-16 13:26:47 -08:00
parent 44f128640a
commit f7424e5c95
3 changed files with 7 additions and 6 deletions

View file

@ -292,7 +292,7 @@ const MetadataSchema = `{
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^[a-zA-Z/.0-9_*]+$": { "type": "string" }
"^[a-zA-Z/.0-9_*-]+$": { "type": "string" }
}
}
}

View file

@ -1986,7 +1986,7 @@ const RoleSpecV3SchemaDefinitions = `
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^[a-zA-Z/.0-9_*]+$": { "anyOf": [{"type": "string"}, { "type": "array", "items": {"type": "string"}}]}
"^[a-zA-Z/.0-9_*-]+$": { "anyOf": [{"type": "string"}, { "type": "array", "items": {"type": "string"}}]}
}
},
"logins": {
@ -2034,7 +2034,7 @@ const RoleSpecV2SchemaTemplate = `{
"node_labels": {
"type": "object",
"patternProperties": {
"^[a-zA-Z/.0-9_]$": { "type": "string" }
"^[a-zA-Z/.0-9_-]$": { "type": "string" }
}
},
"namespaces": {

View file

@ -215,7 +215,7 @@ func (s *RoleSuite) TestRoleParse(c *C) {
in: `{
"kind": "role",
"version": "v3",
"metadata": {"name": "name1"},
"metadata": {"name": "name1", "labels": {"a-b": "c"}},
"spec": {
"options": {
"cert_format": "standard",
@ -225,7 +225,7 @@ func (s *RoleSuite) TestRoleParse(c *C) {
"disconnect_expired_cert": "yes"
},
"allow": {
"node_labels": {"a": "b"},
"node_labels": {"a": "b", "c-d": "e"},
"namespaces": ["default"],
"rules": [
{
@ -249,6 +249,7 @@ func (s *RoleSuite) TestRoleParse(c *C) {
Metadata: Metadata{
Name: "name1",
Namespace: defaults.Namespace,
Labels: map[string]string{"a-b": "c"},
},
Spec: RoleSpecV3{
Options: RoleOptions{
@ -259,7 +260,7 @@ func (s *RoleSuite) TestRoleParse(c *C) {
DisconnectExpiredCert: NewBool(true),
},
Allow: RoleConditions{
NodeLabels: Labels{"a": []string{"b"}},
NodeLabels: Labels{"a": []string{"b"}, "c-d": []string{"e"}},
Namespaces: []string{"default"},
Rules: []Rule{
Rule{