Skip to content

Commit 9b98626

Browse files
authored
Upgrade/golang1.13 (#469)
* Prepare environment for golang 1.13 Add test which checks if version has been changed Remove unnecessary variables from Makefile remove commit change * Remove unnecessary dependencies
1 parent 74dcbdc commit 9b98626

File tree

6 files changed

+58
-401
lines changed

6 files changed

+58
-401
lines changed

.dockerignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
.git
33
.gobuild
44
docs
5-
pkg
65
tools
76
deps
8-
dashboard

Dockerfile

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
1-
FROM scratch
1+
# Upgrading to golang:1.13-alpine:
2+
# It is possible once prometheus-operator will release new version (newer then 0.33.0)
23

3-
ADD bin/arangodb_operator /usr/bin/
4+
# Download packages required by kube-arangodb
5+
FROM golang:1.12.9-alpine AS downloader
46

5-
ENTRYPOINT [ "/usr/bin/arangodb_operator" ]
7+
# git is required by 'go mod'
8+
RUN apk add git
9+
10+
WORKDIR /app
11+
12+
COPY go.mod .
13+
COPY go.sum .
14+
# It is done only once unless go.mod has been changed
15+
RUN go mod download
16+
17+
18+
19+
# Compile Golang kube-arangodb sources with downloaded dependencies
20+
FROM downloader AS builder
21+
ARG VERSION
22+
ARG COMMIT
23+
24+
COPY *.go /app/
25+
COPY pkg /app/pkg
26+
COPY dashboard/assets.go /app/dashboard/assets.go
27+
28+
ENV GO111MODULE=on
29+
ENV CGO_ENABLED=0
30+
ENV GOARCH=amd64
31+
ENV GOOS=linux
32+
33+
RUN go build -installsuffix netgo -ldflags "-X main.projectVersion=${VERSION} -X main.projectBuild=${COMMIT}" -o /arangodb_operator
34+
35+
36+
37+
# Build the final production image with only binary file
38+
FROM scratch
39+
40+
COPY --from=builder /arangodb_operator /usr/bin/arangodb_operator
41+
42+
ENTRYPOINT [ "/usr/bin/arangodb_operator" ]

Makefile

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ VERSION_MAJOR_MINOR_PATCH := $(shell echo $(VERSION) | cut -f 1 -d '+')
66
VERSION_MAJOR_MINOR := $(shell echo $(VERSION_MAJOR_MINOR_PATCH) | cut -f 1,2 -d '.')
77
VERSION_MAJOR := $(shell echo $(VERSION_MAJOR_MINOR) | cut -f 1 -d '.')
88
COMMIT := $(shell git rev-parse --short HEAD)
9-
DOCKERCLI := $(shell which docker)
109

1110
GOBUILDDIR := $(SCRIPTDIR)/.gobuild
1211
SRCDIR := $(SCRIPTDIR)
@@ -18,11 +17,9 @@ DASHBOARDDIR := $(ROOTDIR)/dashboard
1817
ORGPATH := github.com/arangodb
1918
ORGDIR := $(GOBUILDDIR)/src/$(ORGPATH)
2019
REPONAME := kube-arangodb
21-
REPODIR := $(ORGDIR)/$(REPONAME)
2220
REPOPATH := $(ORGPATH)/$(REPONAME)
2321

2422
GOPATH := $(GOBUILDDIR)
25-
GOVERSION := 1.10.0-alpine
2623

2724
PULSAR := $(GOBUILDDIR)/bin/pulsar$(shell go env GOEXE)
2825
GOASSETSBUILDER := $(GOBUILDDIR)/bin/go-assets-builder$(shell go env GOEXE)
@@ -99,8 +96,6 @@ ifndef ALLOWCHAOS
9996
ALLOWCHAOS := true
10097
endif
10198

102-
BINNAME := $(PROJECT)
103-
BIN := $(BINDIR)/$(BINNAME)
10499
TESTBINNAME := $(PROJECT)_test
105100
TESTBIN := $(BINDIR)/$(TESTBINNAME)
106101
DURATIONTESTBINNAME := $(PROJECT)_duration_test
@@ -165,7 +160,7 @@ build: docker manifests
165160

166161
.PHONY: clean
167162
clean:
168-
rm -Rf $(BIN) $(BINDIR) $(DASHBOARDDIR)/build $(DASHBOARDDIR)/node_modules
163+
rm -Rf $(BINDIR) $(DASHBOARDDIR)/build $(DASHBOARDDIR)/node_modules
169164

170165
.PHONY: check-vars
171166
check-vars:
@@ -210,13 +205,9 @@ dashboard/assets.go: $(DASHBOARDSOURCES) $(DASHBOARDDIR)/Dockerfile.build
210205
$(DASHBOARDBUILDIMAGE)
211206
go run github.com/jessevdk/go-assets-builder -s /dashboard/build/ -o dashboard/assets.go -p dashboard dashboard/build
212207

213-
$(BIN): $(SOURCES) dashboard/assets.go VERSION
214-
@mkdir -p $(BINDIR)
215-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -installsuffix netgo -ldflags "-X main.projectVersion=$(VERSION) -X main.projectBuild=$(COMMIT)" -o $(BIN) $(REPOPATH)
216-
217208
.PHONY: docker
218-
docker: check-vars $(BIN)
219-
docker build -f $(DOCKERFILE) -t $(OPERATORIMAGE) .
209+
docker: check-vars $(SOURCES) dashboard/assets.go VERSION
210+
docker build --build-arg VERSION=$(VERSION) --build-arg COMMIT=$(COMMIT) -f $(DOCKERFILE) -t $(OPERATORIMAGE) .
220211
ifdef PUSHIMAGES
221212
docker push $(OPERATORIMAGE)
222213
endif

go.mod

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,94 +8,47 @@ replace (
88
k8s.io/api => k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b
99
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8
1010
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d
11-
k8s.io/code-generator => ./deps/k8s.io/code-generator
12-
1311
)
1412

1513
require (
16-
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
17-
github.com/Azure/go-autorest/autorest v0.1.0 // indirect
18-
github.com/aktau/github-release v0.7.2 // indirect
14+
github.com/PuerkitoBio/purell v1.1.1 // indirect
1915
github.com/arangodb-helper/go-certificates v0.0.0-20180821055445-9fca24fc2680
2016
github.com/arangodb/arangosync-client v0.6.3
2117
github.com/arangodb/go-driver v0.0.0-20191002124627-11b6bfc64f67
2218
github.com/arangodb/go-upgrade-rules v0.0.0-20180809110947-031b4774ff21
23-
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
24-
github.com/bugagazavr/go-gitlab-client v0.0.0-20150830002541-e5999f934dc4 // indirect
2519
github.com/cenkalti/backoff v2.1.1+incompatible
26-
github.com/coreos/bbolt v1.3.2 // indirect
27-
github.com/coreos/etcd v3.3.13+incompatible // indirect
2820
github.com/coreos/go-semver v0.3.0
29-
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
3021
github.com/coreos/prometheus-operator v0.31.1
31-
github.com/cpuguy83/go-md2man v1.0.10 // indirect
3222
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9
3323
github.com/dgrijalva/jwt-go v3.2.0+incompatible
34-
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect
35-
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 // indirect
36-
github.com/dustin/go-broadcast v0.0.0-20171205050544-f664265f5a66 // indirect
3724
github.com/evanphx/json-patch v4.2.0+incompatible
38-
github.com/ewoutp/go-gitlab-client v0.0.0-20150214183219-6e4464cd3221 // indirect
3925
github.com/ghodss/yaml v1.0.0
4026
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 // indirect
41-
github.com/gin-gonic/autotls v0.0.0-20190406003154-fb31fc47f521 // indirect
4227
github.com/gin-gonic/gin v1.3.0
43-
github.com/go-openapi/analysis v0.19.0 // indirect
44-
github.com/go-openapi/errors v0.19.0 // indirect
45-
github.com/go-openapi/loads v0.19.0 // indirect
46-
github.com/go-openapi/runtime v0.19.0 // indirect
47-
github.com/go-openapi/strfmt v0.19.0 // indirect
28+
github.com/go-openapi/spec v0.18.0 // indirect
29+
github.com/go-openapi/swag v0.18.0 // indirect
4830
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
49-
github.com/google/btree v1.0.0 // indirect
5031
github.com/google/gofuzz v1.0.0 // indirect
32+
github.com/google/uuid v1.1.1 // indirect
5133
github.com/googleapis/gnostic v0.2.0 // indirect
52-
github.com/gophercloud/gophercloud v0.0.0-20190504011306-6f9faf57fddc // indirect
53-
github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 // indirect
54-
github.com/gorilla/websocket v1.4.0 // indirect
55-
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
56-
github.com/helm/helm v2.14.3+incompatible // indirect
5734
github.com/inconshreveable/mousetrap v1.0.0 // indirect
5835
github.com/jessevdk/go-assets v0.0.0-20160921144138-4f4301a06e15
59-
github.com/jessevdk/go-assets-builder v0.0.0-20130903091706-b8483521738f // indirect
60-
github.com/jessevdk/go-flags v1.4.0 // indirect
61-
github.com/jonboulle/clockwork v0.1.0 // indirect
62-
github.com/juju/errgo v0.0.0-20140925100237-08cceb5d0b53 // indirect
6336
github.com/julienschmidt/httprouter v1.2.0
64-
github.com/manucorporat/stats v0.0.0-20180402194714-3ba42d56d227 // indirect
65-
github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect
66-
github.com/mattn/go-colorable v0.1.1 // indirect
37+
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe // indirect
6738
github.com/mattn/go-isatty v0.0.7 // indirect
68-
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
69-
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect
7039
github.com/pborman/uuid v1.2.0 // indirect
71-
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
7240
github.com/pkg/errors v0.8.1
7341
github.com/prometheus/client_golang v1.0.0
74-
github.com/pulcy/pulsar v0.0.0-20180915062927-71ea24b0ec2f // indirect
7542
github.com/robfig/cron v1.2.0
7643
github.com/rs/zerolog v1.14.3
77-
github.com/russross/blackfriday v2.0.0+incompatible // indirect
78-
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
79-
github.com/sourcegraph/go-vcsurl v0.0.0-20161114165620-2305ecca26ab // indirect
8044
github.com/spf13/cobra v0.0.3
8145
github.com/spf13/pflag v1.0.3
82-
github.com/spf13/viper v1.3.2 // indirect
8346
github.com/stretchr/testify v1.3.0
84-
github.com/thinkerou/favicon v0.1.0 // indirect
85-
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
86-
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
87-
github.com/ugorji/go v1.1.4 // indirect
88-
github.com/voxelbrain/goptions v0.0.0-20180630082107-58cddc247ea2 // indirect
89-
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
90-
go.uber.org/atomic v1.4.0 // indirect
91-
go.uber.org/multierr v1.1.0 // indirect
92-
go.uber.org/zap v1.10.0 // indirect
47+
github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 // indirect
9348
golang.org/x/sys v0.0.0-20190506115046-ca7f33d4116e
9449
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
95-
google.golang.org/api v0.4.0 // indirect
96-
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873 // indirect
97-
google.golang.org/grpc v1.20.1 // indirect
98-
gopkg.in/sourcegraph/go-vcsurl.v1 v1.0.0-20131114132947-6b12603ea6fd // indirect
50+
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
51+
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
9952
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b
10053
k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8
10154
k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d

0 commit comments

Comments
 (0)