@@ -48,8 +48,8 @@ const noValidInputMsg = "is not a legal IP address, CIDR, or endpoint name"
48
48
49
49
const deliminator = "/"
50
50
51
- // was src/dst input provided as internal address of a vsi ? this is required info since
52
- // if this is the case then in the output the relevant detected VSIs ' names are printed
51
+ // was src/dst input provided as internal address of an endpoint ? this is required info since
52
+ // if this is the case then in the output the relevant detected endpoints ' names are printed
53
53
type srcDstInternalAddr struct {
54
54
src bool
55
55
dst bool
@@ -63,8 +63,8 @@ type srcAndDstNodes struct {
63
63
64
64
// getVPCConfigAndSrcDstNodes given src, dst in string returns the config in which the exaplainability analysis of these
65
65
// should be done and the Nodes for src and dst. It also returns whether src and/or dst was given as the internal address of
66
- // a vsi - which effects the output.
67
- // src/dst when referring to a vsi *name* may be prefixed with the vpc name with the deliminator "/" to solve ambiguity
66
+ // an endpoint - which effects the output.
67
+ // src/dst when referring to an endpoint *name* may be prefixed with the vpc name with the deliminator "/" to solve ambiguity
68
68
// If such prefix is missing then a match in any vpc is valid.
69
69
// At most one config should contain both src and dst, and this is the config returned:
70
70
// * If one is internal and the other is external the vpcConfig of the internal is returned
@@ -74,7 +74,7 @@ type srcAndDstNodes struct {
74
74
// this is the vpcConfig that will be returned, if such tgw exists; if such a tgw does not exist the src and dst are not connected
75
75
// At this stage, we do not support the following:
76
76
// 1. two tgw connects src and dst;
77
- // 2. src and/or dst has VSI (s) in more than one VPC
77
+ // 2. src and/or dst has endpoint (s) in more than one VPC
78
78
79
79
// error handling: the src and dst are being searched for within the context of each vpcConfig.
80
80
// if no match found, then it is due to one of the following errors:
@@ -93,12 +93,12 @@ type srcAndDstNodes struct {
93
93
//
94
94
// More than one match found is also considered an error. It can be due to one of the following:
95
95
// 1. src and dst are of different VPCs and are connected by more than one tgw
96
- // 2. src and dst are internal address containing VSIs in more than one VPC
97
- // 3. src (dst) is internal containing VSIs in more than one VPC and dst (src) is external
96
+ // 2. src and dst are internal address containing endpoints in more than one VPC
97
+ // 3. src (dst) is internal containing endpoints in more than one VPC and dst (src) is external
98
98
// neither are supported in this stage
99
99
// todo: note that there could be cases in which src/dst are internal address that contains EPs of more than one VPC
100
- // which will not result in an error. E.g., src is a vsi of VPC1 and dst is an internal address of VPC1 and VPC2.
101
- // in this case explainability analysis will be done for VPC1
100
+ // which will not result in an error. E.g., src is a endpoint of VPC1 and dst is an internal address of VPC1
101
+ // and VPC2. in this case explainability analysis will be done for VPC1
102
102
103
103
//nolint:gocyclo // better not split into two function
104
104
func (c * MultipleVPCConfigs ) getVPCConfigAndSrcDstNodes (src , dst string ) (vpcConfig * VPCConfig ,
@@ -216,7 +216,7 @@ func (c *MultipleVPCConfigs) listNamesCfg(configsWithSrcDstNode map[string]srcAn
216
216
i := 0
217
217
matchConfigs := make ([]string , len (configsWithSrcDstNode ))
218
218
for vpcUID := range configsWithSrcDstNode {
219
- // the vsis are in more than one config; lists all the configs it is in for the error msg
219
+ // the endpoints are in more than one config; lists all the configs it is in for the error msg
220
220
matchConfigs [i ] = c .Config (vpcUID ).VPC .Name ()
221
221
i ++
222
222
}
@@ -262,8 +262,8 @@ func (e *ExplanationArgs) GetConnectionSet() *connection.Set {
262
262
263
263
// given src and dst input and a VPCConfigs finds the []nodes they represent in the config
264
264
// src/dst may refer to:
265
- // 1. VSI by UID or name; in this case we consider the network interfaces of the VSI
266
- // 2. Internal IP address or cidr; in this case we consider the VSIs in that address range
265
+ // 1. Endpoint by UID or name; in this case we consider the network interfaces of the endpoint
266
+ // 2. Internal IP address or cidr; in this case we consider the endpoints in that address range
267
267
// 3. external IP address or cidr
268
268
func (c * VPCConfig ) srcDstInputToNodes (srcName , dstName string ) (srcNodes ,
269
269
dstNodes []Node , isSrcDstInternalIP srcDstInternalAddr , errType int , err error ) {
@@ -293,7 +293,7 @@ func (c *VPCConfig) srcDstInputToNodes(srcName, dstName string) (srcNodes,
293
293
return srcNodes , dstNodes , srcDstInternalAddr {isSrcInternalIP , isDstInternalIP }, noErr , nil
294
294
}
295
295
296
- // given a VPCConfig and a string looks for the VSI /Internal IP/External address it presents,
296
+ // given a VPCConfig and a string looks for the endpoint /Internal IP/External address it presents,
297
297
// as described above
298
298
func (c * VPCConfig ) getSrcOrDstInputNode (name , srcOrDst string ) (nodes []Node ,
299
299
internalIP bool , errType int , err error ) {
@@ -304,18 +304,18 @@ func (c *VPCConfig) getSrcOrDstInputNode(name, srcOrDst string) (nodes []Node,
304
304
return outNodes , isInternalIP , noErr , nil
305
305
}
306
306
307
- // given a VPCConfig and a string cidrOrName representing a vsi or internal/external
307
+ // given a VPCConfig and a string cidrOrName representing an endpoint or internal/external
308
308
// cidr/address returns the corresponding node(s) and a bool which is true iff
309
309
// cidrOrName is an internal address and the nodes are its network interfaces
310
310
func (c * VPCConfig ) getNodesFromInputString (cidrOrName string ) (nodes []Node ,
311
311
internalIP bool , errType int , err error ) {
312
- // 1. cidrOrName references vsi
313
- vsi , errType1 , err1 := c .getNodesOfVsi (cidrOrName )
312
+ // 1. cidrOrName references endpoint
313
+ endpoint , errType1 , err1 := c .getNodesOfEndpoint (cidrOrName )
314
314
if err1 != nil {
315
315
return nil , false , errType1 , err1
316
316
}
317
- if vsi != nil {
318
- return vsi , false , noErr , nil
317
+ if endpoint != nil {
318
+ return endpoint , false , noErr , nil
319
319
}
320
320
// cidrOrName, if legal, references an address.
321
321
// 2. cidrOrName references an ip address
@@ -330,42 +330,36 @@ func (c *VPCConfig) getNodesFromInputString(cidrOrName string) (nodes []Node,
330
330
return c .getNodesFromAddress (cidrOrName , ipBlock )
331
331
}
332
332
333
- // todo https://github.com/np-guard/vpc-network-config-analyzer/issues/673:
334
- // the name, the variables names and the documentation of the following function is wrong and misleading, because:
335
- // 1. vsi is ibm specific
336
- // 2. this functions returns not only nodes of vsis, but also nodes of vpe, and recently load balancers
337
-
338
- // getNodesOfVsi gets a string name or UID of VSI, and
339
- // returns the list of all nodes within this vsi
340
- func (c * VPCConfig ) getNodesOfVsi (name string ) ([]Node , int , error ) {
341
- var nodeSetWithVsi NodeSet
342
- // vsi name may be prefixed by vpc name
343
- var vpc , vsi string
333
+ // getNodesOfEndpoint gets a string name or UID of an endpoint (e.g. VSI), and
334
+ // returns the list of all nodes within this endpoint
335
+ func (c * VPCConfig ) getNodesOfEndpoint (name string ) ([]Node , int , error ) {
336
+ var nodeSetOfEndpoint NodeSet
337
+ // endpoint name may be prefixed by vpc name
338
+ var vpc , endpoint string
344
339
uid := name // uid specified - vpc prefix is not relevant and uid may contain the deliminator "/"
345
340
cidrOrNameSlice := strings .Split (name , deliminator )
346
341
switch len (cidrOrNameSlice ) {
347
342
case 1 : // vpc name not specified
348
- vsi = name
343
+ endpoint = name
349
344
case 2 : // vpc name specified
350
345
vpc = cidrOrNameSlice [0 ]
351
- vsi = cidrOrNameSlice [1 ]
346
+ endpoint = cidrOrNameSlice [1 ]
352
347
}
353
348
for _ , nodeSet := range append (c .NodeSets , c .loadBalancersAsNodeSets ()... ) {
354
- // currently, assuming c.NodeSets consists of VSIs or VPE
355
- if (vpc == "" || nodeSet .VPC ().Name () == vpc ) && nodeSet .Name () == vsi || // if vpc of vsi specified, equality must hold
349
+ if (vpc == "" || nodeSet .VPC ().Name () == vpc ) && nodeSet .Name () == endpoint || // if vpc of endpoint specified, equality must hold
356
350
nodeSet .UID () == uid {
357
- if nodeSetWithVsi != nil {
351
+ if nodeSetOfEndpoint != nil {
358
352
return nil , fatalErr , fmt .Errorf ("ambiguity - the configuration contains multiple resources named %s, " +
359
353
"try using CRNs or the VPC name to scope resources: vpc-name/instance-name" +
360
- "\n CRNs of matching resources:\n \t %s\n \t %s" , name , nodeSetWithVsi .UID (), nodeSet .UID ())
354
+ "\n CRNs of matching resources:\n \t %s\n \t %s" , name , nodeSetOfEndpoint .UID (), nodeSet .UID ())
361
355
}
362
- nodeSetWithVsi = nodeSet
356
+ nodeSetOfEndpoint = nodeSet
363
357
}
364
358
}
365
- if nodeSetWithVsi == nil {
359
+ if nodeSetOfEndpoint == nil {
366
360
return nil , noErr , nil
367
361
}
368
- return nodeSetWithVsi .Nodes (), noErr , nil
362
+ return nodeSetOfEndpoint .Nodes (), noErr , nil
369
363
}
370
364
371
365
// getNodesFromAddress gets a string and IPBlock that represents a cidr or IP address
0 commit comments