diff --git a/cmd/build/build_test.go b/cmd/build/build_test.go index 6e02b41b..0b492d25 100644 --- a/cmd/build/build_test.go +++ b/cmd/build/build_test.go @@ -102,11 +102,11 @@ COPY --from=build /test/testfile testfile "debug: Authenticating against registry No docker registry\n", "debug: Authentication not supported for registry No docker registry\n", fmt.Sprintf("debug: Using build variables commit %s on branch master\n", hash), - fmt.Sprintf("debug: performing docker build with options (auths removed):\ntags:\n - noregistry/%[1]s:build\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: %[2]s\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - noregistry/%[1]s:build\nsecurityopt: []\nextrahosts: []\ntarget: build\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", base, hash), + fmt.Sprintf("debug: performing docker build with options (auths removed):\ntags:\n - noregistry/%[1]s:build\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: %[2]s\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - noregistry/001:build\n - noregistry/001:master\n - noregistry/001:latest\nsecurityopt: []\nextrahosts: []\ntarget: build\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", base, hash), "info: Successfully tagged noregistry/001:build\n", - fmt.Sprintf("debug: performing docker build with options (auths removed):\ntags:\n - noregistry/%[1]s:export\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: %[2]s\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - noregistry/%[1]s:export\n - noregistry/%[1]s:build\nsecurityopt: []\nextrahosts: []\ntarget: export\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs:\n - type: local\n attrs: {}\n\n", base, hash), + fmt.Sprintf("debug: performing docker build with options (auths removed):\ntags:\n - noregistry/%[1]s:export\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: %[2]s\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - noregistry/001:export\n - noregistry/001:build\n - noregistry/001:master\n - noregistry/001:latest\nsecurityopt: []\nextrahosts: []\ntarget: export\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs:\n - type: local\n attrs: {}\n\n", base, hash), "info: ", - fmt.Sprintf("debug: performing docker build with options (auths removed):\ntags:\n - noregistry/%[1]s:%[2]s\n - noregistry/%[1]s:master\n - noregistry/%[1]s:latest\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: %[2]s\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - noregistry/%[1]s:master\n - noregistry/%[1]s:latest\n - noregistry/001:export\n - noregistry/001:build\nsecurityopt: []\nextrahosts: []\ntarget: \"\"\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", base, hash), + fmt.Sprintf("debug: performing docker build with options (auths removed):\ntags:\n - noregistry/%[1]s:%[2]s\n - noregistry/%[1]s:master\n - noregistry/%[1]s:latest\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: %[2]s\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - noregistry/001:export\n - noregistry/001:build\n - noregistry/001:master\n - noregistry/001:latest\nsecurityopt: []\nextrahosts: []\ntarget: \"\"\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", base, hash), fmt.Sprintf("info: Successfully tagged noregistry/%[1]s:%[2]s\nSuccessfully tagged noregistry/%[1]s:master\nSuccessfully tagged noregistry/%[1]s:latest\n", base, hash), }) } diff --git a/pkg/build/build.go b/pkg/build/build.go index d451fc6e..5b2a3aaa 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -121,7 +121,18 @@ func build(client docker.Client, dir string, buildVars Args) error { commit := currentCI.Commit() branch := currentCI.BranchReplaceSlash() log.Debugf("Using build variables commit %s on branch %s\n", commit, branch) - var caches []string + var tags []string + branchTag := docker.Tag(currentRegistry.RegistryUrl(), currentCI.BuildName(), branch) + latestTag := docker.Tag(currentRegistry.RegistryUrl(), currentCI.BuildName(), "latest") + tags = append(tags, []string{ + docker.Tag(currentRegistry.RegistryUrl(), currentCI.BuildName(), commit), + branchTag, + }...) + if currentCI.Branch() == "master" || currentCI.Branch() == "main" { + tags = append(tags, latestTag) + } + + caches := []string{branchTag, latestTag} buildArgs := map[string]*string{ "BUILDKIT_INLINE_CACHE": aws.String("1"), @@ -152,18 +163,6 @@ func build(client docker.Client, dir string, buildVars Args) error { } } - var tags []string - branchTag := docker.Tag(currentRegistry.RegistryUrl(), currentCI.BuildName(), branch) - latestTag := docker.Tag(currentRegistry.RegistryUrl(), currentCI.BuildName(), "latest") - tags = append(tags, []string{ - docker.Tag(currentRegistry.RegistryUrl(), currentCI.BuildName(), commit), - branchTag, - }...) - if currentCI.Branch() == "master" || currentCI.Branch() == "main" { - tags = append(tags, latestTag) - } - - caches = append([]string{branchTag, latestTag}, caches...) return buildStage(client, dir, buildVars, buildArgs, tags, caches, "", authenticator) } diff --git a/pkg/build/build_test.go b/pkg/build/build_test.go index bb30d01f..1cd1cd2b 100644 --- a/pkg/build/build_test.go +++ b/pkg/build/build_test.go @@ -702,19 +702,19 @@ COPY --from=test file2 . assert.Equal(t, []string{"repo/reponame:build"}, client.BuildOptions[0].Tags) assert.Equal(t, []string{"repo/reponame:test"}, client.BuildOptions[1].Tags) assert.Equal(t, []string{"repo/reponame:abc123", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[2].Tags) - assert.Equal(t, []string{"repo/reponame:build"}, client.BuildOptions[0].CacheFrom) - assert.Equal(t, []string{"repo/reponame:test", "repo/reponame:build"}, client.BuildOptions[1].CacheFrom) - assert.Equal(t, []string{"repo/reponame:master", "repo/reponame:latest", "repo/reponame:test", "repo/reponame:build"}, client.BuildOptions[2].CacheFrom) + assert.Equal(t, []string{"repo/reponame:build", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[0].CacheFrom) + assert.Equal(t, []string{"repo/reponame:test", "repo/reponame:build", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[1].CacheFrom) + assert.Equal(t, []string{"repo/reponame:test", "repo/reponame:build", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[2].CacheFrom) logMock.Check(t, []string{"debug: Using CI Gitlab\n", "debug: Using registry Dockerhub\n", "debug: Authenticating against registry Dockerhub\n", "debug: Logged in\n", "debug: Using build variables commit abc123 on branch master\n", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:build\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: build\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:build\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: build\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", "info: Build successful", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:test\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:test\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: test\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:test\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:test\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: test\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", "info: Build successful", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:abc123\n - repo/reponame:master\n - repo/reponame:latest\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:master\n - repo/reponame:latest\n - repo/reponame:test\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: \"\"\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:abc123\n - repo/reponame:master\n - repo/reponame:latest\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:test\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: \"\"\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", "info: Build successful"}) } @@ -756,9 +756,9 @@ COPY --from=test file2 . "debug: Authenticating against registry Dockerhub\n", "debug: Logged in\n", "debug: Using build variables commit abc123 on branch master\n", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:build\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: build\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:build\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: build\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", "info: Build successful", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:test\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:test\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: test\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:test\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:test\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: test\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", }) } @@ -812,22 +812,22 @@ COPY --from=test file2 . }, }, client.BuildOptions[2].Outputs) assert.Equal(t, []string{"repo/reponame:abc123", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[3].Tags) - assert.Equal(t, []string{"repo/reponame:build"}, client.BuildOptions[0].CacheFrom) - assert.Equal(t, []string{"repo/reponame:test", "repo/reponame:build"}, client.BuildOptions[1].CacheFrom) - assert.Equal(t, []string{"repo/reponame:export", "repo/reponame:test", "repo/reponame:build"}, client.BuildOptions[2].CacheFrom) - assert.Equal(t, []string{"repo/reponame:master", "repo/reponame:latest", "repo/reponame:export", "repo/reponame:test", "repo/reponame:build"}, client.BuildOptions[3].CacheFrom) + assert.Equal(t, []string{"repo/reponame:build", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[0].CacheFrom) + assert.Equal(t, []string{"repo/reponame:test", "repo/reponame:build", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[1].CacheFrom) + assert.Equal(t, []string{"repo/reponame:export", "repo/reponame:test", "repo/reponame:build", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[2].CacheFrom) + assert.Equal(t, []string{"repo/reponame:export", "repo/reponame:test", "repo/reponame:build", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[3].CacheFrom) logMock.Check(t, []string{"debug: Using CI Gitlab\n", "debug: Using registry Dockerhub\n", "debug: Authenticating against registry Dockerhub\n", "debug: Logged in\n", "debug: Using build variables commit abc123 on branch master\n", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:build\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: build\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:build\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: build\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", "info: Build successful", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:test\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:test\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: test\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:test\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:test\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: test\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", "info: Build successful", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:export\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:export\n - repo/reponame:test\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: export\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs:\n - type: local\n attrs: {}\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:export\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:export\n - repo/reponame:test\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: export\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs:\n - type: local\n attrs: {}\n\n", "info: Build successful", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:abc123\n - repo/reponame:master\n - repo/reponame:latest\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:master\n - repo/reponame:latest\n - repo/reponame:export\n - repo/reponame:test\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: \"\"\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:abc123\n - repo/reponame:master\n - repo/reponame:latest\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:export\n - repo/reponame:test\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: \"\"\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", "info: Build successful"}) } @@ -878,22 +878,22 @@ COPY --from=test file2 . }, }, client.BuildOptions[2].Outputs) assert.Equal(t, []string{"repo/reponame:abc123", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[3].Tags) - assert.Equal(t, []string{"repo/reponame:build"}, client.BuildOptions[0].CacheFrom) - assert.Equal(t, []string{"repo/reponame:test", "repo/reponame:build"}, client.BuildOptions[1].CacheFrom) - assert.Equal(t, []string{"repo/reponame:export", "repo/reponame:test", "repo/reponame:build"}, client.BuildOptions[2].CacheFrom) - assert.Equal(t, []string{"repo/reponame:master", "repo/reponame:latest", "repo/reponame:export", "repo/reponame:test", "repo/reponame:build"}, client.BuildOptions[3].CacheFrom) + assert.Equal(t, []string{"repo/reponame:build", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[0].CacheFrom) + assert.Equal(t, []string{"repo/reponame:test", "repo/reponame:build", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[1].CacheFrom) + assert.Equal(t, []string{"repo/reponame:export", "repo/reponame:test", "repo/reponame:build", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[2].CacheFrom) + assert.Equal(t, []string{"repo/reponame:export", "repo/reponame:test", "repo/reponame:build", "repo/reponame:master", "repo/reponame:latest"}, client.BuildOptions[3].CacheFrom) logMock.Check(t, []string{"debug: Using CI Gitlab\n", "debug: Using registry Dockerhub\n", "debug: Authenticating against registry Dockerhub\n", "debug: Logged in\n", "debug: Using build variables commit abc123 on branch master\n", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:build\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: build\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:build\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: build\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", "info: Build successful", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:test\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:test\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: test\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:test\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:test\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: test\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", "info: Build successful", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:export\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:export\n - repo/reponame:test\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: export\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs:\n - type: local\n attrs: {}\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:export\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:export\n - repo/reponame:test\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: export\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs:\n - type: local\n attrs: {}\n\n", "info: Build successful", - "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:abc123\n - repo/reponame:master\n - repo/reponame:latest\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:master\n - repo/reponame:latest\n - repo/reponame:export\n - repo/reponame:test\n - repo/reponame:build\nsecurityopt: []\nextrahosts: []\ntarget: \"\"\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", + "debug: performing docker build with options (auths removed):\ntags:\n - repo/reponame:abc123\n - repo/reponame:master\n - repo/reponame:latest\nsuppressoutput: false\nremotecontext: client-session\nnocache: false\nremove: true\nforceremove: false\npullparent: true\nisolation: \"\"\ncpusetcpus: \"\"\ncpusetmems: \"\"\ncpushares: 0\ncpuquota: 0\ncpuperiod: 0\nmemory: 0\nmemoryswap: -1\ncgroupparent: \"\"\nnetworkmode: \"\"\nshmsize: 268435456\ndockerfile: Dockerfile\nulimits: []\nbuildargs:\n BUILDKIT_INLINE_CACHE: \"1\"\n CI_BRANCH: master\n CI_COMMIT: abc123\nauthconfigs: {}\ncontext: null\nlabels: {}\nsquash: false\ncachefrom:\n - repo/reponame:export\n - repo/reponame:test\n - repo/reponame:build\n - repo/reponame:master\n - repo/reponame:latest\nsecurityopt: []\nextrahosts: []\ntarget: \"\"\nsessionid: \"\"\nplatform: \"\"\nversion: \"2\"\nbuildid: \"\"\noutputs: []\n\n", "info: Build successful"}) }