Skip to content

Commit 3714bae

Browse files
Merge pull request #79 from fmount/gowork
Add go.work to deal with multi module dependencies
2 parents 6240496 + 7e19f41 commit 3714bae

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ config/manager/kustomization.yaml
3030

3131
# Common CI tools repository
3232
CI_TOOLS_REPO
33+
34+
# generated workspace file
35+
go.work
36+
go.work.sum

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ ARG OPERATOR_BASE_IMAGE=gcr.io/distroless/static:nonroot
44
# Build the manager binary
55
FROM $GOLANG_BUILDER AS builder
66

7+
ARG GOWORK=off
8+
ENV GOWORK=$GOWORK
9+
710
#Arguments required by OSBS build system
811
ARG CACHITO_ENV_FILE=/remote-source/cachito.env
912

Makefile

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
4040

4141
VERIFY_TLS ?= true
4242

43+
# GOWORK
44+
GOWORK ?= off
45+
export GOWORK := $(GOWORK)
46+
4347
# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
4448
# You can enable this value if you would like to use SHA Based Digests
4549
# To enable set flag to true
@@ -117,11 +121,17 @@ fmt: ## Run go fmt against code.
117121

118122
.PHONY: vet
119123
vet: ## Run go vet against code.
120-
go vet ./...
124+
go vet ./... ./api/...
121125

122126
.PHONY: test
123127
test: manifests generate fmt vet envtest ## Run tests.
124-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
128+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... ./api/... -coverprofile cover.out
129+
130+
.PHONY: gowork
131+
gowork: ## Generate go.work file to support our multi module repository
132+
test -f go.work || go work init
133+
go work use .
134+
go work use ./api
125135

126136
##@ Build
127137

@@ -135,7 +145,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
135145

136146
.PHONY: docker-build
137147
docker-build: test ## Build docker image with the manager.
138-
podman build -t ${IMG} .
148+
podman build --build-arg GOWORK=$(GOWORK) -t ${IMG} .
139149

140150
.PHONY: docker-push
141151
docker-push: ## Push docker image with the manager.
@@ -273,19 +283,25 @@ get-ci-tools:
273283
# Run go fmt against code
274284
gofmt: get-ci-tools
275285
$(CI_TOOLS_REPO_DIR)/test-runner/gofmt.sh
286+
$(CI_TOOLS_REPO_DIR)/test-runner/gofmt.sh ./api
276287

277288
# Run go vet against code
278289
govet: get-ci-tools
279290
$(CI_TOOLS_REPO_DIR)/test-runner/govet.sh
291+
$(CI_TOOLS_REPO_DIR)/test-runner/govet.sh ./api
280292

281293
# Run go test against code
282294
gotest: get-ci-tools
283295
$(CI_TOOLS_REPO_DIR)/test-runner/gotest.sh
296+
$(CI_TOOLS_REPO_DIR)/test-runner/gotest.sh ./api
284297

285298
# Run golangci-lint test against code
286299
golangci: get-ci-tools
287300
$(CI_TOOLS_REPO_DIR)/test-runner/golangci.sh
301+
$(CI_TOOLS_REPO_DIR)/test-runner/golangci.sh ./api
288302

289303
# Run go lint against code
290304
golint: get-ci-tools
291305
PATH=$(GOBIN):$(PATH); $(CI_TOOLS_REPO_DIR)/test-runner/golint.sh
306+
PATH=$(GOBIN):$(PATH); $(CI_TOOLS_REPO_DIR)/test-runner/golint.sh ./api
307+

go.work

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
go 1.18
2+
3+
use (
4+
.
5+
./api
6+
)

0 commit comments

Comments
 (0)