mirror of
https://github.com/kemko/nomad.git
synced 2026-01-03 00:45:43 +03:00
This closes #10513, thanks to @bastelfreak for the report. GET /status/leader returns an IPv6 host with square brackets around the IP address as expected, but the rpcAddr property on the agent model does not. This fixes rpcAddr, updates the Mirage /status/leader mock to properly format an IPv6 host, and changes the agent factory to sometimes produce IPv6 addresses. I added a formatHost utility function to centralise the conditional square bracket-wrapping that would have otherwise been further scattered around.
32 lines
851 B
JavaScript
32 lines
851 B
JavaScript
import { inject as service } from '@ember/service';
|
|
import { computed } from '@ember/object';
|
|
import Model from '@ember-data/model';
|
|
import { attr } from '@ember-data/model';
|
|
import classic from 'ember-classic-decorator';
|
|
import formatHost from 'nomad-ui/utils/format-host';
|
|
|
|
@classic
|
|
export default class Agent extends Model {
|
|
@service system;
|
|
|
|
@attr('string') name;
|
|
@attr('string') address;
|
|
@attr('string') serfPort;
|
|
@attr('string') rpcPort;
|
|
@attr({ defaultValue: () => ({}) }) tags;
|
|
@attr('string') status;
|
|
@attr('string') datacenter;
|
|
@attr('string') region;
|
|
|
|
@computed('address', 'port')
|
|
get rpcAddr() {
|
|
const { address, rpcPort } = this;
|
|
return formatHost(address, rpcPort);
|
|
}
|
|
|
|
@computed('rpcAddr', 'system.leader.rpcAddr')
|
|
get isLeader() {
|
|
return this.get('system.leader.rpcAddr') === this.rpcAddr;
|
|
}
|
|
}
|