Skip to content

Commit 0c65c7f

Browse files
committed
step into
1 parent aeac5b8 commit 0c65c7f

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

config/sample-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ frontend:
991991
- K8S_ClusterName
992992
feature: multiCluster
993993
filter: cluster_name
994+
stepInto: zone
994995
- id: zone
995996
name: Zone
996997
shortName: AZ
@@ -1004,6 +1005,7 @@ frontend:
10041005
filters:
10051006
- src_zone
10061007
- dst_zone
1008+
stepInto: host
10071009
- id: host
10081010
name: Node
10091011
description: Node on which the resources are running
@@ -1017,6 +1019,7 @@ frontend:
10171019
filters:
10181020
- src_host_name
10191021
- dst_host_name
1022+
stepInto: resource
10201023
- id: namespace
10211024
name: Namespace
10221025
shortName: NS
@@ -1034,6 +1037,7 @@ frontend:
10341037
filters:
10351038
- src_namespace
10361039
- dst_namespace
1040+
stepInto: owner
10371041
- id: owner
10381042
name: Owner
10391043
shortName: Own
@@ -1059,6 +1063,7 @@ frontend:
10591063
filters:
10601064
- src_owner_name
10611065
- dst_owner_name
1066+
stepInto: resource
10621067
- id: resource
10631068
name: Resource
10641069
shortName: Res

pkg/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ type Scope struct {
102102
Groups []string `yaml:"groups,omitempty" json:"groups,omitempty"`
103103
Filter string `yaml:"filter,omitempty" json:"filter,omitempty"`
104104
Filters []string `yaml:"filters,omitempty" json:"filters,omitempty"`
105+
StepInto string `yaml:"stepInto,omitempty" json:"stepInto,omitempty"`
105106
}
106107

107108
type QuickFilter struct {

web/src/components/tabs/netflow-topology/2d/topology-content.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ import { Config } from '../../../../model/config';
2323
import { Filter, FilterDefinition, Filters } from '../../../../model/filters';
2424
import { FlowScope, MetricType, StatFunction } from '../../../../model/flow-query';
2525
import { getStat } from '../../../../model/metrics';
26-
import { ScopeConfigDef } from '../../../../model/scope';
26+
import { getStepInto, ScopeConfigDef } from '../../../../model/scope';
2727
import {
2828
Decorated,
2929
ElementData,
3030
FilterDir,
3131
generateDataModel,
32-
getStepIntoNext,
3332
GraphElementPeer,
3433
isDirElementFiltered,
3534
LayoutName,
@@ -207,7 +206,7 @@ export const TopologyContent: React.FC<TopologyContentProps> = ({
207206
const onStepInto = React.useCallback(
208207
(data: Decorated<ElementData>) => {
209208
const groupTypes: TopologyGroupTypes = metricScope;
210-
const scope = getStepIntoNext(metricScope, scopes);
209+
const scope = getStepInto(metricScope, scopes);
211210
if (data.nodeType && data.peer && scope) {
212211
setMetricScope(scope);
213212
setOptions({ ...options, groupTypes });

web/src/model/scope.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type ScopeConfigDef = {
1313
groups?: string[];
1414
filter?: string;
1515
filters?: string[];
16+
stepInto?: string;
1617
};
1718

1819
export const getScopeName = (sc: ScopeConfigDef | undefined, t: (k: string) => string) => {
@@ -75,3 +76,7 @@ export const getNonDirectionnalScopes = () => {
7576
export const getDirectionnalScopes = () => {
7677
return ContextSingleton.getScopes().filter(sc => isDirectionnal(sc));
7778
};
79+
80+
export const getStepInto = (scopeId: FlowScope, scopes: ScopeConfigDef[]): FlowScope | undefined => {
81+
return scopes.find(sc => sc.id === scopeId)?.stepInto;
82+
};

web/src/model/topology.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { createPeer, getFormattedValue } from '../utils/metrics';
2525
import { defaultMetricFunction, defaultMetricType } from '../utils/router';
2626
import { FlowScope, Groups, MetricFunction, MetricType, NodeType, StatFunction } from './flow-query';
2727
import { getStat } from './metrics';
28-
import { isDirectionnal, ScopeConfigDef } from './scope';
28+
import { getStepInto, isDirectionnal, ScopeConfigDef } from './scope';
2929

3030
export enum LayoutName {
3131
threeD = '3d',
@@ -41,15 +41,6 @@ export enum LayoutName {
4141

4242
export type TopologyGroupTypes = 'none' | Groups;
4343

44-
export const getStepIntoNext = (current: FlowScope, scopes: ScopeConfigDef[]): FlowScope | undefined => {
45-
let next: FlowScope | undefined = undefined;
46-
const index = scopes.findIndex(sc => sc.id === current);
47-
if (index >= 0 && index < scopes.length) {
48-
next = scopes[index].id;
49-
}
50-
return next;
51-
};
52-
5344
export interface TopologyOptions {
5445
maxEdgeStat: number;
5546
nodeBadges?: boolean;
@@ -114,6 +105,9 @@ const getDirFilterDefValue = (
114105
if (fields.resource && fields.namespace) {
115106
def = findFilter(filterDefinitions, `${dir}_resource`)!;
116107
value = `${fields.resource.type}.${fields.namespace}.${fields.resource.name}`;
108+
} else if (nodeType === 'owner' && fields.owner) {
109+
def = findFilter(filterDefinitions, `${dir}_owner_name`)!;
110+
value = `"${fields.owner.name}"`;
117111
} else {
118112
// try by scope definitions
119113
ContextSingleton.getScopes().forEach(sc => {
@@ -552,7 +546,7 @@ export const generateDataModel = (
552546
};
553547

554548
const peerToNodeData = (p: TopologyMetricPeer): NodeData => {
555-
const canStepInto = getStepIntoNext(metricScope, scopes) !== undefined;
549+
const canStepInto = getStepInto(metricScope, scopes) !== undefined;
556550
switch (metricScope) {
557551
case 'owner':
558552
return p.owner ? { peer: p, nodeType: 'owner', canStepInto } : { peer: p, nodeType: 'unknown' };

0 commit comments

Comments
 (0)