Skip to content

Commit

Permalink
add option to specify other log dstns
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafal Wegrzycki committed Sep 18, 2020
1 parent 6581c74 commit a6e267e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/k8s/app_protect_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
errormsg := "Error parsing App Protect Log config: Destination Annotation must follow format: syslog:server=<ip-address | localhost>:<port>"
errormsg := "Error parsing App Protect Log config: Destination Annotation must follow format: syslog:server=<ip-address | localhost>:<port> or stderr or absolute path to file"
if !logDstEx.MatchString(dstAntn) {
return fmt.Errorf("%s Log Destination did not follow format", errormsg)
}
if dstAntn == "stderr" {
return nil
}

if logDstFileEx.MatchString(dstAntn) {
return nil
}

dstchunks := strings.Split(dstAntn, ":")

Expand Down

0 comments on commit a6e267e

Please sign in to comment.