Skip to content

Commit

Permalink
Sync main and api go module vendoring to fix go workspaces
Browse files Browse the repository at this point in the history
Adds a target to the Makefile to do a 'go work sync' and ensure that the
main and api modules are synced whenever we update dependencies. This
makes it possible to work with go workspaces locally on developer
machines. The target will be executed whenever a 'make update' is run.
  • Loading branch information
csrwng committed Nov 19, 2024
1 parent 02a5fea commit 9909930
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ PROMTOOL=$(abspath $(TOOLS_BIN_DIR)/promtool)

GO_GCFLAGS ?= -gcflags=all='-N -l'
GO=GO111MODULE=on GOWORK=off GOFLAGS=-mod=vendor go
GOWS=GO111MODULE=on GOWORK=$(shell pwd)/hack/workspace/go.work GOFLAGS=-mod=vendor go
GO_BUILD_RECIPE=CGO_ENABLED=1 $(GO) build $(GO_GCFLAGS)
GO_CLI_RECIPE=CGO_ENABLED=0 $(GO) build $(GO_GCFLAGS) -ldflags '-extldflags "-static"'
GO_E2E_RECIPE=CGO_ENABLED=1 $(GO) test $(GO_GCFLAGS) -tags e2e -c
Expand Down Expand Up @@ -50,7 +51,7 @@ pre-commit: all verify test
build: hypershift-operator control-plane-operator control-plane-pki-operator hypershift product-cli

.PHONY: update
update: api-deps api api-docs deps clients
update: workspace-sync api-deps api api-docs deps clients

.PHONY: verify
verify: update staticcheck fmt vet
Expand Down Expand Up @@ -240,6 +241,10 @@ api-deps:
$(GO) mod verify && \
$(GO) list -m -mod=readonly -json all > /dev/null

.PHONY: workspace-sync
workspace-sync:
cd hack/workspace && \
$(GOWS) work sync

# Run staticcheck
# How to ignore failures https://staticcheck.io/docs/configuration#line-based-linter-directives
Expand Down
2 changes: 2 additions & 0 deletions hack/workspace/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
go.work.sum
6 changes: 6 additions & 0 deletions hack/workspace/go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
go 1.22.0

use (
./hypershift
./hypershift/api
)
1 change: 1 addition & 0 deletions hack/workspace/hypershift

0 comments on commit 9909930

Please sign in to comment.