Skip to content

Commit

Permalink
fix lint errors and comments
Browse files Browse the repository at this point in the history
Signed-off-by: Max Smythe <smythe@google.com>
  • Loading branch information
maxsmythe committed Jun 23, 2022
1 parent e97e8af commit dbf18ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,6 @@ github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
github.com/open-policy-agent/cert-controller v0.3.0 h1:9eUgN3yYMZsfyW7qdW8+CX9YZCUb5R5JfRTj0cqaSVg=
github.com/open-policy-agent/cert-controller v0.3.0/go.mod h1:uOQW+2tMU51vSxy1Yt162oVUTMdqLuotC0aObQxrh6k=
github.com/open-policy-agent/frameworks/constraint v0.0.0-20220527154834-b482a682709a h1:li3My6X1UgTahY+UZOi3HYQw01tZqjjn+Fh0RBzXu4k=
github.com/open-policy-agent/frameworks/constraint v0.0.0-20220527154834-b482a682709a/go.mod h1:8GTSaIKto8bel+l15v1Zwm9qXF3LCgdHatn7+rj5Jhw=
github.com/open-policy-agent/frameworks/constraint v0.0.0-20220603201627-e8d94b2fcf7a h1:YFthks7sIYmiOsElAwUZ48VdN9LI7ekF/vV4wYeR9mk=
github.com/open-policy-agent/frameworks/constraint v0.0.0-20220603201627-e8d94b2fcf7a/go.mod h1:8GTSaIKto8bel+l15v1Zwm9qXF3LCgdHatn7+rj5Jhw=
github.com/open-policy-agent/opa v0.40.0 h1:z/eg0ff3O1y6ovxpbL7xv+NHSwi8rVA7993sLv5Owac=
Expand Down
13 changes: 6 additions & 7 deletions pkg/gator/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ func (r *Runner) runTest(ctx context.Context, suiteDir string, filter Filter, t

err := r.tryAddConstraint(ctx, suiteDir, t)
var results []CaseResult
if err == nil && !t.Invalid {
if t.Invalid {
if errors.Is(err, constraints.ErrSchema) {
err = nil
}
err = fmt.Errorf("%w: got error %v but want %v", ErrValidConstraint, err, constraints.ErrSchema)
} else if err == nil {
results, err = r.runCases(ctx, suiteDir, filter, t)
}

Expand Down Expand Up @@ -124,12 +129,6 @@ func (r *Runner) tryAddConstraint(ctx context.Context, suiteDir string, t Test)
}

_, err = client.AddConstraint(ctx, cObj)
if t.Invalid {
if errors.Is(err, constraints.ErrSchema) {
return nil
}
return fmt.Errorf("%w: got error %v but want %v", ErrValidConstraint, err, constraints.ErrSchema)
}
return err
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/gator/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/open-policy-agent/frameworks/constraint/pkg/client"
constraintclient "github.com/open-policy-agent/frameworks/constraint/pkg/client"
"github.com/open-policy-agent/gatekeeper/pkg/gator/fixtures"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
Expand Down Expand Up @@ -644,7 +644,7 @@ func TestRunner_Run(t *testing.T) {
},
want: SuiteResult{
TestResults: []TestResult{{
Error: client.ErrMissingConstraintTemplate,
Error: constraintclient.ErrMissingConstraintTemplate,
}},
},
},
Expand Down

0 comments on commit dbf18ab

Please sign in to comment.