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

add option to specify other log destinations in AP #1147

Merged
merged 3 commits into from
Sep 21, 2020
Merged

Conversation

rafwegv
Copy link
Contributor

@rafwegv rafwegv commented Sep 16, 2020

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.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto master
  • I will ensure my PR is targeting the master branch and pulling from my branch from my own fork

@rafwegv rafwegv added the enhancement Pull requests for new features/feature enhancements label Sep 16, 2020
@rafwegv rafwegv self-assigned this Sep 16, 2020
@@ -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 {
Copy link
Contributor

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)

Copy link
Contributor Author

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.

Copy link
Contributor

@pleshakov pleshakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafwegv

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 ?

@rafwegv rafwegv merged commit 8ffdeb3 into master Sep 21, 2020
@rafwegv rafwegv deleted the ap-logdst branch September 21, 2020 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Pull requests for new features/feature enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants