Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions util/buildflags/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (e *CacheOptionsEntry) UnmarshalText(text []byte) error {
}

if e.Type == "" {
return errors.Errorf("type required form> %q", in)
return errors.Errorf("type required for %q", in)
}
return e.validate(text)
}
Expand All @@ -132,7 +132,7 @@ func (e *CacheOptionsEntry) validate(gv any) error {
default:
text, _ = json.Marshal(gv)
}
return errors.Errorf("type required form> %q", string(text))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you sure it wasn't meant to be <form>? 🤣

return errors.Errorf("type required for %q", string(text))
}
return nil
}
Expand Down
13 changes: 13 additions & 0 deletions util/buildflags/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,16 @@ func TestCacheOptions_RefOnlyFormat(t *testing.T) {
{Type: "registry", Attrs: map[string]string{"ref": "ref2"}},
}, opts)
}

func TestCacheOptions_MissingTypeError(t *testing.T) {
t.Run("ParseCacheEntry", func(t *testing.T) {
_, err := ParseCacheEntry([]string{"test=test"})
require.EqualError(t, err, `type required for "test=test"`)
})

t.Run("UnmarshalJSON", func(t *testing.T) {
var actual CacheOptionsEntry
err := json.Unmarshal([]byte(`{"ref":"user/app:cache"}`), &actual)
require.EqualError(t, err, `type required for "{\"ref\":\"user/app:cache\"}"`)
})
}
Loading