Skip to content

Commit

Permalink
Change default validate image output to text
Browse files Browse the repository at this point in the history
The previous default was json.

There was one change in the unit tests required to make the tests
pass. I'm not 100% sure why that was needed (or rather why it wasn't
needed before), but my understanding is that the fs and the ctx was
being reused between two test cases and it was causing problems
somehow.

I did look at the task definition also, but the output is specified
explicitly, so should be no change needed.

Ref: https://issues.redhat.com/browse/EC-758
  • Loading branch information
simonbaird committed Aug 28, 2024
1 parent f436ee7 commit acad497
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 53 deletions.
22 changes: 12 additions & 10 deletions cmd/validate/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ type data struct {
var rootArgs = []string{
"validate",
"image",
"--output",
"json",
}

func happyValidator() imageValidationFunc {
Expand Down Expand Up @@ -472,16 +474,6 @@ func Test_ValidateImageCommandKeyless(t *testing.T) {
}

func Test_ValidateImageCommandYAMLPolicyFile(t *testing.T) {
validateImageCmd := validateImageCmd(happyValidator())
cmd := setUpCobra(validateImageCmd)

client := fake.FakeClient{}
commonMockClient(&client)
fs := afero.NewMemMapFs()
ctx := utils.WithFS(context.Background(), fs)
ctx = oci.WithClient(ctx, &client)
cmd.SetContext(ctx)

cases := []struct {
name string
config string
Expand Down Expand Up @@ -527,6 +519,16 @@ spec:

for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
validateImageCmd := validateImageCmd(happyValidator())
cmd := setUpCobra(validateImageCmd)

client := fake.FakeClient{}
commonMockClient(&client)
fs := afero.NewMemMapFs()
ctx := utils.WithFS(context.Background(), fs)
ctx = oci.WithClient(ctx, &client)
cmd.SetContext(ctx)

err := afero.WriteFile(fs, "/policy.yaml", []byte(c.config), 0644)
if err != nil {
panic(err)
Expand Down
Loading

0 comments on commit acad497

Please sign in to comment.