mirror of https://github.com/hashicorp/consul
ui: Add ServerExternalAddresses field to token generation
parent
941f6da202
commit
ea23bac1fb
|
@ -36,5 +36,26 @@
|
|||
</fieldset>
|
||||
|
||||
{{/let}}
|
||||
|
||||
{{#let
|
||||
(hash
|
||||
help=(t 'common.validations.server-external-addresses.help')
|
||||
)
|
||||
as |ServerExternalAddresses|}}
|
||||
<fieldset>
|
||||
<TextInput
|
||||
@label="Server address(es)"
|
||||
@name="ServerExternalAddresses"
|
||||
@item={{@item}}
|
||||
@chart={{fsm}}
|
||||
@validations={{ServerExternalAddresses}}
|
||||
@oninput={{pick 'target.value' this.onInput}}
|
||||
/>
|
||||
{{yield (hash
|
||||
valid=(not (state-matches fsm.state 'error'))
|
||||
)}}
|
||||
</fieldset>
|
||||
|
||||
{{/let}}
|
||||
</StateMachine>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import Component from '@glimmer/component';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class PeerGenerateFieldSets extends Component {
|
||||
@action
|
||||
onInput(addresses) {
|
||||
if (addresses) {
|
||||
addresses = addresses.split(',').map(address => address.trim());
|
||||
} else {
|
||||
addresses = [];
|
||||
}
|
||||
|
||||
this.args.item.ServerExternalAddresses = addresses;
|
||||
}
|
||||
}
|
|
@ -44,12 +44,13 @@
|
|||
|
||||
<fsm.State @matches={{'loading'}}>
|
||||
<DataSource
|
||||
@src={{uri '/${partition}/${nspace}/${dc}/peering/token-for/${name}'
|
||||
@src={{uri '/${partition}/${nspace}/${dc}/peering/token-for/${name}/${externalAddresses}'
|
||||
(hash
|
||||
partition=@item.Partition
|
||||
nspace=''
|
||||
dc=@item.Datacenter
|
||||
name=@item.Name
|
||||
externalAddresses=@item.ServerExternalAddresses
|
||||
)
|
||||
}}
|
||||
@onchange={{queue
|
||||
|
|
|
@ -17,6 +17,8 @@ export default class Peer extends Model {
|
|||
@attr('string') Name;
|
||||
@attr('string') State;
|
||||
@attr('string') ID;
|
||||
@attr('string') ServerExternalAddresses;
|
||||
@nullValue([]) @attr() ServerExternalAddresses;
|
||||
|
||||
// only the side that establishes will hold this property
|
||||
@attr('string') PeerID;
|
||||
|
|
|
@ -44,8 +44,11 @@ export default class PeerService extends RepositoryService {
|
|||
});
|
||||
}
|
||||
|
||||
@dataSource('/:partition/:ns/:dc/peering/token-for/:name')
|
||||
async fetchToken({ dc, ns, partition, name }, configuration, request) {
|
||||
@dataSource('/:partition/:ns/:dc/peering/token-for/:name/:externalAddresses')
|
||||
async fetchToken({ dc, ns, partition, name, externalAddresses }, configuration, request) {
|
||||
const ServerExternalAddresses =
|
||||
externalAddresses?.length > 0 ? externalAddresses.split(',') : [];
|
||||
|
||||
return (
|
||||
await request`
|
||||
POST /v1/peering/token
|
||||
|
@ -53,6 +56,7 @@ export default class PeerService extends RepositoryService {
|
|||
${{
|
||||
PeerName: name,
|
||||
Partition: partition || undefined,
|
||||
ServerExternalAddresses,
|
||||
}}
|
||||
`
|
||||
)((headers, body, cache) => body);
|
||||
|
|
|
@ -81,4 +81,8 @@ validations:
|
|||
error: "{name} must be a valid DNS hostname."
|
||||
immutable:
|
||||
help: Once created, this cannot be changed.
|
||||
server-external-addresses:
|
||||
help: |
|
||||
Enter a fallback server address for this peer to be used in the event of failed automatic updates. This field is required for HCP-managed clusters.
|
||||
test: "^$|^[a-zA-Z0-9]([a-zA-Z0-9-]'{0,62}'[a-zA-Z0-9])?$"
|
||||
|
||||
|
|
Loading…
Reference in New Issue