Skip to content

Commit 6d10b89

Browse files
authored
Merge pull request #130 from lunarway/feature/upgrade-go-version
upgrade go version and dependencies
2 parents 9d0635f + d0e0daf commit 6d10b89

File tree

5 files changed

+268
-331
lines changed

5 files changed

+268
-331
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
- uses: actions/setup-go@v3
1515
with:
16-
go-version: "1.17"
16+
go-version: "1.19.1"
1717

1818
- name: Cache Go modules
1919
uses: actions/cache@v3

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
- uses: actions/setup-go@v3
1414
with:
15-
go-version: "1.17.7"
15+
go-version: "1.19.1"
1616

1717
- name: Set tag in environment
1818
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV # extracts the tag name from refs/tags/v1.2.3

Makefile

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# To re-generate a bundle for another specific version without changing the standard setup, you can:
44
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6-
VERSION ?= 0.1.21
6+
VERSION ?= 0.1.22
77

88
# CHANNELS define the bundle channels used in the bundle.
99
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
@@ -41,12 +41,25 @@ TAG ?= latest
4141
# lunar.tech/cluster-routing-controller-bundle:$VERSION and lunar.tech/cluster-routing-controller-catalog:$VERSION.
4242
IMAGE_TAG_BASE ?= ${REG}/${ORG}/${PROJECT}
4343

44+
# BUNDLE_IMG defines the image:tag used for the bundle.
45+
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
46+
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
47+
48+
# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
49+
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
50+
51+
# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
52+
# You can enable this value if you would like to use SHA Based Digests
53+
# To enable set flag to true
54+
USE_IMAGE_DIGESTS ?= false
55+
ifeq ($(USE_IMAGE_DIGESTS), true)
56+
BUNDLE_GEN_FLAGS += --use-image-digests
57+
endif
58+
4459
IMG ?= ${IMAGE_TAG_BASE}:${TAG}
4560

46-
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
47-
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
4861
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
49-
ENVTEST_K8S_VERSION = 1.21
62+
ENVTEST_K8S_VERSION = 1.24.2
5063

5164
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5265
ifeq (,$(shell go env GOBIN))
@@ -61,6 +74,7 @@ endif
6174
SHELL = /usr/bin/env bash -o pipefail
6275
.SHELLFLAGS = -ec
6376

77+
.PHONY: all
6478
all: build
6579

6680
##@ General
@@ -76,67 +90,102 @@ all: build
7690
# More info on the awk command:
7791
# http://linuxcommand.org/lc3_adv_awk.php
7892

93+
.PHONY: help
7994
help: ## Display this help.
8095
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
8196

8297
##@ Development
8398

99+
.PHONY: manifests
84100
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
85-
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
101+
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
86102

103+
.PHONY: generate
87104
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
88105
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
89106

107+
.PHONY: fmt
90108
fmt: ## Run go fmt against code.
91109
go fmt ./...
92110

111+
.PHONY: vet
93112
vet: ## Run go vet against code.
94113
go vet ./...
95114

115+
.PHONY: test
96116
test: manifests generate fmt vet envtest ## Run tests.
97117
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
98118

99119
##@ Build
100-
120+
.PHONY: build
101121
build: generate fmt vet ## Build manager binary.
102122
go build -o bin/manager main.go
103123

124+
.PHONY: run
104125
run: manifests generate fmt vet ## Run a controller from your host.
105126
go run ./main.go
106127

128+
.PHONY: docker-build
107129
docker-build: test ## Build docker image with the manager.
108130
docker build -t ${IMG} .
109131

132+
.PHONY: docker-push
110133
docker-push: ## Push docker image with the manager.
111134
docker push ${IMG}
112135

113136
##@ Deployment
114137

138+
ifndef ignore-not-found
139+
ignore-not-found = false
140+
endif
141+
142+
.PHONY: install
115143
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
116144
$(KUSTOMIZE) build config/crd | kubectl apply -f -
117145

146+
.PHONY: uninstall
118147
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
119-
$(KUSTOMIZE) build config/crd | kubectl delete -f -
148+
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
120149

150+
.PHONY: deploy
121151
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
122152
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
123153
$(KUSTOMIZE) build config/default | kubectl apply -f -
124154

155+
.PHONY: undeploy
125156
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
126-
$(KUSTOMIZE) build config/default | kubectl delete -f -
157+
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
158+
159+
## Location to install dependencies to
160+
LOCALBIN ?= $(shell pwd)/bin
161+
$(LOCALBIN):
162+
mkdir -p $(LOCALBIN)
163+
164+
## Tool Binaries
165+
KUSTOMIZE ?= $(LOCALBIN)/kustomize
166+
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
167+
ENVTEST ?= $(LOCALBIN)/setup-envtest
168+
169+
## Tool Versions
170+
KUSTOMIZE_VERSION ?= v3.8.7
171+
CONTROLLER_TOOLS_VERSION ?= v0.9.2
127172

173+
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
174+
.PHONY: kustomize
175+
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
176+
$(KUSTOMIZE): $(LOCALBIN)
177+
test -s $(LOCALBIN)/kustomize || { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
128178

129-
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
130-
controller-gen: ## Download controller-gen locally if necessary.
131-
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])
179+
.PHONY: controller-gen
180+
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
181+
$(CONTROLLER_GEN): $(LOCALBIN)
182+
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
132183

