GitOps for k8s
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. .DEFAULT: all
  2. .PHONY: all release-bins clean realclean test integration-test check-generated
  3. SUDO := $(shell docker info > /dev/null 2> /dev/null || echo "sudo")
  4. TEST_FLAGS?=
  5. include docker/kubectl.version
  6. include docker/helm.version
  7. # NB default target architecture is amd64. If you would like to try the
  8. # other one -- pass an ARCH variable, e.g.,
  9. # `make ARCH=arm64`
  10. ifeq ($(ARCH),)
  11. ARCH=amd64
  12. endif
  13. CURRENT_OS_ARCH=$(shell echo `go env GOOS`-`go env GOARCH`)
  14. GO_BIN=$(shell if [ "$GOBIN" != "" ]; then echo "$GOBIN"; else echo `go env GOPATH`/bin; fi)
  15. # NB because this outputs absolute file names, you have to be careful
  16. # if you're testing out the Makefile with `-W` (pretend a file is
  17. # new); use the full path to the pretend-new file, e.g.,
  18. # `make -W $PWD/registry/registry.go`
  19. godeps=$(shell go list -f '{{join .Deps "\n"}}' $1 | grep -v /vendor/ | xargs go list -f '{{if not .Standard}}{{ $$dep := . }}{{range .GoFiles}}{{$$dep.Dir}}/{{.}} {{end}}{{end}}')
  20. FLUXD_DEPS:=$(call godeps,./cmd/fluxd)
  21. FLUXCTL_DEPS:=$(call godeps,./cmd/fluxctl)
  22. HELM_OPERATOR_DEPS:=$(call godeps,./cmd/helm-operator)
  23. IMAGE_TAG:=$(shell ./docker/image-tag)
  24. VCS_REF:=$(shell git rev-parse HEAD)
  25. BUILD_DATE:=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
  26. all: $(GO_BIN)/bin/fluxctl $(GO_BIN)/bin/fluxd $(GO_BIN)/bin/helm-operator build/.flux.done build/.helm-operator.done
  27. release-bins:
  28. for arch in amd64; do \
  29. for os in linux darwin windows; do \
  30. CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -o "build/fluxctl_"$$os"_$$arch" $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/fluxctl/; \
  31. done; \
  32. done;
  33. for arch in arm arm64; do \
  34. for os in linux; do \
  35. CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -o "build/fluxctl_"$$os"_$$arch" $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/fluxctl/; \
  36. done; \
  37. done;
  38. clean:
  39. go clean
  40. rm -rf ./build
  41. rm -f test/bin/kubectl test/bin/helm test/bin/kind
  42. realclean: clean
  43. rm -rf ./cache
  44. test: test/bin/helm test/bin/kubectl
  45. PATH="${PWD}/bin:${PWD}/test/bin:${PATH}" go test ${TEST_FLAGS} $(shell go list ./... | grep -v "^github.com/weaveworks/flux/vendor" | sort -u)
  46. e2e: test/bin/helm test/bin/kubectl build/.flux.done build/.helm-operator.done
  47. PATH="${PWD}/test/bin:${PATH}" CURRENT_OS_ARCH=$(CURRENT_OS_ARCH) test/e2e/run.sh
  48. build/.%.done: docker/Dockerfile.%
  49. mkdir -p ./build/docker/$*
  50. cp $^ ./build/docker/$*/
  51. $(SUDO) docker build -t docker.io/weaveworks/$* -t docker.io/weaveworks/$*:$(IMAGE_TAG) \
  52. --build-arg VCS_REF="$(VCS_REF)" \
  53. --build-arg BUILD_DATE="$(BUILD_DATE)" \
  54. -f build/docker/$*/Dockerfile.$* ./build/docker/$*
  55. touch $@
  56. build/.flux.done: build/fluxd build/kubectl docker/ssh_config docker/kubeconfig docker/known_hosts.sh
  57. build/.helm-operator.done: build/helm-operator build/kubectl build/helm docker/ssh_config docker/known_hosts.sh docker/helm-repositories.yaml
  58. build/fluxd: $(FLUXD_DEPS)
  59. build/fluxd: cmd/fluxd/*.go
  60. CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o $@ $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/fluxd
  61. build/helm-operator: $(HELM_OPERATOR_DEPS)
  62. build/helm-operator: cmd/helm-operator/*.go
  63. CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o $@ $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/helm-operator
  64. build/kubectl: cache/linux-$(ARCH)/kubectl-$(KUBECTL_VERSION)
  65. test/bin/kubectl: cache/$(CURRENT_OS_ARCH)/kubectl-$(KUBECTL_VERSION)
  66. build/helm: cache/linux-$(ARCH)/helm-$(HELM_VERSION)
  67. test/bin/helm: cache/$(CURRENT_OS_ARCH)/helm-$(HELM_VERSION)
  68. build/kubectl test/bin/kubectl build/helm test/bin/helm:
  69. mkdir -p build
  70. cp $< $@
  71. if [ `basename $@` = "build" -a $(CURRENT_OS_ARCH) = "linux-$(ARCH)" ]; then strip $@; fi
  72. chmod a+x $@
  73. cache/%/kubectl-$(KUBECTL_VERSION): docker/kubectl.version
  74. mkdir -p cache/$*
  75. curl -L -o cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz "https://dl.k8s.io/$(KUBECTL_VERSION)/kubernetes-client-$*.tar.gz"
  76. [ $* != "linux-$(ARCH)" ] || echo "$(KUBECTL_CHECKSUM_$(ARCH)) cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz" | shasum -a 256 -c
  77. tar -m --strip-components 3 -C ./cache/$* -xzf cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz kubernetes/client/bin/kubectl
  78. mv ./cache/$*/kubectl $@
  79. cache/%/helm-$(HELM_VERSION): docker/helm.version
  80. mkdir -p cache/$*
  81. curl -L -o cache/$*/helm-$(HELM_VERSION).tar.gz "https://storage.googleapis.com/kubernetes-helm/helm-v$(HELM_VERSION)-$*.tar.gz"
  82. [ $* != "linux-$(ARCH)" ] || echo "$(HELM_CHECKSUM_$(ARCH)) cache/$*/helm-$(HELM_VERSION).tar.gz" | shasum -a 256 -c
  83. tar -m -C ./cache -xzf cache/$*/helm-$(HELM_VERSION).tar.gz $*/helm
  84. mv cache/$*/helm $@
  85. $(GO_BIN)/bin/fluxctl: $(FLUXCTL_DEPS)
  86. $(GO_BIN)/bin/fluxctl: ./cmd/fluxctl/*.go
  87. go install ./cmd/fluxctl
  88. $(GO_BIN)/bin/fluxd: $(FLUXD_DEPS)
  89. $(GO_BIN)/bin/fluxd: cmd/fluxd/*.go
  90. go install ./cmd/fluxd
  91. $(GO_BIN)/bin/helm-operator: $(HELM_OPERATOR_DEPS)
  92. $(GO_BIN)/bin/help-operator: cmd/helm-operator/*.go
  93. go install ./cmd/helm-operator
  94. integration-test: all
  95. test/bin/test-flux
  96. check-generated:
  97. ./bin/helm/update_codegen.sh
  98. git diff --exit-code -- integrations/apis intergrations/client