-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (62 loc) · 1.88 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
.PHONY: dir check_connect_timeout
GO ?= go
GOBUILDFLAGS ?=
LDFLAGS ?=
MODVER ?= 1.20
DOCKERCFGDIR ?=
STOREROOT ?=
COMPOSEROOT ?=
CONNECTTIMEOUT ?=
BASESYSTEMCONFIG ?=
bd = bin
exe = composectl
linter = golangci-lint
commit = $(shell git rev-parse HEAD)
ifneq ($(strip $(commit)),)
LDFLAGS += -X 'github.com/foundriesio/composeapp/cmd/composectl/cmd.commit=$(commit)'
endif
ifdef DOCKERCFGDIR
LDFLAGS += -X 'github.com/foundriesio/composeapp/cmd/composectl/cmd.overrideConfigDir=$(DOCKERCFGDIR)'
endif
ifdef STOREROOT
LDFLAGS += -X 'github.com/foundriesio/composeapp/cmd/composectl/cmd.storeRoot=$(STOREROOT)'
endif
ifdef COMPOSEROOT
LDFLAGS += -X 'github.com/foundriesio/composeapp/cmd/composectl/cmd.composeRoot=$(COMPOSEROOT)'
endif
ifdef CONNECTTIMEOUT
LDFLAGS += -X 'github.com/foundriesio/composeapp/cmd/composectl/cmd.defConnectTimeout=$(CONNECTTIMEOUT)'
endif
ifdef BASESYSTEMCONFIG
LDFLAGS += -X 'github.com/foundriesio/composeapp/cmd/composectl/cmd.baseSystemConfig=$(BASESYSTEMCONFIG)'
endif
ifdef LDFLAGS
GOBUILDFLAGS += -ldflags="$(LDFLAGS)"
endif
all: $(exe)
check_connect_timeout:
@if [ -n "$(strip $(CONNECTTIMEOUT))" ] && ! [ "$(strip $(CONNECTTIMEOUT))" -eq "$(strip $(CONNECTTIMEOUT))" ] 2>/dev/null; then \
echo "ERR: invalid CONNECTTIMEOUT value ($(CONNECTTIMEOUT)); it must be integer."; \
exit 1; \
fi
format:
@$(GO) fmt ./...
test-unit:
@$(GO) test -v ./pkg/compose/...
$(bd):
@mkdir -p $@
$(exe): $(bd) check_connect_timeout
$(GO) build -tags publish $(GOBUILDFLAGS) -o $(bd)/$@ cmd/composectl/main.go
clean:
@rm -r $(bd)
check: format
$(linter) run
tidy-mod:
go mod tidy -go=$(MODVER)
# the followinf targets should be run only in the dev container
preload-images:
test/fixtures/preload-images.sh
test-e2e: $(exe) preload-images
@$(GO) test -v ./...
test-smoke: $(exe) preload-images
@$(GO) test -v -run TestSmoke test/integration/smoke_test.go