Skip to content

Commit

Permalink
fix build for go 1.15
Browse files Browse the repository at this point in the history
* call go mod vendor from Makefile
* use code-generator from go.mod
* update to golang:1.15 AS builder
* update to alpine:3.12
* update dependencies
  • Loading branch information
mwennrich committed Aug 26, 2020
1 parent e3e361b commit 260b035
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 18 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
############# builder-base #############
FROM golang:1.13 AS builder
FROM golang:1.15 AS builder

WORKDIR /go/src/github.com/metal-stack/gardener-extension-provider-metal
COPY . .
RUN hack/install-requirements.sh \
&& make VERIFY=$VERIFY all


############# base #############
FROM alpine:3.12
RUN apk add --update bash curl
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ format:
clean:
@./hack/clean.sh

.PHONY: vendor
vendor:
@go mod vendor

.PHONY: generate
generate:
@./hack/generate.sh

.PHONE: generate-in-docker
generate-in-docker:
docker run --rm -it -v $(PWD):/go/src/github.com/metal-stack/gardener-extension-provider-metal golang:1.14 \
docker run --rm -it -v $(PWD):/go/src/github.com/metal-stack/gardener-extension-provider-metal golang:1.15 \
sh -c "cd /go/src/github.com/metal-stack/gardener-extension-provider-metal \
&& ./hack/install-requirements.sh \
&& make vendor \
&& make generate \
&& chown -R $(shell id -u):$(shell id -g) ."

Expand All @@ -52,9 +57,9 @@ install:

.PHONY: all
ifeq ($(VERIFY),true)
all: verify generate install
all: vendor verify generate install
else
all: generate install
all: vendor generate install
endif

### Docker commands
Expand Down
8 changes: 0 additions & 8 deletions hack/install-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,3 @@ $ export PATH=/usr/local/opt/coreutils/libexec/gnubin:\$PATH
EOM
fi

# install code-generator which is required for generate-code
echo "installing code-generator"
mkdir -p "$DIRNAME/../vendor/k8s.io/"
cd "$DIRNAME/../vendor/k8s.io/"
rm -rf *
curl -fLs https://github.com/kubernetes/code-generator/archive/v0.16.6.tar.gz | tar -xzf -
mv code-generator-0.16.6 code-generator
cd -
22 changes: 22 additions & 0 deletions hack/tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// +build tools

// Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
//
// 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.

// This package imports things required by build scripts, to force `go mod` to see them as dependencies
package tools

import (
_ "k8s.io/code-generator"
)
2 changes: 1 addition & 1 deletion pkg/controller/controlplane/valuesprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/metal-stack/gardener-extension-provider-metal/pkg/metal"

gardencorev1alpha1 "github.com/gardener/gardener/pkg/apis/core/v1alpha1"
gardenv1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1"
extensionsv1alpha1 "github.com/gardener/gardener/pkg/apis/extensions/v1alpha1"
gardenv1beta1 "github.com/gardener/gardener/pkg/apis/garden/v1beta1"

"github.com/golang/mock/gomock"

Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/worker/machines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (

extensionscontroller "github.com/gardener/gardener/extensions/pkg/controller"
"github.com/gardener/gardener/extensions/pkg/controller/worker"
mockclient "github.com/gardener/gardener/extensions/pkg/mock/controller-runtime/client"
mockkubernetes "github.com/gardener/gardener/extensions/pkg/mock/gardener/client/kubernetes"
mockclient "github.com/gardener/gardener/pkg/mock/controller-runtime/client"
mockkubernetes "github.com/gardener/gardener/pkg/mock/gardener/client/kubernetes"
"github.com/metal-stack/gardener-extension-provider-metal/pkg/apis/config"
apismetal "github.com/metal-stack/gardener-extension-provider-metal/pkg/apis/metal"
. "github.com/metal-stack/gardener-extension-provider-metal/pkg/controller/worker"
"github.com/metal-stack/gardener-extension-provider-metal/pkg/metal"

gardenv1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1"
extensionsv1alpha1 "github.com/gardener/gardener/pkg/apis/extensions/v1alpha1"
gardenv1beta1 "github.com/gardener/gardener/pkg/apis/garden/v1beta1"
"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/controlplane/ensurer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
"testing"

mockclient "github.com/gardener/gardener/extensions/pkg/mock/controller-runtime/client"
extensionswebhook "github.com/gardener/gardener/extensions/pkg/webhook"
"github.com/gardener/gardener/extensions/pkg/webhook/controlplane/test"
gardencorev1alpha1 "github.com/gardener/gardener/pkg/apis/core/v1alpha1"
mockclient "github.com/gardener/gardener/pkg/mock/controller-runtime/client"
"github.com/metal-stack/gardener-extension-provider-metal/pkg/metal"

"github.com/coreos/go-systemd/unit"
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/controlplaneexposure/ensurer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"testing"

mockclient "github.com/gardener/gardener/extensions/pkg/mock/controller-runtime/client"
"github.com/gardener/gardener/extensions/pkg/util"
"github.com/gardener/gardener/extensions/pkg/webhook/controlplane"
mockclient "github.com/gardener/gardener/pkg/mock/controller-runtime/client"
"github.com/metal-stack/gardener-extension-provider-metal/pkg/apis/config"

"github.com/golang/mock/gomock"
Expand Down

0 comments on commit 260b035

Please sign in to comment.