mirror of https://github.com/status-im/consul.git
Merge pull request #15159 from hashicorp/ui/fix-peered-service-not-unique-based-on-peer
ui: Fix PeerName is part of service uniqueness
This commit is contained in:
commit
67905f8348
|
@ -5,7 +5,7 @@ import { fragment } from 'ember-data-model-fragments/attributes';
|
||||||
import replace, { nullValue } from 'consul-ui/decorators/replace';
|
import replace, { nullValue } from 'consul-ui/decorators/replace';
|
||||||
|
|
||||||
export const PRIMARY_KEY = 'uid';
|
export const PRIMARY_KEY = 'uid';
|
||||||
export const SLUG_KEY = 'Name';
|
export const SLUG_KEY = 'Name,PeerName';
|
||||||
|
|
||||||
export const Collection = class Collection {
|
export const Collection = class Collection {
|
||||||
@tracked items;
|
@tracked items;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { get } from '@ember/object';
|
import { get } from '@ember/object';
|
||||||
|
import { isEmpty } from '@ember/utils';
|
||||||
|
|
||||||
export default function (foreignKey, nspaceKey, partitionKey, hash = JSON.stringify) {
|
export default function (foreignKey, nspaceKey, partitionKey, hash = JSON.stringify) {
|
||||||
return function (primaryKey, slugKey, foreignKeyValue, nspaceValue, partitionValue) {
|
return function (primaryKey, slugKey, foreignKeyValue, nspaceValue, partitionValue) {
|
||||||
|
@ -10,15 +11,24 @@ export default function (foreignKey, nspaceKey, partitionKey, hash = JSON.string
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const slugKeys = slugKey.split(',');
|
const slugKeys = slugKey.split(',');
|
||||||
const slugValues = slugKeys.map(function (slugKey) {
|
const slugValues = slugKeys
|
||||||
const slug = get(item, slugKey);
|
.map(function (slugKey) {
|
||||||
if (slug == null || slug.length < 1) {
|
const slug = get(item, slugKey);
|
||||||
throw new Error(
|
|
||||||
`Unable to create fingerprint, missing slug. Looking for value in \`${slugKey}\` got \`${slug}\``
|
const isSlugEmpty = isEmpty(slug);
|
||||||
);
|
|
||||||
}
|
if (isSlugEmpty) {
|
||||||
return slug;
|
// PeerName should be optional as part of id
|
||||||
});
|
if (slugKey === 'PeerName') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new Error(
|
||||||
|
`Unable to create fingerprint, missing slug. Looking for value in \`${slugKey}\` got \`${slug}\``
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return slug;
|
||||||
|
})
|
||||||
|
.compact();
|
||||||
// This ensures that all data objects have a Namespace and a Partition
|
// This ensures that all data objects have a Namespace and a Partition
|
||||||
// value set, even in OSS.
|
// value set, even in OSS.
|
||||||
if (typeof item[nspaceKey] === 'undefined') {
|
if (typeof item[nspaceKey] === 'undefined') {
|
||||||
|
|
Loading…
Reference in New Issue