Skip to content

Commit

Permalink
Merge pull request #691 from xdu31/goversion-release-0.6
Browse files Browse the repository at this point in the history
Repo controlled build go version
  • Loading branch information
k8s-ci-robot authored Feb 5, 2024
2 parents 8b36c07 + 666533e commit c33ded4
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ jobs:
with:
go-version-input: 1.21.5
go-version-file: go.mod

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
aws-iam-authenticator

bin

/dist
/_output

Expand Down
1 change: 1 addition & 0 deletions .go-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.21.5
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ARG golang_image=public.ecr.aws/docker/library/golang:1.21.5
FROM --platform=$BUILDPLATFORM $golang_image AS builder
WORKDIR /go/src/github.com/kubernetes-sigs/aws-iam-authenticator
COPY . .
RUN go version
RUN go mod download
ARG TARGETOS TARGETARCH
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make bin
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ image: .image-linux-$(GOARCH)
.PHONY: .image-linux-%
.image-linux-%:
docker buildx build --output=type=docker --platform linux/$* \
--build-arg golang_image=$(shell hack/setup-go.sh) \
--tag aws-iam-authenticator:$(VERSION)_$(GIT_COMMIT)_$(BUILD_DATE_STRIPPED)-linux_$* .

.PHONY: goreleaser
Expand All @@ -111,8 +112,7 @@ endif

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

.PHONY: integration
integration:
Expand Down
31 changes: 31 additions & 0 deletions hack/setup-go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Copyright 2020 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# script to setup go version as needed
# MUST BE RUN FROM THE REPO ROOT DIRECTORY

# read go-version file unless GO_VERSION is set
GO_VERSION="${GO_VERSION:-"$(cat .go-version)"}"
GO_IMAGE=public.ecr.aws/docker/library/golang:$GO_VERSION

# gotoolchain
# https://go.dev/doc/toolchain
export GOSUMDB="sum.golang.org"
export GOTOOLCHAIN=go${GO_VERSION}

# force go modules
export GO111MODULE=on

echo $GO_IMAGE
4 changes: 4 additions & 0 deletions hack/test-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ if [[ "${CREATE_TEST_ROLE}" = "true" ]]; then
TEST_ROLE_ARN="$(echo ${create_role_output} | jq -r '.Role.Arn')"
fi

source hack/setup-go.sh

go version

make clean
make bin

Expand Down
31 changes: 31 additions & 0 deletions hack/test-unit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o pipefail
set -o nounset

# cd to the repo root and setup go
REPO_ROOT="$(cd "$( dirname "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd)"

source hack/setup-go.sh

pushd ${REPO_ROOT}

go version
go test -v -coverprofile=coverage.out -race sigs.k8s.io/aws-iam-authenticator/pkg/...
go tool cover -html=coverage.out -o coverage.html
popd

0 comments on commit c33ded4

Please sign in to comment.