Skip to content

Commit

Permalink
Add headers to matrix-diff-ss file
Browse files Browse the repository at this point in the history
  • Loading branch information
sabinaaledort committed May 29, 2024
1 parent f7c7a13 commit b3c0099
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func main() {
}

func buildMatrixDiff(mat1 types.ComMatrix, mat2 types.ComMatrix) string {
diff := ""
diff := consts.CSVHeaders + "\n"
for _, cd := range mat1.Matrix {
if mat2.Contains(cd) {
diff += fmt.Sprintf("%s\n", cd)
Expand Down
1 change: 1 addition & 0 deletions consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ const (
RoleLabel = "node-role.kubernetes.io/"
DefaultDebugNamespace = "openshift-commatrix-debug"
DefaultDebugPodImage = "quay.io/openshift-release-dev/ocp-release:4.15.12-multi"
CSVHeaders = "Direction,Protocol,Port,Namespace,Service,Pod,Container,Node Role,Optional"
)
5 changes: 2 additions & 3 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"slices"
"strings"

"github.com/openshift-kni/commatrix/consts"
"sigs.k8s.io/yaml"
)

Expand All @@ -29,13 +30,11 @@ type ComDetails struct {
}

func ToCSV(m ComMatrix) ([]byte, error) {
var header = "Direction,Protocol,Port,Namespace,Service,Pod,Container,Node Role,Optional"

out := make([]byte, 0)
w := bytes.NewBuffer(out)
csvwriter := csv.NewWriter(w)

err := csvwriter.Write(strings.Split(header, ","))
err := csvwriter.Write(strings.Split(consts.CSVHeaders, ","))
if err != nil {
return nil, fmt.Errorf("failed to write to CSV: %w", err)
}
Expand Down

0 comments on commit b3c0099

Please sign in to comment.