Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support md output format with all_subnets analysis type #314

Merged
merged 6 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 &&
adisos marked this conversation as resolved.
Show resolved Hide resolved
*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)
adisos marked this conversation as resolved.
Show resolved Hide resolved
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
Loading