From c0a986b43b5457b565438c1211125ae8c36b76ae Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 25 May 2024 16:32:37 +0200 Subject: [PATCH 1/2] build: loadInputs: remove redundant check for hasTag hasTag was always true as it was set to "true" when missing, in which case the default (`:latest`) tag was applied; localPath, tag, hasTag := strings.Cut(localPath, ":") if !hasTag { tag = "latest" hasTag = true } Signed-off-by: Sebastiaan van Stijn --- build/opt.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build/opt.go b/build/opt.go index 5d05e25a76f..99da75f5696 100644 --- a/build/opt.go +++ b/build/opt.go @@ -500,7 +500,6 @@ func loadInputs(ctx context.Context, d *driver.DriverHandle, inp Inputs, addVCSL localPath, tag, hasTag := strings.Cut(localPath, ":") if !hasTag { tag = "latest" - hasTag = true } idx := ociindex.NewStoreIndex(localPath) if !hasDigest { @@ -543,10 +542,7 @@ func loadInputs(ctx context.Context, d *driver.DriverHandle, inp Inputs, addVCSL } target.OCIStores[storeName] = store - layout := "oci-layout://" + storeName - if hasTag { - layout += ":" + tag - } + layout := "oci-layout://" + storeName + ":" + tag if hasDigest { layout += "@" + dig } From 17c0a3794b24280404952901b381afc7f687b180 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 25 May 2024 16:36:52 +0200 Subject: [PATCH 2/2] build: loadInputs: remove redundant check for hasDigest hasDigest would always be true when reaching this code, because the function would return with an error when failing to resolve the digest; if !hasDigest { return nil, errors.Errorf("oci-layout reference %q could not be resolved", v.Path) } Signed-off-by: Sebastiaan van Stijn --- build/opt.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/build/opt.go b/build/opt.go index 99da75f5696..85e48ea8559 100644 --- a/build/opt.go +++ b/build/opt.go @@ -542,12 +542,7 @@ func loadInputs(ctx context.Context, d *driver.DriverHandle, inp Inputs, addVCSL } target.OCIStores[storeName] = store - layout := "oci-layout://" + storeName + ":" + tag - if hasDigest { - layout += "@" + dig - } - - target.FrontendAttrs["context:"+k] = layout + target.FrontendAttrs["context:"+k] = "oci-layout://" + storeName + ":" + tag + "@" + dig continue } st, err := os.Stat(v.Path)