Skip to content

Commit 7dd4f17

Browse files
authored
Merge pull request kubernetes#104296 from claudiubelu/test-images/automate-agnhost-binary-version
test images: Simplifies the agnhost binary version
2 parents 07fe9f0 + 94ac896 commit 7dd4f17

File tree

7 files changed

+8
-29
lines changed

7 files changed

+8
-29
lines changed

build/dependencies.yaml

-16
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,6 @@ dependencies:
1616
- path: hack/tools/go.mod
1717
match: sigs.k8s.io/zeitgeist\ v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?
1818

19-
# agnhost: bump this one first
20-
- name: "agnhost"
21-
version: "2.32"
22-
refPaths:
23-
- path: test/images/agnhost/VERSION
24-
match: \d.\d
25-
- path: test/images/agnhost/agnhost.go
26-
match: "Version:"
27-
28-
# then after merge and successful postsubmit image push / promotion, bump this
29-
- name: "agnhost: dependents"
30-
version: "2.32"
31-
refPaths:
32-
- path: test/utils/image/manifest.go
33-
match: configs\[Agnhost\] = Config{list\.PromoterE2eRegistry, "agnhost", "\d+\.\d+"}
34-
3519
# CNI plugins
3620
- name: "cni"
3721
version: 0.9.1

test/images/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ These images are then used by the rest of the E2E test images as a cache / base
104104
Make updates to the functionality of the images required for your test case and update the version number.
105105

106106
The version can easily be bumped by modifying the file `test/images/${IMAGE_NAME}/VERSION`, which will
107-
be used when building the image. Additionally, for the `agnhost` image, also bump the `Version` in
108-
`test/images/agnhost/agnhost.go`.
107+
be used when building the image.
109108

110109
Some test images (`agnhost`) are used as bases for other images (`kitten`, `nautilus`). If the parent
111110
image's `VERSION` has been bumped, also bump the version in the children's `BASEIMAGE` files in order

test/images/agnhost/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ TARGET ?= $(CURDIR)
1919
GOARM ?= 7
2020
GOLANG_VERSION ?= latest
2121
SRC_DIR = $(notdir $(shell pwd))
22+
VERSION = $(shell cat VERSION)
23+
LD_FLAGS = -X 'main.Version=$(VERSION)'
2224
export
2325

2426
bin:

test/images/agnhost/README.md

-8
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ The image was created for testing purposes, reducing the need for having differe
1616
cases for the same tested behaviour.
1717

1818

19-
## Developer notes
20-
21-
We've introduced versioning into the `agnhost` binary for debugging purposes (e.g.: if the
22-
image and binary versions do not match, see [here](https://github.com/kubernetes/kubernetes/pull/79667#discussion_r304198370)).
23-
24-
Whenever the image `VERSION` is bumped, the `Version` in `agnhost.go` will also have to be bumped.
25-
26-
2719
## Usage
2820

2921
The `agnhost` binary has several subcommands which are can be used to test different

test/images/agnhost/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.32
1+
2.33

test/images/agnhost/agnhost.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ import (
4848
"k8s.io/kubernetes/test/images/agnhost/webhook"
4949
)
5050

51+
var Version = "development"
52+
5153
func main() {
5254
rootCmd := &cobra.Command{
5355
Use: "app",
54-
Version: "2.32",
56+
Version: Version,
5557
}
5658

5759
rootCmd.AddCommand(auditproxy.CmdAuditProxy)

test/images/image-util.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ bin() {
278278
golang:"${GOLANG_VERSION}" \
279279
/bin/bash -c "\
280280
cd /go/src/k8s.io/kubernetes/test/images/${SRC_DIR} && \
281-
CGO_ENABLED=0 ${arch_prefix} GOOS=${OS} GOARCH=${ARCH} go build -a -installsuffix cgo --ldflags '-w' -o ${TARGET}/${SRC} ./$(dirname "${SRC}")"
281+
CGO_ENABLED=0 ${arch_prefix} GOOS=${OS} GOARCH=${ARCH} go build -a -installsuffix cgo --ldflags \"-w ${LD_FLAGS}\" -o ${TARGET}/${SRC} ./$(dirname "${SRC}")"
282282
done
283283
}
284284

0 commit comments

Comments
 (0)