Merge pull request #3969 from crazy-max/fix-cache-type-error-message

buildflags: fix missing cache type error typo
This commit is contained in:
Sebastiaan van Stijn
2026-07-24 00:31:50 +02:00
committed by GitHub
2 changed files with 15 additions and 2 deletions
+2 -2
View File
@@ -114,7 +114,7 @@ func (e *CacheOptionsEntry) UnmarshalText(text []byte) error {
} }
if e.Type == "" { if e.Type == "" {
return errors.Errorf("type required form> %q", in) return errors.Errorf("type required for %q", in)
} }
return e.validate(text) return e.validate(text)
} }
@@ -132,7 +132,7 @@ func (e *CacheOptionsEntry) validate(gv any) error {
default: default:
text, _ = json.Marshal(gv) text, _ = json.Marshal(gv)
} }
return errors.Errorf("type required form> %q", string(text)) return errors.Errorf("type required for %q", string(text))
} }
return nil return nil
} }
+13
View File
@@ -86,3 +86,16 @@ func TestCacheOptions_RefOnlyFormat(t *testing.T) {
{Type: "registry", Attrs: map[string]string{"ref": "ref2"}}, {Type: "registry", Attrs: map[string]string{"ref": "ref2"}},
}, opts) }, 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\"}"`)
})
}