Skip to content

Commit ba6cb41

Browse files
committed
add parameter base_image and addon_image to BUILD_PARAMETERS
1 parent 7b96bea commit ba6cb41

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

build.make

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,35 @@ endif
6363
# Specific packages can be excluded from each of the tests below by setting the *_FILTER_CMD variables
6464
# to something like "| grep -v 'github.com/kubernetes-csi/project/pkg/foobar'". See usage below.
6565

66-
# BUILD_PLATFORMS contains a set of <os> <arch> <suffix> triplets,
66+
# BUILD_PLATFORMS contains the set of tuples [os arch suffix base_image addon_image]
6767
# separated by semicolon. An empty variable or empty entry (= just a
6868
# semicolon) builds for the default platform of the current Go
6969
# toolchain.
7070
BUILD_PLATFORMS =
7171

7272
# Add go ldflags using LDFLAGS at the time of compilation.
73-
IMPORTPATH_LDFLAGS = -X main.version=$(REV)
73+
IMPORTPATH_LDFLAGS = -X main.version=$(REV)
7474
EXT_LDFLAGS = -extldflags "-static"
75-
LDFLAGS =
75+
LDFLAGS =
7676
FULL_LDFLAGS = $(LDFLAGS) $(IMPORTPATH_LDFLAGS) $(EXT_LDFLAGS)
7777
# This builds each command (= the sub-directories of ./cmd) for the target platform(s)
7878
# defined by BUILD_PLATFORMS.
7979
$(CMDS:%=build-%): build-%: check-go-version-go
8080
mkdir -p bin
81-
echo '$(BUILD_PLATFORMS)' | tr ';' '\n' | while read -r os arch suffix; do \
81+
# OS_ARCH_SEEN captures all of the $os-$arch seen for the current binary
82+
# that we want to build, if we've seen an $os-$arch before it means that
83+
# we don't need to build it again, this is done to avoid building
84+
# the windows binary multiple times (see the default value of $BUILD_PLATFORMS)
85+
export OS_ARCH_SEEN="" && echo '$(BUILD_PLATFORMS)' | tr ';' '\n' | while read -r os arch suffix base_image addon_image; do \
86+
os_arch_seen_pre=$${OS_ARCH_SEEN%%$$os-$$arch*}; \
87+
if ! [ $${#os_arch_seen_pre} = $${#OS_ARCH_SEEN} ]; then \
88+
continue; \
89+
fi; \
8290
if ! (set -x; CGO_ENABLED=0 GOOS="$$os" GOARCH="$$arch" go build $(GOFLAGS_VENDOR) -a -ldflags '$(FULL_LDFLAGS)' -o "./bin/$*$$suffix" ./cmd/$*); then \
8391
echo "Building $* for GOOS=$$os GOARCH=$$arch failed, see error(s) above."; \
8492
exit 1; \
8593
fi; \
94+
OS_ARCH_SEEN+=";$$os-$$arch"; \
8695
done
8796

8897
$(CMDS:%=container-%): container-%: build-%
@@ -139,21 +148,33 @@ $(CMDS:%=push-multiarch-%): push-multiarch-%: check-pull-base-ref build-%
139148
dockerfile_windows=$$(if [ -e ./cmd/$*/Dockerfile.Windows ]; then echo ./cmd/$*/Dockerfile.Windows; else echo Dockerfile.Windows; fi); \
140149
if [ '$(BUILD_PLATFORMS)' ]; then build_platforms='$(BUILD_PLATFORMS)'; else build_platforms="linux amd64"; fi; \
141150
if ! [ -f "$$dockerfile_windows" ]; then \
142-
build_platforms="$$(echo "$$build_platforms" | sed -e 's/windows *[^ ]* *.exe//g' -e 's/; *;/;/g')"; \
151+
# we couldn't find a windows dockerfile, remove all of the
152+
# windows build platform configurations from $BUILD_PLATFORMS
153+
build_platforms="$$(echo "$$build_platforms" | sed -e 's/windows *[^ ]* *.exe *[^ ]* *[^ ]*//g' -e 's/; *;/;/g')"; \
143154
fi; \
144155
pushMultiArch () { \
145156
tag=$$1; \
146-
echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix; do \
157+
echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix base_image addon_image; do \
158+
# the docker tags shouldn't have colons
159+
escaped_base_image=$${base_image/:/-/}; \
160+
if ! [ -z $$escaped_base_image ]; then escaped_base_image+="-"; fi \
147161
docker buildx build --push \
148-
--tag $(IMAGE_NAME):$$arch-$$os-$$tag \
162+
--tag $(IMAGE_NAME):$$arch-$$escaped_base_image$$os-$$tag \
149163
--platform=$$os/$$arch \
150164
--file $$(eval echo \$${dockerfile_$$os}) \
151165
--build-arg binary=./bin/$*$$suffix \
152166
--build-arg ARCH=$$arch \
167+
--build-arg BASE_IMAGE=$$base_image \
168+
--build-arg ADDON_IMAGE=$$addon_image \
153169
--label revision=$(REV) \
154170
.; \
155171
done; \
156-
images=$$(echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix; do echo $(IMAGE_NAME):$$arch-$$os-$$tag; done); \
172+
images=$$(echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix base_image addon_image; do \
173+
# the docker tags shouldn't have colons
174+
escaped_base_image=$${base_image/:/-/}; \
175+
if ! [ -z $$escaped_base_image ]; then escaped_base_image+="-"; fi \
176+
echo $(IMAGE_NAME):$$arch-$$escaped_base_image$$os-$$tag;
177+
done); \
157178
docker manifest create --amend $(IMAGE_NAME):$$tag $$images; \
158179
docker manifest push -p $(IMAGE_NAME):$$tag; \
159180
}; \
@@ -288,4 +309,3 @@ test-spelling:
288309
test-boilerplate:
289310
@ echo; echo "### $@:"
290311
@ ./release-tools/verify-boilerplate.sh "$(pwd)"
291-

prow.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ version_to_git () {
7777
esac
7878
}
7979

80-
configvar CSI_PROW_BUILD_PLATFORMS "linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x; linux arm64 -arm64" "Go target platforms (= GOOS + GOARCH) and file suffix of the resulting binaries"
80+
configvar CSI_PROW_BUILD_PLATFORMS "linux amd64; linux ppc64le -ppc64le; linux s390x -s390x; linux arm64 -arm64; windows amd64 .exe nanoserver:ltsc2019 servercore:ltsc2019; windows amd64 .exe nanoserver:1909 servercore:1909; windows amd64 .exe nanoserver:2004 servercore:2004; windows amd64 .exe nanoserver:20H2 servercore:20H2" "Go target platforms (= GOOS + GOARCH) and file suffix of the resulting binaries"
8181

8282
# If we have a vendor directory, then use it. We must be careful to only
8383
# use this for "make" invocations inside the project's repo itself because
@@ -723,7 +723,7 @@ install_csi_driver () {
723723
fi
724724
}
725725

726-
# Installs all nessesary snapshotter CRDs
726+
# Installs all nessesary snapshotter CRDs
727727
install_snapshot_crds() {
728728
# Wait until volumesnapshot CRDs are in place.
729729
CRD_BASE_DIR="https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION}/client/config/crd"
@@ -770,7 +770,7 @@ install_snapshot_controller() {
770770
fi
771771
echo "$(date +%H:%M:%S)" "waiting for snapshot RBAC setup complete, attempt #$cnt"
772772
cnt=$((cnt + 1))
773-
sleep 10
773+
sleep 10
774774
done
775775

776776
SNAPSHOT_CONTROLLER_YAML="${CONTROLLER_DIR}/deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
@@ -839,7 +839,7 @@ install_snapshot_controller() {
839839
fi
840840
echo "$(date +%H:%M:%S)" "waiting for snapshot controller deployment to complete, attempt #$cnt"
841841
cnt=$((cnt + 1))
842-
sleep 10
842+
sleep 10
843843
done
844844
}
845845
@@ -979,7 +979,7 @@ run_sanity () (
979979
kubectl exec "${CSI_PROW_SANITY_POD}" -c "${CSI_PROW_SANITY_CONTAINER}" -- mkdir "\$@" && echo "\$@"
980980
EOF
981981
# Using "rm -rf" as fallback for "rmdir" is a workaround for:
982-
# Node Service
982+
# Node Service
983983
# should work
984984
# /nvme/gopath.tmp/src/github.com/kubernetes-csi/csi-test/pkg/sanity/node.go:624
985985
# STEP: reusing connection to CSI driver at dns:///172.17.0.2:30896
@@ -1143,7 +1143,7 @@ make_test_to_junit () {
11431143
# version_gt 1.3.1 v1.2.0 (returns true)
11441144
# version_gt 1.1.1 release-1.2.0 (returns false)
11451145
# version_gt 1.2.0 1.2.2 (returns false)
1146-
function version_gt() {
1146+
function version_gt() {
11471147
versions=$(for ver in "$@"; do ver=${ver#release-}; ver=${ver#kubernetes-}; echo "${ver#v}"; done)
11481148
greaterVersion=${1#"release-"};
11491149
greaterVersion=${greaterVersion#"kubernetes-"};
@@ -1206,7 +1206,7 @@ main () {
12061206
if [ "$rbac_file_path" == "" ]; then
12071207
rbac_file_path="$(pwd)/deploy/kubernetes/rbac.yaml"
12081208
fi
1209-
1209+
12101210
if [ -e "$rbac_file_path" ]; then
12111211
# This is one of those components which has its own RBAC rules (like external-provisioner).
12121212
# We are testing a locally built image and also want to test with the the current,

0 commit comments

Comments
 (0)