Skip to content

Commit

Permalink
include Log attribute in StandardValueSource
Browse files Browse the repository at this point in the history
  • Loading branch information
lhitchon committed Mar 13, 2018
1 parent 01b3276 commit 7df92bc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion cli/kubernetes.go
Expand Up @@ -62,7 +62,6 @@ func (l KubernetesLinter) ValidateKubernetesResources(report *filter.ValidationR
if filter.ExcludeResource(rule, resource) {
l.Log(fmt.Sprintf("Ignoring resource %s", resource.Id))
} else {
l.Log(fmt.Sprintf("Checking resource %s", resource.Id))
_, violations := filter.ApplyRule(rule, resource, l.Log)
for _, violation := range violations {
report.Violations[violation.Status] = append(report.Violations[violation.Status], violation)
Expand Down
1 change: 0 additions & 1 deletion cli/terraform.go
Expand Up @@ -90,7 +90,6 @@ func (l TerraformLinter) ValidateTerraformResources(report *filter.ValidationRep
if filter.ExcludeResource(rule, resource) {
l.Log(fmt.Sprintf("Ignoring resource %s", resource.Id))
} else {
l.Log(fmt.Sprintf("Checking resource %s", resource.Id))
_, violations := filter.ApplyRule(rule, resource, l.Log)
for _, violation := range violations {
report.Violations[violation.Status] = append(report.Violations[violation.Status], violation)
Expand Down
5 changes: 3 additions & 2 deletions filter/filter.go
Expand Up @@ -9,8 +9,9 @@ func searchAndMatch(filter Filter, resource Resource, valueSource ValueSource, l
if err != nil {
panic(err)
}
match := isMatch(unquoted(v), filter.Op, valueSource.GetValue(filter))
log(fmt.Sprintf("Key: %s Output: %s Looking for %s %s", filter.Key, v, filter.Op, filter.Value))
value := valueSource.GetValue(filter)
match := isMatch(unquoted(v), filter.Op, value)
log(fmt.Sprintf("Key: %s Output: %s Looking for %s %s", filter.Key, v, filter.Op, value))
log(fmt.Sprintf("ResourceId: %s Type: %s %t",
resource.Id,
resource.Type,
Expand Down
2 changes: 1 addition & 1 deletion filter/rules.go
Expand Up @@ -54,7 +54,7 @@ func ApplyRule(rule Rule, resource Resource, log LoggingFunction) (string, []Vio
if ExcludeResource(rule, resource) {
return returnStatus, violations
}
valueSource := StandardValueSource{}
valueSource := StandardValueSource{Log: log}
for _, ruleFilter := range rule.Filters {
log(fmt.Sprintf("Checking resource %s", resource.Id))
status := ApplyFilter(rule, ruleFilter, resource, valueSource, log)
Expand Down
3 changes: 3 additions & 0 deletions filter/value.go
Expand Up @@ -2,16 +2,19 @@ package filter

import (
"bytes"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
)

type StandardValueSource struct {
Log LoggingFunction
}

func (v StandardValueSource) GetValue(filter Filter) string {
if filter.ValueFrom.Bucket != "" {
v.Log(fmt.Sprintf("Getting value_from s3://%s/%s", filter.ValueFrom.Bucket, filter.ValueFrom.Key))
content, err := v.GetValueFromS3(filter.ValueFrom.Bucket, filter.ValueFrom.Key)
if err != nil {
return "Error" // FIXME
Expand Down

0 comments on commit 7df92bc

Please sign in to comment.