buildflags: skip empty cache entries when parsing

Broken in 11c84973ef. The section to skip
an empty input was accidentally removed when some code was refactored to
fix a separate issue.

This skips empty cache entries which allows disabling the `cache-from` and
`cache-to` entries from the command line overrides.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
Jonathan A. Sternberg
2025-02-24 10:09:02 -06:00
parent 62f5cc7c80
commit e75ac22ba6
2 changed files with 47 additions and 0 deletions

View File

@ -175,6 +175,10 @@ func ParseCacheEntry(in []string) (CacheOptions, error) {
opts := make(CacheOptions, 0, len(in))
for _, in := range in {
if in == "" {
continue
}
if !strings.Contains(in, "=") {
// This is ref only format. Each field in the CSV is its own entry.
fields, err := csvvalue.Fields(in, nil)