Skip to content

Commit e0ef30e

Browse files
Merge pull request #186 from openshift-cherrypick-robot/cherry-pick-185-to-release-4.15
[release-4.15] [KNI] build: envtest: remove 'latest' floating tag refs
2 parents 60eedad + 23b6dee commit e0ef30e

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

Makefile.kni

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ unit-test-quick: update-vendor
6969

7070
.PHONY: install-envtest
7171
install-envtest: update-vendor
72-
hack/install-envtest.sh
72+
hack-kni/install-envtest.sh
7373

7474
.PHONY: integration-test
7575
integration-test: install-envtest

hack-kni/install-envtest.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2022 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# This script is a helper script to install envtest
18+
# (https://github.com/kubernetes-sigs/controller-runtime/tree/master/pkg/envtest)
19+
# Mostly used by CI but can also be used for running integration tests locally.
20+
# Usage: `hack/install-envtest.sh`.
21+
22+
set -o errexit
23+
set -o nounset
24+
set -o pipefail
25+
26+
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
27+
source "${SCRIPT_ROOT}/hack/lib/init.sh"
28+
29+
# setup-envtest requires the version to be in the form of X.Y(.Z) (e.g. 1.23 or 1.23.3)
30+
# thus we want to remove the 'v' from the version extracted out of the go.mod file
31+
version=$(cat ${SCRIPT_ROOT}/go.mod | grep 'k8s.io/kubernetes' | grep -v '=>' | awk '{print $NF}' | awk 'BEGIN{FS=OFS="."}NF--' | sed 's/v//')
32+
33+
GOPATH=$(go env GOPATH)
34+
TEMP_DIR=${TMPDIR-/tmp}
35+
# this is the last version before the bump golang 1.20 -> 1.22. We want to avoid the go.mod version format changes - for now.
36+
go install sigs.k8s.io/controller-runtime/tools/[email protected]
37+
"${GOPATH}"/bin/setup-envtest use -p env "${version}" > "${TEMP_DIR}/setup-envtest"
38+

0 commit comments

Comments
 (0)