Skip to content

feat: Return violating resource in pkg/gator/test.Test#2198

Merged
maxsmythe merged 1 commit into
open-policy-agent:masterfrom
julianKatz:include-violating-resource-in-gator-test-output
Sep 28, 2022
Merged

feat: Return violating resource in pkg/gator/test.Test#2198
maxsmythe merged 1 commit into
open-policy-agent:masterfrom
julianKatz:include-violating-resource-in-gator-test-output

Conversation

@julianKatz
Copy link
Copy Markdown
Contributor

During the refactoring of the Constraint Framework, the violating
resource was removed from the pkg/types.Result struct.

As this struct was returned in the public interface of Gatekeeper's
pkg/gator/test.Test() function, consumers of that test package were
deprived of their ability to discern which resource was causing the
violation returned to them.

This PR declares a new set of types in the test package that are meant
to mirror those of CF's types package, but that include a reference to
the violating object.

This PR also updates the gator test CLI command to use this new
interface.

Signed-off-by: juliankatz juliankatz@google.com

@julianKatz julianKatz requested review from a team and maxsmythe July 29, 2022 01:22
@julianKatz julianKatz force-pushed the include-violating-resource-in-gator-test-output branch 3 times, most recently from 6812d5f to a3f86b3 Compare August 2, 2022 00:24
Copy link
Copy Markdown
Member

@ritazh ritazh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ritazh
Copy link
Copy Markdown
Member

ritazh commented Aug 12, 2022

@maxsmythe LGTY?

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Merging #2198 (e9dfc4a) into master (b6c369b) will increase coverage by 0.19%.
The diff coverage is 91.42%.

@@            Coverage Diff             @@
##           master    #2198      +/-   ##
==========================================
+ Coverage   54.36%   54.55%   +0.19%     
==========================================
  Files         111      112       +1     
  Lines        9538     9568      +30     
==========================================
+ Hits         5185     5220      +35     
+ Misses       3954     3950       -4     
+ Partials      399      398       -1     
Flag Coverage Δ
unittests 54.55% <91.42%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/gator/test/types.go 88.46% <88.46%> (ø)
pkg/gator/test/test.go 63.15% <100.00%> (+2.04%) ⬆️
pkg/readiness/object_tracker.go 83.98% <0.00%> (+1.06%) ⬆️
...onstrainttemplate/constrainttemplate_controller.go 57.79% <0.00%> (+1.19%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@maxsmythe
Copy link
Copy Markdown
Contributor

It does, I was hoping to merge Davis's PR first to avoid the need to resolve a merge conflict on that PR

@julianKatz julianKatz force-pushed the include-violating-resource-in-gator-test-output branch from e9dfc4a to cb64804 Compare August 13, 2022 00:51
@maxsmythe
Copy link
Copy Markdown
Contributor

@julianKatz ready to merge after merge conflicts are resolved.

During the refactoring of the Constraint Framework, the violating
resource was removed from the pkg/types.Result struct.

As this struct was returned in the public interface of Gatekeeper's
pkg/gator/test.Test() function, consumers of that test package were
deprived of their ability to discern which resource was causing the
violation returned to them.

This PR declares a new set of types in the `test` package that are meant
to mirror those of CF's `types` package, but that include a reference to
the violating object.

This PR also updates the gator test CLI command to use this new
interface.

Signed-off-by: juliankatz <juliankatz@google.com>
@julianKatz julianKatz force-pushed the include-violating-resource-in-gator-test-output branch from cb64804 to ced94bd Compare September 27, 2022 17:55
Copy link
Copy Markdown
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maxsmythe maxsmythe merged commit ef443f0 into open-policy-agent:master Sep 28, 2022
@julianKatz julianKatz deleted the include-violating-resource-in-gator-test-output branch September 28, 2022 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants