From 66f8691b399e32ce32f22fb5e9805deb13c83c83 Mon Sep 17 00:00:00 2001 From: Justin Kulikauskas <44813129+JustinKuli@users.noreply.github.com> Date: Sat, 4 May 2024 18:24:21 +0000 Subject: [PATCH] Improve some minor formatting Signed-off-by: Justin Kulikauskas <44813129+JustinKuli@users.noreply.github.com> --- api/v1beta1/target.go | 3 +- test/fakepolicy/test/yamlformat_test.go | 47 ++++++++++++++++++------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/api/v1beta1/target.go b/api/v1beta1/target.go index 84c5eb3..a88a27a 100644 --- a/api/v1beta1/target.go +++ b/api/v1beta1/target.go @@ -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 { diff --git a/test/fakepolicy/test/yamlformat_test.go b/test/fakepolicy/test/yamlformat_test.go index d5736c4..3a5b5c8 100644 --- a/test/fakepolicy/test/yamlformat_test.go +++ b/test/fakepolicy/test/yamlformat_test.go @@ -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"), ) })