buildflags: fix missing cache type error typo
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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\"}"`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user