Skip to content

Commit

Permalink
Improve some minor formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Kulikauskas <[email protected]>
  • Loading branch information
JustinKuli committed May 4, 2024
1 parent deaa84d commit 66f8691
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
3 changes: 2 additions & 1 deletion api/v1beta1/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func (t Target) GetMatches(ctx context.Context, r client.Reader, list ResourceLi
// overriding the namespace specified in the Target).
//
// NOTE: unlike the NamespaceSelector, an empty Target will match *all* resources on the cluster.
func (t Target) GetMatchesDynamic(ctx context.Context, iface dynamic.ResourceInterface,
func (t Target) GetMatchesDynamic(
ctx context.Context, iface dynamic.ResourceInterface,
) ([]*unstructured.Unstructured, error) {
labelSel, err := metav1.LabelSelectorAsSelector(t.LabelSelector)
if err != nil {
Expand Down
47 changes: 35 additions & 12 deletions test/fakepolicy/test/yamlformat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,42 @@ var _ = Describe("FakePolicy resource format verification", func() {

Expect(string(wantSpec)).To(Equal(string(gotSpec)))
},
Entry("The sample YAML policy should be correct", sampleYAML.DeepCopy(), "fakepolicy-sample.yaml"),
// The golang instances defined above should match the specified files.
Entry("The sample YAML policy should be correct",
sampleYAML.DeepCopy(),
"fakepolicy-sample.yaml"),
Entry("The empty matchExpressions should be preserved",
emptyMatchExpressionsYAML.DeepCopy(), "empty-match-expressions.yaml"),
Entry("An extra field in the spec should be removed", extraFieldYAML.DeepCopy(), "fakepolicy-sample.yaml"),
Entry("The sample typed policy should be correct", sample.DeepCopy(), "fakepolicy-sample.yaml"),
Entry("An empty Includes list should be removed", emptyInclude.DeepCopy(), "no-include.yaml"),
Entry("An empty LabelSelector should have no effect", emptyLabelSelector.DeepCopy(), "fakepolicy-sample.yaml"),
Entry("A nil LabelSelector should have no effect", nilLabelSelector.DeepCopy(), "fakepolicy-sample.yaml"),
emptyMatchExpressionsYAML.DeepCopy(),
"empty-match-expressions.yaml"),
Entry("An extra field in the spec should be removed",
extraFieldYAML.DeepCopy(),
"fakepolicy-sample.yaml"),
Entry("The sample typed policy should be correct",
sample.DeepCopy(),
"fakepolicy-sample.yaml"),
Entry("An empty Includes list should be removed",
emptyInclude.DeepCopy(),
"no-include.yaml"),
Entry("An empty LabelSelector should have no effect",
emptyLabelSelector.DeepCopy(),
"fakepolicy-sample.yaml"),
Entry("A nil LabelSelector should have no effect",
nilLabelSelector.DeepCopy(),
"fakepolicy-sample.yaml"),
Entry("The emptyMatchExpressions in the typed object should match the YAML",
emptyMatchExpressions.DeepCopy(), "empty-match-expressions.yaml"),
Entry("An empty NamespaceSelector is not removed", emptyNSSelector.DeepCopy(), "empty-ns-selector.yaml"),
Entry("An empty Severity should be removed", emptySeverity.DeepCopy(), "no-severity.yaml"),
Entry("An empty RemediationAction should be removed", emptyRemAction.DeepCopy(), "no-remediation.yaml"),
Entry("A LabelSelector with Exists doesn't have values", reqSelector.DeepCopy(), "req-selector.yaml"),
emptyMatchExpressions.DeepCopy(),
"empty-match-expressions.yaml"),
Entry("An empty NamespaceSelector is not removed",
emptyNSSelector.DeepCopy(),
"empty-ns-selector.yaml"),
Entry("An empty Severity should be removed",
emptySeverity.DeepCopy(),
"no-severity.yaml"),
Entry("An empty RemediationAction should be removed",
emptyRemAction.DeepCopy(),
"no-remediation.yaml"),
Entry("A LabelSelector with Exists doesn't have values",
reqSelector.DeepCopy(),
"req-selector.yaml"),
)
})

0 comments on commit 66f8691

Please sign in to comment.