133-
KUSTOMIZE = $(shell pwd)/bin/kustomize
134-
kustomize: ## Download kustomize locally if necessary.
135-
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])
184+
.PHONY: envtest
185+
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
186+
$(ENVTEST): $(LOCALBIN)
187+
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
136188

137-
ENVTEST = $(shell pwd)/bin/setup-envtest
138-
envtest: ## Download envtest-setup locally if necessary.
139-
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
140189

141190
# go-get-tool will 'go get' any package $2 and install it to $1.
142191
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
@@ -156,7 +205,7 @@ endef
156205
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
157206
operator-sdk generate kustomize manifests -q
158207
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
159-
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
208+
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)
160209
operator-sdk bundle validate ./bundle
161210

162211
.PHONY: bundle-build
@@ -176,7 +225,7 @@ ifeq (,$(shell which opm 2>/dev/null))
176225
set -e ;\
177226
mkdir -p $(dir $(OPM)) ;\
178227
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
179-
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\
228+
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$${OS}-$${ARCH}-opm ;\
180229
chmod +x $(OPM) ;\
181230
}
182231
else

go.mod

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,86 @@
11
module github/lunarway/cluster-routing-controller
22

3-
go 1.16
3+
go 1.19
44

55
require (
66
github.com/onsi/ginkgo v1.16.5
7-
github.com/onsi/gomega v1.22.1
7+
github.com/onsi/gomega v1.23.0
88
github.com/stretchr/testify v1.8.0
9-
k8s.io/api v0.24.4
10-
k8s.io/apimachinery v0.24.4
11-
k8s.io/client-go v0.24.4
12-
sigs.k8s.io/controller-runtime v0.12.3
9+
k8s.io/api v0.25.3
10+
k8s.io/apimachinery v0.25.3
11+
k8s.io/client-go v0.25.3
12+
sigs.k8s.io/controller-runtime v0.13.0
13+
)
14+
15+
require (
16+
cloud.google.com/go v0.97.0 // indirect
17+
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
18+
github.com/Azure/go-autorest/autorest v0.11.27 // indirect
19+
github.com/Azure/go-autorest/autorest/adal v0.9.20 // indirect
20+
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
21+
github.com/Azure/go-autorest/logger v0.2.1 // indirect
22+
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
23+
github.com/PuerkitoBio/purell v1.1.1 // indirect
24+
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
25+
github.com/beorn7/perks v1.0.1 // indirect
26+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
27+
github.com/davecgh/go-spew v1.1.1 // indirect
28+
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
29+
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
30+
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
31+
github.com/fsnotify/fsnotify v1.5.4 // indirect
32+
github.com/go-logr/logr v1.2.3 // indirect
33+
github.com/go-logr/zapr v1.2.3 // indirect
34+
github.com/go-openapi/jsonpointer v0.19.5 // indirect
35+
github.com/go-openapi/jsonreference v0.19.5 // indirect
36+
github.com/go-openapi/swag v0.19.14 // indirect
37+
github.com/gogo/protobuf v1.3.2 // indirect
38+
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
39+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
40+
github.com/golang/protobuf v1.5.2 // indirect
41+
github.com/google/gnostic v0.5.7-v3refs // indirect
42+
github.com/google/go-cmp v0.5.9 // indirect
43+
github.com/google/gofuzz v1.1.0 // indirect
44+
github.com/google/uuid v1.1.2 // indirect
45+
github.com/imdario/mergo v0.3.12 // indirect
46+
github.com/josharian/intern v1.0.0 // indirect
47+
github.com/json-iterator/go v1.1.12 // indirect
48+
github.com/mailru/easyjson v0.7.6 // indirect
49+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
50+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
51+
github.com/modern-go/reflect2 v1.0.2 // indirect
52+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
53+
github.com/nxadm/tail v1.4.8 // indirect
54+
github.com/pkg/errors v0.9.1 // indirect
55+
github.com/pmezard/go-difflib v1.0.0 // indirect
56+
github.com/prometheus/client_golang v1.12.2 // indirect
57+
github.com/prometheus/client_model v0.2.0 // indirect
58+
github.com/prometheus/common v0.32.1 // indirect
59+
github.com/prometheus/procfs v0.7.3 // indirect
60+
github.com/spf13/pflag v1.0.5 // indirect
61+
go.uber.org/atomic v1.7.0 // indirect
62+
go.uber.org/multierr v1.6.0 // indirect
63+
go.uber.org/zap v1.21.0 // indirect
64+
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect
65+
golang.org/x/net v0.1.0 // indirect
66+
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
67+
golang.org/x/sys v0.1.0 // indirect
68+
golang.org/x/term v0.1.0 // indirect
69+
golang.org/x/text v0.4.0 // indirect
70+
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
71+
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
72+
google.golang.org/appengine v1.6.7 // indirect
73+
google.golang.org/protobuf v1.28.0 // indirect
74+
gopkg.in/inf.v0 v0.9.1 // indirect
75+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
76+
gopkg.in/yaml.v2 v2.4.0 // indirect
77+
gopkg.in/yaml.v3 v3.0.1 // indirect
78+
k8s.io/apiextensions-apiserver v0.25.0 // indirect
79+
k8s.io/component-base v0.25.0 // indirect
80+
k8s.io/klog/v2 v2.70.1 // indirect
81+
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
82+
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
83+
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
84+
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
85+
sigs.k8s.io/yaml v1.3.0 // indirect
1386
)

0 commit comments

Comments
 (0)