-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apdoslogconf will warning case format is not splunk (#2991)
- Loading branch information
Showing
12 changed files
with
129 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ var appProtectDosPolicyRequiredFields = [][]string{ | |
} | ||
|
||
var appProtectDosLogConfRequiredFields = [][]string{ | ||
{"spec", "content"}, | ||
{"spec", "filter"}, | ||
} | ||
|
||
|
@@ -90,15 +89,28 @@ func validateResourceReference(ref string) error { | |
return nil | ||
} | ||
|
||
// checkAppProtectDosLogConfContentField check conetent field doesnt appear in dos log | ||
func checkAppProtectDosLogConfContentField(obj *unstructured.Unstructured) string { | ||
_, found, err := unstructured.NestedMap(obj.Object, "spec", "content") | ||
This comment has been minimized.
Sorry, something went wrong.
jjngx
Contributor
|
||
if err == nil && found { | ||
unstructured.RemoveNestedField(obj.Object, "spec", "content") | ||
msg := "the Content field is not supported, defaulting to splunk format." | ||
return msg | ||
} | ||
|
||
return "" | ||
} | ||
|
||
// ValidateAppProtectDosLogConf validates LogConfiguration resource | ||
func ValidateAppProtectDosLogConf(logConf *unstructured.Unstructured) error { | ||
func ValidateAppProtectDosLogConf(logConf *unstructured.Unstructured) (string, error) { | ||
lcName := logConf.GetName() | ||
err := validation2.ValidateRequiredFields(logConf, appProtectDosLogConfRequiredFields) | ||
if err != nil { | ||
return fmt.Errorf("error validating App Protect Dos Log Configuration %v: %w", lcName, err) | ||
return "", fmt.Errorf("error validating App Protect Dos Log Configuration %v: %w", lcName, err) | ||
} | ||
warning := checkAppProtectDosLogConfContentField(logConf) | ||
|
||
return nil | ||
return warning, nil | ||
} | ||
|
||
var ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
what happens when the
policy
is nil here?