Skip to content

Commit 19902a8

Browse files
authored
Merge pull request #692 from xdu31/goversion-release-0.5
Repo controlled build go version
2 parents 3c9f223 + 1b7e9d5 commit 19902a8

7 files changed

+74
-2
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
aws-iam-authenticator
2+
3+
bin
4+
15
/dist
26
/_output
37

.go-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.21.5

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ARG golang_image=public.ecr.aws/docker/library/golang:1.21.5
1717
FROM --platform=$BUILDPLATFORM $golang_image AS builder
1818
WORKDIR /go/src/github.com/kubernetes-sigs/aws-iam-authenticator
1919
COPY . .
20+
RUN go version
2021
RUN goproxy=https://goproxy.io go mod download
2122
ARG TARGETOS TARGETARCH
2223
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make bin

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ image: .image-linux-$(GOARCH)
100100
.PHONY: .image-linux-%
101101
.image-linux-%:
102102
docker buildx build --output=type=docker --platform linux/$* \
103+
--build-arg golang_image=$(shell hack/setup-go.sh) \
103104
--tag aws-iam-authenticator:$(VERSION)_$(GIT_COMMIT)_$(BUILD_DATE_STRIPPED)-linux_$* .
104105

105106
.PHONY: goreleaser
@@ -111,8 +112,7 @@ endif
111112

112113
.PHONY: test
113114
test:
114-
go test -v -coverprofile=coverage.out -race $(PKG)/pkg/...
115-
go tool cover -html=coverage.out -o coverage.html
115+
./hack/test-unit.sh
116116

117117
.PHONY: integration
118118
integration:

hack/setup-go.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Copyright 2020 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# script to setup go version as needed
17+
# MUST BE RUN FROM THE REPO ROOT DIRECTORY
18+
19+
# read go-version file unless GO_VERSION is set
20+
GO_VERSION="${GO_VERSION:-"$(cat .go-version)"}"
21+
GO_IMAGE=public.ecr.aws/docker/library/golang:$GO_VERSION
22+
23+
# gotoolchain
24+
# https://go.dev/doc/toolchain
25+
export GOSUMDB="sum.golang.org"
26+
export GOTOOLCHAIN=go${GO_VERSION}
27+
28+
# force go modules
29+
export GO111MODULE=on
30+
31+
echo $GO_IMAGE

hack/test-integration.sh

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ if [[ "${CREATE_TEST_ROLE}" = "true" ]]; then
7878
TEST_ROLE_ARN="$(echo ${create_role_output} | jq -r '.Role.Arn')"
7979
fi
8080

81+
source hack/setup-go.sh
82+
83+
go version
84+
8185
make clean
8286
make bin
8387

hack/test-unit.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2016 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+
set -o errexit
18+
set -o pipefail
19+
set -o nounset
20+
21+
# cd to the repo root and setup go
22+
REPO_ROOT="$(cd "$( dirname "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd)"
23+
24+
source hack/setup-go.sh
25+
26+
pushd ${REPO_ROOT}
27+
28+
go version
29+
go test -v -coverprofile=coverage.out -race sigs.k8s.io/aws-iam-authenticator/pkg/...
30+
go tool cover -html=coverage.out -o coverage.html
31+
popd

0 commit comments

Comments
 (0)