-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make
IMAGE_TAG
available in buildArgs when used in docker `FRO…
…M` (#9664) * provide a docker.ImageReference in dependency resolution step * pass nils * other plumbing * fix: add back out io.Writer field * fix bugs * fix lookup and hash tests * fix tag test * fix skaffold/runner * fix skaffold/graph * remove the tags field where its not needed * make fixes to test * fix tests * fix another typo * add license boilerplate * add 2025 as a valid year * chore:add integration test * format go file * fix: lint and test * fix test * fix:lint * add debug output * add test action for debugging * add test * add test * add test * add test * add test * use the default context when building the image * fix imports * fix: flaky helm deploy unit test by making the order of helm command calls consistent * fix lint * add unit tests and fix existing tests * remove xtra file * fix lint * test that the build arg used as part of a filename is also replaced * use stub instead of mock for test objects * use empty string in place of tag because hash_test unit tests mock SingleArtifactDependencies so the value doesn't matter * add integration test to ensure that the build int BUILD args can be used as part of a file * fix imports, remove github action workflow used for debugging * fix lint * use one function everywhere in the codebase to generate the image info tags * Replace use of EvalBuildArgs with EvalBuildArgsWithEnv since they invoke the same function * add unit test for hash package * add test for TestCheckArtifacts --------- Co-authored-by: Abe Winter <[email protected]>
- Loading branch information
1 parent
4aeb393
commit 93e325b
Showing
40 changed files
with
659 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
integration/testdata/docker-run-with-build-args/artifact-with-dependency/base/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM golang:1.23 as builder | ||
WORKDIR /code | ||
COPY main.go . | ||
COPY go.mod . | ||
# `skaffold debug` sets SKAFFOLD_GO_GCFLAGS to disable compiler optimizations | ||
ARG SKAFFOLD_GO_GCFLAGS | ||
ARG IMAGE_REPO | ||
ARG IMAGE_NAME | ||
ARG IMAGE_TAG | ||
RUN go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -ldflags="-X main.ImageRepo=${IMAGE_REPO} -X main.ImageName=${IMAGE_NAME} -X main.ImageTag=${IMAGE_TAG}" -trimpath -o /app main.go | ||
|
3 changes: 3 additions & 0 deletions
3
integration/testdata/docker-run-with-build-args/artifact-with-dependency/base/go.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/GoogleContainerTools/skaffold/examples/docker-deploy-with-build-args/base | ||
|
||
go 1.23 |
14 changes: 14 additions & 0 deletions
14
integration/testdata/docker-run-with-build-args/artifact-with-dependency/base/main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
var ImageRepo = "unknown" | ||
var ImageTag = "unknown" | ||
var ImageName = "unknown" | ||
|
||
func main() { | ||
output := fmt.Sprintf("IMAGE_REPO: %s, IMAGE_NAME: %s, IMAGE_TAG:%s\n", ImageRepo, ImageName, ImageTag) | ||
fmt.Println(output) | ||
} |
5 changes: 5 additions & 0 deletions
5
integration/testdata/docker-run-with-build-args/artifact-with-dependency/child/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ARG BASE | ||
FROM $BASE as parent | ||
FROM alpine | ||
COPY --from=parent /app . | ||
CMD ["./app"] |
29 changes: 29 additions & 0 deletions
29
integration/testdata/docker-run-with-build-args/artifact-with-dependency/skaffold.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: skaffold/v4beta12 | ||
kind: Config | ||
build: | ||
tagPolicy: | ||
sha256: {} | ||
local: | ||
push: false | ||
useDockerCLI: true | ||
artifacts: | ||
- image: gcr.io/k8s-skaffold/skaffold | ||
context: base | ||
docker: | ||
dockerfile: Dockerfile | ||
noCache: true | ||
buildArgs: | ||
IMAGE_REPO: '{{.IMAGE_REPO}}' | ||
IMAGE_NAME: '{{.IMAGE_NAME}}' | ||
IMAGE_TAG: '{{.IMAGE_TAG}}' | ||
- image: child | ||
requires: | ||
- image: gcr.io/k8s-skaffold/skaffold | ||
alias: BASE | ||
context: child | ||
docker: | ||
dockerfile: Dockerfile | ||
noCache: true | ||
deploy: | ||
docker: | ||
images: [child] |
5 changes: 5 additions & 0 deletions
5
integration/testdata/docker-run-with-build-args/single-artifact/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM busybox | ||
ARG IMAGE_TAG | ||
RUN echo $IMAGE_TAG | ||
COPY "script-${IMAGE_TAG}.sh" script.sh | ||
CMD ["/bin/sh","script.sh"] |
1 change: 1 addition & 0 deletions
1
integration/testdata/docker-run-with-build-args/single-artifact/script-latest.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
echo "HELLO WORLD" |
18 changes: 18 additions & 0 deletions
18
integration/testdata/docker-run-with-build-args/single-artifact/skaffold.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: skaffold/v4beta12 | ||
kind: Config | ||
build: | ||
tagPolicy: | ||
sha256: {} | ||
local: | ||
push: false | ||
useDockerCLI: true | ||
artifacts: | ||
- image: example | ||
docker: | ||
dockerfile: Dockerfile | ||
noCache: true | ||
buildArgs: | ||
IMAGE_TAG: '{{.IMAGE_TAG}}' | ||
deploy: | ||
docker: | ||
images: [example] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.