-
Notifications
You must be signed in to change notification settings - Fork 7
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
Allow setting custom-entries-file in formats #7
Allow setting custom-entries-file in formats #7
Conversation
4e87c4a
to
5cabd78
Compare
@@ -34,7 +37,7 @@ const ( | |||
// Custom entries from a JSON file can be added to the matrix by setting `customEntriesPath`. | |||
// Returns a pointer to ComMatrix and error. Entries include traffic direction, protocol, | |||
// port number, namespace, service name, pod, container, node role, and flow optionality for OpenShift. | |||
func New(kubeconfigPath string, customEntriesPath string, e Env, d Deployment) (*types.ComMatrix, error) { | |||
func New(kubeconfigPath string, customEntriesPath string, customEntriesFormat string, e Env, d Deployment) (*types.ComMatrix, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
customEntriesFormat should be an enum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, the flag still accepts string, but internally it's validated as an enum
commatrix/commatrix.go
Outdated
@@ -61,7 +64,10 @@ func New(kubeconfigPath string, customEntriesPath string, e Env, d Deployment) ( | |||
res = append(res, staticEntries...) | |||
|
|||
if customEntriesPath != "" { | |||
customComDetails, err := addFromFile(customEntriesPath) | |||
if customEntriesFormat == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be validated in main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -51,7 +51,7 @@ func ToCSV(m ComMatrix) ([]byte, error) { | |||
} | |||
|
|||
func ToJSON(m ComMatrix) ([]byte, error) { | |||
out, err := json.Marshal(m.Matrix) | |||
out, err := json.MarshalIndent(m.Matrix, "", " ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the output more readable with tabs and newlines instead of one long string
5cabd78
to
cf44110
Compare
cf44110
to
763423e
Compare
763423e
to
ec1657b
Compare
This commit adds the the flag customEntriesFormat that sets the custom entries file format (json/yaml/csv). We also include 3 example files to help the user to create his own custom file, and they'll be used in the integration test. Signed-off-by: Lior Noy <[email protected]>
ec1657b
to
fa17b99
Compare
This commit adds the the flag customEntriesFormat that sets the custom entries file format (json/yaml/csv).
We also include 3 example files to help the user to create his own custom file, and they'll be used in the integration test.