diff --git a/agent/structs/acltemplatedpolicy/policies/ce/nomad-client.hcl b/agent/structs/acltemplatedpolicy/policies/ce/nomad-client.hcl index 26941a8128..4045531f08 100644 --- a/agent/structs/acltemplatedpolicy/policies/ce/nomad-client.hcl +++ b/agent/structs/acltemplatedpolicy/policies/ce/nomad-client.hcl @@ -1,7 +1,7 @@ agent_prefix "" { policy = "read" } -node_prefix "" { +node "{{.Name}}" { policy = "write" } service_prefix "" { diff --git a/agent/structs/acltemplatedpolicy/policies/ce/nomad-server.hcl b/agent/structs/acltemplatedpolicy/policies/ce/nomad-server.hcl index 23cb78e113..2bb5f49852 100644 --- a/agent/structs/acltemplatedpolicy/policies/ce/nomad-server.hcl +++ b/agent/structs/acltemplatedpolicy/policies/ce/nomad-server.hcl @@ -5,7 +5,7 @@ mesh = "write" agent_prefix "" { policy = "read" } -node_prefix "" { +node "{{.Name}}" { policy = "write" } service_prefix "" { diff --git a/command/acl/templatedpolicy/formatter.go b/command/acl/templatedpolicy/formatter.go index e71b52a375..32263d9c92 100644 --- a/command/acl/templatedpolicy/formatter.go +++ b/command/acl/templatedpolicy/formatter.go @@ -71,11 +71,11 @@ func (f *prettyFormatter) FormatTemplatedPolicy(templatedPolicy api.ACLTemplated switch templatedPolicy.TemplateName { case api.ACLTemplatedPolicyServiceName: nameRequiredVariableOutput(&buffer, templatedPolicy.TemplateName, "The name of the service", "api") - case api.ACLTemplatedPolicyNodeName: + case api.ACLTemplatedPolicyNodeName, api.ACLTemplatedPolicyNomadServerName, api.ACLTemplatedPolicyNomadClientName: nameRequiredVariableOutput(&buffer, templatedPolicy.TemplateName, "The node name", "node-1") case api.ACLTemplatedPolicyAPIGatewayName: nameRequiredVariableOutput(&buffer, templatedPolicy.TemplateName, "The api gateway service name", "api-gateway") - case api.ACLTemplatedPolicyDNSName, api.ACLTemplatedPolicyNomadServerName, api.ACLTemplatedPolicyNomadClientName: + case api.ACLTemplatedPolicyDNSName: noRequiredVariablesOutput(&buffer, templatedPolicy.TemplateName) default: buffer.WriteString(" None\n") diff --git a/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-client-templated-policy.json.golden b/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-client-templated-policy.json.golden index 0fece044de..5b59695096 100644 --- a/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-client-templated-policy.json.golden +++ b/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-client-templated-policy.json.golden @@ -1,6 +1,6 @@ { "TemplateName": "builtin/nomad-client", "Schema": "", - "Template": "agent_prefix \"\" {\n policy = \"read\"\n}\nnode_prefix \"\" {\n policy = \"write\"\n}\nservice_prefix \"\" {\n policy = \"write\"\n}\nkey_prefix \"\" {\n policy = \"read\"\n}", + "Template": "agent_prefix \"\" {\n policy = \"read\"\n}\nnode \"{{.Name}}\" {\n policy = \"write\"\n}\nservice_prefix \"\" {\n policy = \"write\"\n}\nkey_prefix \"\" {\n policy = \"read\"\n}", "Description": "Gives the token or role permissions required for integration with a nomad client." } \ No newline at end of file diff --git a/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-client-templated-policy.pretty-meta.golden b/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-client-templated-policy.pretty-meta.golden index cc3a19df2c..99ce3c4437 100644 --- a/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-client-templated-policy.pretty-meta.golden +++ b/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-client-templated-policy.pretty-meta.golden @@ -1,13 +1,14 @@ Name: builtin/nomad-client Description: Gives the token or role permissions required for integration with a nomad client. -Input variables: None +Input variables: + Name: String - Required - The node name. Example usage: - consul acl token create -templated-policy builtin/nomad-client + consul acl token create -templated-policy builtin/nomad-client -var name:node-1 Raw Template: agent_prefix "" { policy = "read" } -node_prefix "" { +node "{{.Name}}" { policy = "write" } service_prefix "" { diff --git a/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-client-templated-policy.pretty.golden b/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-client-templated-policy.pretty.golden index 6dd152d498..8125eaaa42 100644 --- a/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-client-templated-policy.pretty.golden +++ b/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-client-templated-policy.pretty.golden @@ -1,5 +1,6 @@ Name: builtin/nomad-client Description: Gives the token or role permissions required for integration with a nomad client. -Input variables: None +Input variables: + Name: String - Required - The node name. Example usage: - consul acl token create -templated-policy builtin/nomad-client + consul acl token create -templated-policy builtin/nomad-client -var name:node-1 diff --git a/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-server-templated-policy.json.golden b/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-server-templated-policy.json.golden index 56b257a1fa..6adac15f21 100644 --- a/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-server-templated-policy.json.golden +++ b/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-server-templated-policy.json.golden @@ -1,6 +1,6 @@ { "TemplateName": "builtin/nomad-server", "Schema": "", - "Template": "\nacl = \"write\"\nmesh = \"write\"\n\nagent_prefix \"\" {\n policy = \"read\"\n}\nnode_prefix \"\" {\n policy = \"write\"\n}\nservice_prefix \"\" {\n policy = \"write\"\n}", + "Template": "\nacl = \"write\"\nmesh = \"write\"\n\nagent_prefix \"\" {\n policy = \"read\"\n}\nnode \"{{.Name}}\" {\n policy = \"write\"\n}\nservice_prefix \"\" {\n policy = \"write\"\n}", "Description": "Gives the token or role permissions required for integration with a nomad server." } \ No newline at end of file diff --git a/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-server-templated-policy.pretty-meta.golden b/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-server-templated-policy.pretty-meta.golden index 0ce9e58532..9c38bd962e 100644 --- a/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-server-templated-policy.pretty-meta.golden +++ b/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-server-templated-policy.pretty-meta.golden @@ -1,8 +1,9 @@ Name: builtin/nomad-server Description: Gives the token or role permissions required for integration with a nomad server. -Input variables: None +Input variables: + Name: String - Required - The node name. Example usage: - consul acl token create -templated-policy builtin/nomad-server + consul acl token create -templated-policy builtin/nomad-server -var name:node-1 Raw Template: acl = "write" @@ -11,7 +12,7 @@ mesh = "write" agent_prefix "" { policy = "read" } -node_prefix "" { +node "{{.Name}}" { policy = "write" } service_prefix "" { diff --git a/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-server-templated-policy.pretty.golden b/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-server-templated-policy.pretty.golden index e65d016320..45f8e11dd8 100644 --- a/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-server-templated-policy.pretty.golden +++ b/command/acl/templatedpolicy/testdata/FormatTemplatedPolicy/ce/nomad-server-templated-policy.pretty.golden @@ -1,5 +1,6 @@ Name: builtin/nomad-server Description: Gives the token or role permissions required for integration with a nomad server. -Input variables: None +Input variables: + Name: String - Required - The node name. Example usage: - consul acl token create -templated-policy builtin/nomad-server + consul acl token create -templated-policy builtin/nomad-server -var name:node-1