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 GitHub
parent 6bc1b2be44
commit 8eb1133cac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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}}" {
policy = "write"
}
service_prefix "" {
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>
{{#if (eq item.template 'service-identity')}}
<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>
{{else if (eq item.template 'node-identity')}}
<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>
</BlockSlot>
<BlockSlot @name="body">
<PolicyForm @form={{form}} @dc={{dc}} @allowServiceIdentity={{allowServiceIdentity}} />
<PolicyForm @form={{form}} @nspace={{nspace}} @dc={{dc}} @allowServiceIdentity={{allowServiceIdentity}} />
</BlockSlot>
<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'}}>
@ -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>
{{#if (eq item.template 'service-identity')}}
<CodeEditor @syntax="hcl" @readonly={{true}}>
{{~component 'service-identity' name=item.Name~}}
{{~component 'service-identity' nspace=nspace name=item.Name~}}
</CodeEditor>
{{else if (eq item.template 'node-identity')}}
<CodeEditor @syntax="hcl" @readonly={{true}}>

View File

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

View File

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