Skip to content

Commit

Permalink
Support md output format with all_subnets analysis type
Browse files Browse the repository at this point in the history
Signed-off-by: Ola Saadi <[email protected]>
  • Loading branch information
olasaadi99 committed Jan 9, 2024
1 parent 25e0bc3 commit 9953768
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cmd/analyzer/parse_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ func errorInErgs(args *InArgs, flagset *flag.FlagSet) error {

func notSupportedYetArgs(args *InArgs) error {
diffAnalysis := *args.AnalysisType == allEndpointsDiff || *args.AnalysisType == allSubnetsDiff
if !diffAnalysis && *args.AnalysisType != allEndpoints && *args.OutputFormat != TEXTFormat &&
*args.OutputFormat != JSONFormat {
if !diffAnalysis && *args.AnalysisType != allEndpoints && *args.AnalysisType != allSubnets &&
*args.OutputFormat != TEXTFormat && *args.OutputFormat != JSONFormat {
return fmt.Errorf("currently only txt/json output format supported with %s analysis type", *args.AnalysisType)
}
if diffAnalysis && *args.OutputFormat != TEXTFormat && *args.OutputFormat != MDFormat {
Expand Down
14 changes: 8 additions & 6 deletions pkg/vpcmodel/mdOutput.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ func (m *MDoutputFormatter) WriteOutput(c1, c2 *VPCConfig,
switch uc {
case AllEndpoints:
lines := []string{mdDefaultTitle, mdDefaultHeader}
connLines := m.getGroupedOutput(conn)
connLines := m.getGroupedOutput(conn.GroupedConnectivity)
out += linesToOutput(connLines, lines)
case AllSubnets:
lines := []string{mdDefaultTitle, mdDefaultHeader}
connLines := m.getGroupedOutput(subnetsConn.GroupedConnectivity)
out += linesToOutput(connLines, lines)
case SubnetsDiff, EndpointsDiff:
var mdTitle, mdHeader string
Expand All @@ -55,8 +59,6 @@ func (m *MDoutputFormatter) WriteOutput(c1, c2 *VPCConfig,
lines := []string{mdTitle, mdHeader}
connLines := m.getGroupedDiffOutput(cfgsDiff)
out += linesToOutput(connLines, lines)
case AllSubnets:
return nil, errors.New("SubnetLevel use case not supported for md format currently ")
case SingleSubnet:
return nil, errors.New("DebugSubnet use case not supported for md format currently ")
}
Expand All @@ -73,9 +75,9 @@ func linesToOutput(connLines, lines []string) string {
return out
}

func (m *MDoutputFormatter) getGroupedOutput(conn *VPCConnectivity) []string {
lines := make([]string, len(conn.GroupedConnectivity.GroupedLines))
for i, line := range conn.GroupedConnectivity.GroupedLines {
func (m *MDoutputFormatter) getGroupedOutput(connLines *GroupConnLines) []string {
lines := make([]string, len(connLines.GroupedLines))
for i, line := range connLines.GroupedLines {
lines[i] = getGroupedMDLine(line)
}
return lines
Expand Down

0 comments on commit 9953768

Please sign in to comment.