Skip to content

Commit

Permalink
fix: don't ignore annotations when metadata.name doesn't exist (datre…
Browse files Browse the repository at this point in the history
…eio#733)

Co-authored-by: teselil <tzlil@datree.com>
  • Loading branch information
TzlilSwimmer123 and teselil committed Jul 20, 2022
1 parent 4d52318 commit 291fe1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 0 additions & 4 deletions pkg/evaluation/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,6 @@ func addFailedRule(currentFailedRulesByFiles FailedRulesByFiles, fileName string
func extractSkipAnnotations(configuration extractor.Configuration) map[string]string {
skipAnnotations := make(map[string]string)

if configuration.MetadataName == "" || configuration.Kind == "" {
return nil
}

for annotationKey, annotationValue := range configuration.Annotations {
if strings.Contains(annotationKey, SKIP_RULE_PREFIX) {
skipAnnotations[annotationKey] = annotationValue.(string)
Expand Down
7 changes: 4 additions & 3 deletions pkg/extractor/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ func extractConfigurationK8sData(content []byte) Configuration {
if metadata := jsonObject["metadata"]; metadata != nil {
if metadataName := metadata.(map[string]interface{})["name"]; metadataName != nil {
configuration.MetadataName = metadataName.(string)
if annotations := metadata.(map[string]interface{})["annotations"]; annotations != nil {
configuration.Annotations = annotations.(map[string]interface{})
}
}

if annotations := metadata.(map[string]interface{})["annotations"]; annotations != nil {
configuration.Annotations = annotations.(map[string]interface{})
}
}

Expand Down

0 comments on commit 291fe1d

Please sign in to comment.