From f015c16f080133ee926402671536e14ff6e4028d Mon Sep 17 00:00:00 2001 From: Jim Bugwadia Date: Sat, 2 Oct 2021 14:24:23 -0700 Subject: [PATCH] fmt Signed-off-by: Jim Bugwadia --- pkg/engine/imageVerify.go | 12 +++++------- pkg/engine/variables/vars.go | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/engine/imageVerify.go b/pkg/engine/imageVerify.go index 57d1f7e766..4bcdb03e5d 100644 --- a/pkg/engine/imageVerify.go +++ b/pkg/engine/imageVerify.go @@ -174,7 +174,7 @@ func (iv *imageVerifier) attestImage(repository, key string, imageInfo *context. attestations, err := cosign.FetchAttestations(image, []byte(key), repository) if err != nil { iv.logger.Info("failed to fetch attestations", "image", image, "error", err, "duration", time.Since(start).Seconds()) - return ruleError(iv.rule, fmt.Sprintf("failed to fetch attestations for %s", image), err) + return ruleError(iv.rule, fmt.Sprintf("failed to fetch attestations for %s", image), err) } iv.logger.Info("received attestation", "attestations", attestations) @@ -182,22 +182,21 @@ func (iv *imageVerifier) attestImage(repository, key string, imageInfo *context. iv.policyContext.JSONContext.Checkpoint() defer iv.policyContext.JSONContext.Restore() if err := iv.policyContext.JSONContext.AddJSONObject(attestations); err != nil { - return ruleError(iv.rule, fmt.Sprintf("failed to add attestations to the context %v", attestations), err) + return ruleError(iv.rule, fmt.Sprintf("failed to add attestations to the context %v", attestations), err) } passed, err := iv.checkConditions(attestationChecks) if err != nil { - return ruleError(iv.rule, "failed to check attestation", err) + return ruleError(iv.rule, "failed to check attestation", err) } if !passed { - return ruleResponse(iv.rule, "attestation checks failed", response.RuleStatusFail) + return ruleResponse(iv.rule, "attestation checks failed", response.RuleStatusFail) } - return ruleResponse(iv.rule, "attestation checks passed", response.RuleStatusPass) + return ruleResponse(iv.rule, "attestation checks passed", response.RuleStatusPass) } - func (iv *imageVerifier) checkConditions(attestationChecks []*v1.AnyAllConditions) (bool, error) { conditions, err := variables.SubstituteAllInConditions(iv.logger, iv.policyContext.JSONContext, attestationChecks) if err != nil { @@ -207,4 +206,3 @@ func (iv *imageVerifier) checkConditions(attestationChecks []*v1.AnyAllCondition pass := variables.EvaluateConditions(iv.logger, iv.policyContext.JSONContext, conditions) return pass, nil } - diff --git a/pkg/engine/variables/vars.go b/pkg/engine/variables/vars.go index 9f0c02a870..9af6c0b6d5 100644 --- a/pkg/engine/variables/vars.go +++ b/pkg/engine/variables/vars.go @@ -126,7 +126,7 @@ func SubstituteAllInConditions(log logr.Logger, ctx context.EvalInterface, condi return JSONObjectToConditions(i) } -func ConditionsToJSONObject(conditions []*kyverno.AnyAllConditions) ([]map[string]interface{}, error){ +func ConditionsToJSONObject(conditions []*kyverno.AnyAllConditions) ([]map[string]interface{}, error) { bytes, err := json.Marshal(conditions) if err != nil { return nil, err