ui: Add namespaced versions of templated policies (#8173)

This commit is contained in:
John Cowen 2020-06-23 17:58:43 +01:00 committed by hashicorp-ci
parent 44f03b4f6c
commit deb77f31cb
5 changed files with 36 additions and 6 deletions

View File

@ -1,6 +1,19 @@
{{#if (env "CONSUL_NSPACES_ENABLED")}}
namespace "default" {
node "{{name}}" {
policy = "write"
}
}
namespace_prefix "" {
service_prefix "" {
policy = "read"
}
}
{{else}}
node "{{name}}" { node "{{name}}" {
policy = "write" policy = "write"
} }
service_prefix "" { service_prefix "" {
policy = "read" policy = "read"
} }
{{/if}}

View File

@ -36,7 +36,7 @@
<span>Rules <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a></span> <span>Rules <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a></span>
{{#if (eq item.template 'service-identity')}} {{#if (eq item.template 'service-identity')}}
<CodeEditor @readonly={{true}} @name={{concat name "[Rules]"}} @syntax="hcl" @oninput={{action "change" (concat name "[Rules]")}}> <CodeEditor @readonly={{true}} @name={{concat name "[Rules]"}} @syntax="hcl" @oninput={{action "change" (concat name "[Rules]")}}>
{{~component 'service-identity' name=item.Name~}} {{~component 'service-identity' nspace=nspace name=item.Name~}}
</CodeEditor> </CodeEditor>
{{else if (eq item.template 'node-identity')}} {{else if (eq item.template 'node-identity')}}
<CodeEditor @readonly={{true}} @name={{concat name "[Rules]"}} @syntax="hcl" @oninput={{action "change" (concat name "[Rules]")}}> <CodeEditor @readonly={{true}} @name={{concat name "[Rules]"}} @syntax="hcl" @oninput={{action "change" (concat name "[Rules]")}}>

View File

@ -21,7 +21,7 @@
<h2>New Policy</h2> <h2>New Policy</h2>
</BlockSlot> </BlockSlot>
<BlockSlot @name="body"> <BlockSlot @name="body">
<PolicyForm @form={{form}} @dc={{dc}} @allowServiceIdentity={{allowServiceIdentity}} /> <PolicyForm @form={{form}} @nspace={{nspace}} @dc={{dc}} @allowServiceIdentity={{allowServiceIdentity}} />
</BlockSlot> </BlockSlot>
<BlockSlot @name="actions" as |close|> <BlockSlot @name="actions" as |close|>
<button type="submit" {{action 'save' item items (queue (action close) (action 'reset'))}} disabled={{if (or item.isSaving item.isPristine item.isInvalid) 'disabled'}}> <button type="submit" {{action 'save' item items (queue (action close) (action 'reset'))}} disabled={{if (or item.isSaving item.isPristine item.isInvalid) 'disabled'}}>
@ -83,7 +83,7 @@
<span>Rules <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a></span> <span>Rules <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a></span>
{{#if (eq item.template 'service-identity')}} {{#if (eq item.template 'service-identity')}}
<CodeEditor @syntax="hcl" @readonly={{true}}> <CodeEditor @syntax="hcl" @readonly={{true}}>
{{~component 'service-identity' name=item.Name~}} {{~component 'service-identity' nspace=nspace name=item.Name~}}
</CodeEditor> </CodeEditor>
{{else if (eq item.template 'node-identity')}} {{else if (eq item.template 'node-identity')}}
<CodeEditor @syntax="hcl" @readonly={{true}}> <CodeEditor @syntax="hcl" @readonly={{true}}>

View File

@ -1,3 +1,5 @@
{{#if (env "CONSUL_NSPACES_ENABLED")}}
namespace "{{nspace}}" {
service "{{name}}" { service "{{name}}" {
policy = "write" policy = "write"
} }
@ -10,3 +12,18 @@ service_prefix "" {
node_prefix "" { node_prefix "" {
policy = "read" policy = "read"
} }
}
{{else}}
service "{{name}}" {
policy = "write"
}
service "{{name}}-sidecar-proxy" {
policy = "write"
}
service_prefix "" {
policy = "read"
}
node_prefix "" {
policy = "read"
}
{{/if}}

View File

@ -1,5 +1,5 @@
<form> <form>
<PolicyForm @form={{form}} @item={{item}}> <PolicyForm @form={{form}} @nspace={{nspace}} @item={{item}}>
{{!don't show template selection here, i.e. Service Identity}} {{!don't show template selection here, i.e. Service Identity}}
<BlockSlot @name="template" /> <BlockSlot @name="template" />
</PolicyForm> </PolicyForm>