diff --git a/pkg/vpcmodel/debugOutput.go b/pkg/vpcmodel/debugOutput.go index b5ec9f241..2290e0b98 100644 --- a/pkg/vpcmodel/debugOutput.go +++ b/pkg/vpcmodel/debugOutput.go @@ -12,7 +12,7 @@ func (t *DebugOutputFormatter) WriteOutput(c1, c2 *VPCConfig, grouping bool, uc OutputUseCase) (*SingleAnalysisOutput, error) { out, err := headerOfAnalyzedVPC(uc, c1.VPC.Name(), "", c1) - unStateFul := false + hasStatelessConns := false if err != nil { return nil, err } @@ -21,11 +21,11 @@ func (t *DebugOutputFormatter) WriteOutput(c1, c2 *VPCConfig, // TODO: add a flag of whether to include grouped output or not // TODO: add another 'debug' format that includes all detailed output out = conn.DetailedString() - unStateFul = conn.GroupedConnectivity.HasStatelessConns() + hasStatelessConns = conn.GroupedConnectivity.hasStatelessConns() case AllSubnets: case SingleSubnet: case SubnetsDiff, EndpointsDiff: } _, err = WriteToFile(out, outFile) - return &SingleAnalysisOutput{Output: out, VPC1Name: c1.VPC.Name(), VPC2Name: "", format: Debug, HaveUnStateFulConn: unStateFul}, err + return &SingleAnalysisOutput{Output: out, VPC1Name: c1.VPC.Name(), VPC2Name: "", format: Debug, hasStatelessConn: hasStatelessConns}, err } diff --git a/pkg/vpcmodel/grouping.go b/pkg/vpcmodel/grouping.go index 13c71f965..f26d146b4 100644 --- a/pkg/vpcmodel/grouping.go +++ b/pkg/vpcmodel/grouping.go @@ -494,13 +494,13 @@ func (g *GroupConnLines) String() string { return strings.Join(linesStr, "\n") + "\n" } -// get the grouped connectivity stateLessness -func (g *GroupConnLines) HasStatelessConns() bool { - unStateFul := false +// get indication if the connections contain a stateless connection +func (g *GroupConnLines) hasStatelessConns() bool { + hasStatelessConns := false for _, line := range g.GroupedLines { - unStateFul = unStateFul || line.commonProperties.conn.IsStateful == common.StatefulFalse + hasStatelessConns = hasStatelessConns || line.commonProperties.conn.IsStateful == common.StatefulFalse } - return unStateFul + return hasStatelessConns } func listEndpointElemStr(eps []EndpointElem, fn func(ep EndpointElem) string) string { diff --git a/pkg/vpcmodel/mdOutput.go b/pkg/vpcmodel/mdOutput.go index dc39b4355..708d16cba 100644 --- a/pkg/vpcmodel/mdOutput.go +++ b/pkg/vpcmodel/mdOutput.go @@ -38,13 +38,13 @@ func (m *MDoutputFormatter) WriteOutput(c1, c2 *VPCConfig, return nil, err } out = "# " + out - unStateFul := false + hasStatelessConns := false switch uc { case AllEndpoints: lines := []string{mdDefaultTitle, mdDefaultHeader} connLines := m.getGroupedOutput(conn) out += linesToOutput(connLines, lines) - unStateFul = m.HasStatelessConns(conn) + hasStatelessConns = m.hasStatelessConns(conn) case SubnetsDiff, EndpointsDiff: var mdTitle, mdHeader string if uc == EndpointsDiff { @@ -56,7 +56,7 @@ func (m *MDoutputFormatter) WriteOutput(c1, c2 *VPCConfig, } lines := []string{mdTitle, mdHeader} connLines := m.getGroupedDiffOutput(cfgsDiff) - unStateFul = m.DiffHasStatelessConns(cfgsDiff) + hasStatelessConns = m.diffHasStatelessConns(cfgsDiff) out += linesToOutput(connLines, lines) case AllSubnets: return nil, errors.New("SubnetLevel use case not supported for md format currently ") @@ -65,7 +65,7 @@ func (m *MDoutputFormatter) WriteOutput(c1, c2 *VPCConfig, } _, err = WriteToFile(out, outFile) - return &SingleAnalysisOutput{Output: out, VPC1Name: c1.VPC.Name(), VPC2Name: v2Name, format: MD, HaveUnStateFulConn: unStateFul}, err + return &SingleAnalysisOutput{Output: out, VPC1Name: c1.VPC.Name(), VPC2Name: v2Name, format: MD, hasStatelessConn: hasStatelessConns}, err } func linesToOutput(connLines, lines []string) string { @@ -85,8 +85,8 @@ func (m *MDoutputFormatter) getGroupedOutput(conn *VPCConnectivity) []string { } // get the grouped connectivity stateLessness -func (m *MDoutputFormatter) HasStatelessConns(conn *VPCConnectivity) bool { - return conn.GroupedConnectivity.HasStatelessConns() +func (m *MDoutputFormatter) hasStatelessConns(conn *VPCConnectivity) bool { + return conn.GroupedConnectivity.hasStatelessConns() } func (m *MDoutputFormatter) getGroupedDiffOutput(diff *diffBetweenCfgs) []string { @@ -102,8 +102,8 @@ func (m *MDoutputFormatter) getGroupedDiffOutput(diff *diffBetweenCfgs) []string } // get the diff grouped connectivity stateLessness -func (m *MDoutputFormatter) DiffHasStatelessConns(diff *diffBetweenCfgs) bool { - return diff.HasStatelessConns() +func (m *MDoutputFormatter) diffHasStatelessConns(diff *diffBetweenCfgs) bool { + return diff.hasStatelessConns() } // formats a connection line for md output diff --git a/pkg/vpcmodel/output.go b/pkg/vpcmodel/output.go index 39fce3576..e9b9a7543 100644 --- a/pkg/vpcmodel/output.go +++ b/pkg/vpcmodel/output.go @@ -95,12 +95,13 @@ func NewOutputGenerator(c1, c2 *VPCConfig, grouping bool, uc OutputUseCase, arch // SingleAnalysisOutput captures output per connectivity analysis of a single VPC, or per semantic diff between 2 VPCs // in the former case VPC2Name will be empty type SingleAnalysisOutput struct { - VPC1Name string - VPC2Name string - Output string - jsonStruct interface{} - format OutFormat - HaveUnStateFulConn bool + VPC1Name string + VPC2Name string + Output string + jsonStruct interface{} + format OutFormat + // hasStatelessConn indicates if the connectivity results contain a stateless conn + hasStatelessConn bool } // Generate returns SingleAnalysisOutput for its VPC analysis results @@ -151,7 +152,7 @@ func AggregateVPCsOutput(outputList []*SingleAnalysisOutput, f OutFormat, uc Out vpcsOut := make([]string, len(outputList)) for i, o := range outputList { vpcsOut[i] = o.Output - if uc != SingleSubnet && o.HaveUnStateFulConn { + if uc != SingleSubnet && o.hasStatelessConn { infoMessage = asteriskDetails } } @@ -176,7 +177,7 @@ func WriteDiffOutput(output *SingleAnalysisOutput, f OutFormat, outFile string) switch f { case Text, MD, Debug: // currently, return out as is infoMessage := "" - if output.HaveUnStateFulConn { + if output.hasStatelessConn { infoMessage = asteriskDetails } res, err = WriteToFile(output.Output+infoMessage, outFile) diff --git a/pkg/vpcmodel/semanticDiff.go b/pkg/vpcmodel/semanticDiff.go index aa6947e90..735fbbe9f 100644 --- a/pkg/vpcmodel/semanticDiff.go +++ b/pkg/vpcmodel/semanticDiff.go @@ -272,16 +272,16 @@ func (diffCfgs *diffBetweenCfgs) String() string { } // get the grouped diff connectivity stateLessness -func (diffCfgs *diffBetweenCfgs) HasStatelessConns() bool { - unStateFul := false +func (diffCfgs *diffBetweenCfgs) hasStatelessConns() bool { + hasStatelessConns := false for _, grouped := range diffCfgs.groupedLines { - unStateFul = unStateFul || + hasStatelessConns = hasStatelessConns || (grouped.commonProperties.connDiff.conn1 != nil && grouped.commonProperties.connDiff.conn1.IsStateful == common.StatefulFalse) || (grouped.commonProperties.connDiff.conn2 != nil && grouped.commonProperties.connDiff.conn2.IsStateful == common.StatefulFalse) } - return unStateFul + return hasStatelessConns } // prints connection for the above string(..) where the connection could be empty diff --git a/pkg/vpcmodel/subnetsConnectivity.go b/pkg/vpcmodel/subnetsConnectivity.go index 8975d4414..835fff77a 100644 --- a/pkg/vpcmodel/subnetsConnectivity.go +++ b/pkg/vpcmodel/subnetsConnectivity.go @@ -314,12 +314,12 @@ func (v *VPCsubnetConnectivity) String() string { } // get the grouped subnet connectivity stateLessness -func (v *VPCsubnetConnectivity) HasStatelessConns() bool { - unStateFul := false +func (v *VPCsubnetConnectivity) hasStatelessConns() bool { + hasStatelessConns := false for _, line := range v.GroupedConnectivity.GroupedLines { - unStateFul = unStateFul || line.commonProperties.conn.IsStateful == common.StatefulFalse + hasStatelessConns = hasStatelessConns || line.commonProperties.conn.IsStateful == common.StatefulFalse } - return unStateFul + return hasStatelessConns } // GetConnectivityOutputPerEachSubnetSeparately returns string results of connectivity analysis per diff --git a/pkg/vpcmodel/textOutput.go b/pkg/vpcmodel/textOutput.go index c03c1bc67..8b3cff1f4 100644 --- a/pkg/vpcmodel/textOutput.go +++ b/pkg/vpcmodel/textOutput.go @@ -41,23 +41,23 @@ func (t *TextOutputFormatter) WriteOutput(c1, c2 *VPCConfig, if err != nil { return nil, err } - unStateFul := false + hasStatelessConns := false // get output by analysis type switch uc { case AllEndpoints: out += conn.GroupedConnectivity.String() - unStateFul = conn.GroupedConnectivity.HasStatelessConns() + hasStatelessConns = conn.GroupedConnectivity.hasStatelessConns() case AllSubnets: out += subnetsConn.String() - unStateFul = subnetsConn.GroupedConnectivity.HasStatelessConns() + hasStatelessConns = subnetsConn.GroupedConnectivity.hasStatelessConns() case SingleSubnet: out += c1.GetConnectivityOutputPerEachSubnetSeparately() case SubnetsDiff, EndpointsDiff: out += cfgsDiff.String() - unStateFul = cfgsDiff.HasStatelessConns() + hasStatelessConns = cfgsDiff.hasStatelessConns() } // write output to file and return the output string _, err = WriteToFile(out, outFile) - return &SingleAnalysisOutput{Output: out, VPC1Name: c1.VPC.Name(), VPC2Name: vpc2Name, format: Text, HaveUnStateFulConn: unStateFul}, err + return &SingleAnalysisOutput{Output: out, VPC1Name: c1.VPC.Name(), VPC2Name: vpc2Name, format: Text, hasStatelessConn: hasStatelessConns}, err }