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 22, 2024
1 parent c984f54 commit 455e188
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 @@ -187,7 +187,7 @@ func main() {
}

func diff(mat types.ComMatrix, ssMat types.ComMatrix) string {
diff := ""
diff := consts.CSVHeaders + "\n"
for _, cd := range mat.Matrix {
if ssMat.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 @@ -8,6 +8,7 @@ import (
"fmt"
"strings"

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

Expand All @@ -28,13 +29,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 455e188

Please sign in to comment.