-
Notifications
You must be signed in to change notification settings - Fork 2k
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
add option to specify other log destinations in AP #1147
Conversation
@@ -55,14 +55,22 @@ func ValidateAppProtectLogConf(logConf *unstructured.Unstructured) error { | |||
return nil | |||
} | |||
|
|||
var logDstEx = regexp.MustCompile(`syslog:server=((?:\d{1,3}\.){3}\d{1,3}|localhost):\d{1,5}`) | |||
var logDstEx = regexp.MustCompile(`(?:syslog:server=((?:\d{1,3}\.){3}\d{1,3}|localhost):\d{1,5})|stderr|(?:\/[\S]+)+`) | |||
var logDstFileEx = regexp.MustCompile(`(?:\/[\S]+)+`) | |||
|
|||
// ValidateAppProtectLogDestinationAnnotation validates annotation for log destination configuration | |||
func ValidateAppProtectLogDestinationAnnotation(dstAntn string) 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.
Could you possibly add a unit test for this function? It be great to test for each of the possible types of valid values as well as invalid values (a case per eachreturn fmt.Errorf
)
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.
added tests, also removed one return fmt.Errorf since i found it is not reachable.
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.
the test looks good.
One comment though - for maintainability, we usually don't put the test input into global variables - we put them into the test function. could you make posDstAntns
and negDstAntns
local variables of ValidateAppProtectLogDestinationAnnotation
?
Proposed changes
This change allows for configuring additional values as log destinations, when setting remote logging via apLogConf
Checklist
Before creating a PR, run through this checklist and mark each as complete.