Skip to content

Commit

Permalink
go.work example
Browse files Browse the repository at this point in the history
ENV=prod (default) builds without go.work
ENV != prod builds with go.work
  • Loading branch information
karol-kokoszka committed Nov 19, 2024
1 parent c8442d4 commit 3736cb0
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 7 deletions.
30 changes: 23 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ GIT_ROOT = $(shell git rev-parse --show-toplevel)
GOBIN ?= $(shell pwd)/bin
GOFILES = go list -f '{{range .GoFiles}}{{ $$.Dir }}/{{ . }} {{end}}{{range .TestGoFiles}}{{ $$.Dir }}/{{ . }} {{end}}' $(PKG)

# DO NOT CHANGE IT
# ENV=prod means that go.work is not taken into the account when building the project.
ENV ?= prod

SCYLLA_VERSION?=scylla:6.0.1
IP_FAMILY?=IPV4
RAFT_SCHEMA?=none
Expand Down Expand Up @@ -166,7 +170,7 @@ pkg-stress-test:
@cd $(PKG); $(GOBIN)/stress $(PWD)/stress.test -test.run $(RUN)

.PHONY: start-dev-env
start-dev-env: ## Start testing containers
start-dev-env: GOWORK=off## Start testing containers
start-dev-env: .testing-up deploy-agent build-cli

.PHONY: .testing-up
Expand All @@ -179,8 +183,12 @@ dev-env-status: ## Checks status of docker containers and cluster nodes

.PHONY: build-agent
build-agent: ## Build development agent binary
@echo "==> Building agent"
@CGO_ENABLED=0 GOOS=linux go build -trimpath -mod=vendor -o ./scylla-manager-agent.dev ./pkg/cmd/agent
@echo "==> Building agent with ENV=$(ENV)"
@if [ "$(ENV)" = "prod" ]; then \
CGO_ENABLED=0 GOOS=linux GOWORK=off go build -trimpath -mod=vendor -o ./scylla-manager-agent.dev ./pkg/cmd/agent || { echo "Build failed"; exit 1; }; \
else \
CGO_ENABLED=0 GOOS=linux go build -trimpath -o ./scylla-manager-agent.dev ./pkg/cmd/agent || { echo "Build failed"; exit 1; }; \
fi

.PHONY: deploy-agent
deploy-agent: build-agent ## Deploy it to testing containers
Expand All @@ -191,13 +199,21 @@ deploy-agent: build-agent ## Deploy it to testing containers
build-cli: ## Build development cli binary
build-cli: OUTPUT=./sctool.dev
build-cli:
@echo "==> Building sctool"
@go build -trimpath -mod=vendor -o $(OUTPUT) ./pkg/cmd/sctool
@echo "==> Building sctool with ENV=$(ENV)"
@if [ "$(ENV)" = "prod" ]; then \
GOWORK=off go build -trimpath -mod=vendor -o $(OUTPUT) ./pkg/cmd/sctool || { echo "Build failed"; exit 1; }; \
else \
go build -trimpath -o $(OUTPUT) ./pkg/cmd/sctool || { echo "Build failed"; exit 1; }; \
fi

.PHONY: build-server
build-server: ## Build development server
@echo "==> Building scylla-manager"
@CGO_ENABLED=0 GOOS=linux go build -trimpath -mod=vendor -o ./scylla-manager.dev ./pkg/cmd/scylla-manager
@echo "==> Building scylla-manager with ENV=$(ENV)"
@if [ "$(ENV)" = "prod" ]; then \
CGO_ENABLED=0 GOOS=linux GOWORK=off go build -trimpath -mod=vendor -o ./scylla-manager.dev ./pkg/cmd/scylla-manager || { echo "Build failed"; exit 1; }; \
else \
CGO_ENABLED=0 GOOS=linux go build -trimpath -o ./scylla-manager.dev ./pkg/cmd/scylla-manager || { echo "Build failed"; exit 1; }; \
fi

.PHONY: clean-server
clean-server: ## Remove development server container
Expand Down
8 changes: 8 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
go 1.21.1

use (
.
./v3/pkg/managerclient
./v3/pkg/util
./v3/swagger
)
29 changes: 29 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
bazil.org/fuse v0.0.0-20200524192727-fb710f7dfd05/go.mod h1:h0h5FBYpXThbvSfTqthw+0I4nmHnhTHkO5BoOHsBWqg=
cloud.google.com/go/compute v1.19.1 h1:am86mquDUgjGNWxiGn+5PGLbmgiWXlE/yNWpIpNvuXY=
github.com/a8m/tree v0.0.0-20201026183218-fce18e2a750e/go.mod h1:FSdwKX97koS5efgm8WevNf7XS3PqtyFkKDDXrz778cg=
github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
github.com/anacrolix/dms v1.1.0/go.mod h1:msPKAoppoNRfrYplJqx63FZ+VipDZ4Xsj3KzIQxyU7k=
github.com/atotto/clipboard v0.1.2/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/billziss-gh/cgofuse v1.4.0/go.mod h1:LJjoaUojlVjgo5GQoEJTcJNqZJeRU0nCR84CyxKt2YM=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/hanwen/go-fuse/v2 v2.0.3/go.mod h1:0EQM6aH2ctVpvZ6a+onrQ/vaykxh2GH7hy3e13vzTUY=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nsf/termbox-go v0.0.0-20200418040025-38ba6e5628f1/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
github.com/sevlyar/go-daemon v0.1.5/go.mod h1:6dJpPatBT9eUwM5VCw9Bt6CdX9Tk6UWvhW3MebLDRKE=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
goftp.io/server v0.4.0/go.mod h1:hFZeR656ErRt3ojMKt7H10vQ5nuWV1e0YeUTeorlR6k=
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
3 changes: 3 additions & 0 deletions pkg/cmd/scylla-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import (
"fmt"
"syscall"
"time"

"github.com/scylladb/scylla-manager/v3/pkg/util"
)

func main() {
util.Panic()
if err := rootCmd.Execute(); err != nil {
fmt.Fprintf(rootCmd.OutOrStderr(), "\nSTARTUP ERROR: %s\n\n", err)

Expand Down
5 changes: 5 additions & 0 deletions v3/pkg/util/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package util

func Panic() {
panic("works")
}

0 comments on commit 3736cb0

Please sign in to comment.