2023-03-14 14:18:55 +01:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2020-11-09 17:29:12 +00:00
|
|
|
import Model, { attr } from '@ember-data/model';
|
2021-04-12 09:19:49 -04:00
|
|
|
import { computed } from '@ember/object';
|
2020-10-05 13:07:35 -04:00
|
|
|
|
|
|
|
export const PRIMARY_KEY = 'uid';
|
|
|
|
export const SLUG_KEY = 'ServiceName';
|
2020-11-09 17:29:12 +00:00
|
|
|
|
|
|
|
export default class Topology extends Model {
|
|
|
|
@attr('string') uid;
|
|
|
|
@attr('string') ServiceName;
|
|
|
|
|
|
|
|
@attr('string') Datacenter;
|
|
|
|
@attr('string') Namespace;
|
2021-09-15 19:50:11 +01:00
|
|
|
@attr('string') Partition;
|
2020-11-09 17:29:12 +00:00
|
|
|
@attr('string') Protocol;
|
|
|
|
@attr('boolean') FilteredByACLs;
|
2021-04-08 14:08:57 -04:00
|
|
|
@attr('boolean') TransparentProxy;
|
2022-02-16 22:51:54 +01:00
|
|
|
@attr('boolean') ConnectNative;
|
2020-11-09 17:29:12 +00:00
|
|
|
@attr() Upstreams; // Service[]
|
|
|
|
@attr() Downstreams; // Service[],
|
|
|
|
@attr() meta; // {}
|
2021-04-12 09:19:49 -04:00
|
|
|
|
2021-05-25 11:02:38 -04:00
|
|
|
@computed('Downstreams')
|
|
|
|
get notDefinedIntention() {
|
2021-04-12 09:19:49 -04:00
|
|
|
let undefinedDownstream = false;
|
|
|
|
|
|
|
|
undefinedDownstream =
|
|
|
|
this.Downstreams.filter(
|
2022-09-15 10:43:17 +02:00
|
|
|
(item) =>
|
|
|
|
item.Source === 'specific-intention' &&
|
|
|
|
!item.TransparentProxy &&
|
|
|
|
!item.ConnectNative &&
|
|
|
|
item.Intention.Allowed
|
2021-04-12 09:19:49 -04:00
|
|
|
).length !== 0;
|
|
|
|
|
2021-05-25 11:02:38 -04:00
|
|
|
return undefinedDownstream;
|
|
|
|
}
|
|
|
|
|
2021-10-12 09:27:06 -04:00
|
|
|
@computed('Downstreams', 'Upstreams')
|
|
|
|
// A service has a wildcard intention if `Allowed == true` and `HasExact = false`
|
|
|
|
// The Permissive Intention notice appears if at least one upstream or downstream has
|
|
|
|
// a wildcard intention
|
|
|
|
get wildcardIntention() {
|
|
|
|
const downstreamWildcard =
|
2022-09-15 10:43:17 +02:00
|
|
|
this.Downstreams.filter((item) => !item.Intention.HasExact && item.Intention.Allowed)
|
|
|
|
.length !== 0;
|
2021-05-25 11:02:38 -04:00
|
|
|
|
2021-10-12 09:27:06 -04:00
|
|
|
const upstreamWildcard =
|
2022-09-15 10:43:17 +02:00
|
|
|
this.Upstreams.filter((item) => !item.Intention.HasExact && item.Intention.Allowed).length !==
|
2021-10-12 09:27:06 -04:00
|
|
|
0;
|
|
|
|
|
|
|
|
return downstreamWildcard || upstreamWildcard;
|
2021-04-12 09:19:49 -04:00
|
|
|
}
|
2021-11-05 13:46:41 -04:00
|
|
|
|
|
|
|
@computed('Downstreams', 'Upstreams')
|
|
|
|
get noDependencies() {
|
|
|
|
return this.Upstreams.length === 0 && this.Downstreams.length === 0;
|
|
|
|
}
|
2020-11-09 17:29:12 +00:00
|
|
|
}
|