From a6e267e78340841d008ff773dfa5c162e0374125 Mon Sep 17 00:00:00 2001 From: Rafal Wegrzycki Date: Tue, 8 Sep 2020 12:13:10 +0200 Subject: [PATCH] add option to specify other log dstns --- internal/k8s/app_protect_resources.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/k8s/app_protect_resources.go b/internal/k8s/app_protect_resources.go index 685f54421f..b3f942de53 100644 --- a/internal/k8s/app_protect_resources.go +++ b/internal/k8s/app_protect_resources.go @@ -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=:" + errormsg := "Error parsing App Protect Log config: Destination Annotation must follow format: syslog:server=: 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, ":")