From b5ea989eee4071b325306dea820d9b63cb8df456 Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Thu, 2 Mar 2023 10:28:56 +0000 Subject: [PATCH] monitor: resolve oci layout path in client Signed-off-by: Justin Chadwell --- commands/build.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/commands/build.go b/commands/build.go index 616d810a..d3fd4990 100644 --- a/commands/build.go +++ b/commands/build.go @@ -676,19 +676,28 @@ func resolvePaths(options *controllerapi.BuildOptions) (_ *controllerapi.BuildOp } var contexts map[string]string for k, v := range options.NamedContexts { - p := v - if !urlutil.IsGitURL(p) && !urlutil.IsURL(p) && !strings.HasPrefix(p, "docker-image://") && !strings.HasPrefix(p, "oci-layout://") { - // named context can specify non-path value - // https://github.com/docker/buildx/blob/v0.10.3/docs/reference/buildx_build.md#-additional-build-contexts---build-context + if urlutil.IsGitURL(v) || urlutil.IsURL(v) || strings.HasPrefix(v, "docker-image://") { + // url prefix, this is a remote path + } else if strings.HasPrefix(v, "oci-layout://") { + // oci layout prefix, this is a local path + p := strings.TrimPrefix(v, "oci-layout://") p, err = filepath.Abs(p) if err != nil { return nil, err } + v = "oci-layout://" + p + } else { + // no prefix, assume local path + v, err = filepath.Abs(v) + if err != nil { + return nil, err + } } + if contexts == nil { contexts = make(map[string]string) } - contexts[k] = p + contexts[k] = v } options.NamedContexts = contexts