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 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. CURRENT_OS_ARCH=$(shell echo `go env GOOS`-`go env GOARCH`)
  8. # NB because this outputs absolute file names, you have to be careful
  9. # if you're testing out the Makefile with `-W` (pretend a file is
  10. # new); use the full path to the pretend-new file, e.g.,
  11. # `make -W $PWD/registry/registry.go`
  12. 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}}')
  13. FLUXD_DEPS:=$(call godeps,./cmd/fluxd)
  14. FLUXCTL_DEPS:=$(call godeps,./cmd/fluxctl)
  15. HELM_OPERATOR_DEPS:=$(call godeps,./cmd/helm-operator)
  16. IMAGE_TAG:=$(shell ./docker/image-tag)
  17. VCS_REF:=$(shell git rev-parse HEAD)
  18. BUILD_DATE:=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
  19. all: $(GOPATH)/bin/fluxctl $(GOPATH)/bin/fluxd $(GOPATH)/bin/helm-operator build/.flux.done build/.helm-operator.done
  20. release-bins:
  21. for arch in amd64; do \
  22. for os in linux darwin windows; do \
  23. 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/; \
  24. done; \
  25. done
  26. clean:
  27. go clean
  28. rm -rf ./build
  29. rm -f test/bin/kubectl test/bin/helm
  30. realclean: clean
  31. rm -rf ./cache
  32. test: test/bin/helm test/bin/kubectl
  33. PATH="${PWD}/bin:${PWD}/test/bin:${PATH}" go test ${TEST_FLAGS} $(shell go list ./... | grep -v "^github.com/weaveworks/flux/vendor" | sort -u)
  34. build/.%.done: docker/Dockerfile.%
  35. mkdir -p ./build/docker/$*
  36. cp $^ ./build/docker/$*/
  37. $(SUDO) docker build -t docker.io/weaveworks/$* -t docker.io/weaveworks/$*:$(IMAGE_TAG) \
  38. --build-arg VCS_REF="$(VCS_REF)" \
  39. --build-arg BUILD_DATE="$(BUILD_DATE)" \
  40. -f build/docker/$*/Dockerfile.$* ./build/docker/$*
  41. touch $@
  42. build/.flux.done: build/fluxd build/kubectl docker/ssh_config docker/kubeconfig docker/verify_known_hosts.sh
  43. build/.helm-operator.done: build/helm-operator build/kubectl build/helm docker/ssh_config docker/verify_known_hosts.sh docker/helm-repositories.yaml
  44. build/fluxd: $(FLUXD_DEPS)
  45. build/fluxd: cmd/fluxd/*.go
  46. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/fluxd
  47. build/helm-operator: $(HELM_OPERATOR_DEPS)
  48. build/helm-operator: cmd/helm-operator/*.go
  49. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/helm-operator
  50. build/kubectl: cache/linux-amd64/kubectl-$(KUBECTL_VERSION)
  51. test/bin/kubectl: cache/$(CURRENT_OS_ARCH)/kubectl-$(KUBECTL_VERSION)
  52. build/helm: cache/linux-amd64/helm-$(HELM_VERSION)
  53. test/bin/helm: cache/$(CURRENT_OS_ARCH)/helm-$(HELM_VERSION)
  54. build/kubectl test/bin/kubectl build/helm test/bin/helm:
  55. mkdir -p build
  56. cp $< $@
  57. if [ `basename $@` = "build" -a $(CURRENT_OS_ARCH) = "linux-amd64" ]; then strip $@; fi
  58. chmod a+x $@
  59. cache/%/kubectl-$(KUBECTL_VERSION): docker/kubectl.version
  60. mkdir -p cache/$*
  61. curl -L -o cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz "https://dl.k8s.io/$(KUBECTL_VERSION)/kubernetes-client-$*.tar.gz"
  62. [ $* != "linux-amd64" ] || echo "$(KUBECTL_CHECKSUM) cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz" | shasum -a 256 -c
  63. tar -m --strip-components 3 -C ./cache/$* -xzf cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz kubernetes/client/bin/kubectl
  64. mv ./cache/$*/kubectl $@
  65. cache/%/helm-$(HELM_VERSION): docker/helm.version
  66. mkdir -p cache/$*
  67. curl -L -o cache/$*/helm-$(HELM_VERSION).tar.gz "https://storage.googleapis.com/kubernetes-helm/helm-v$(HELM_VERSION)-$*.tar.gz"
  68. [ $* != "linux-amd64" ] || echo "$(HELM_CHECKSUM) cache/$*/helm-$(HELM_VERSION).tar.gz" | shasum -a 256 -c
  69. tar -m -C ./cache -xzf cache/$*/helm-$(HELM_VERSION).tar.gz $*/helm
  70. mv cache/$*/helm $@
  71. $(GOPATH)/bin/fluxctl: $(FLUXCTL_DEPS)
  72. $(GOPATH)/bin/fluxctl: ./cmd/fluxctl/*.go
  73. go install ./cmd/fluxctl
  74. $(GOPATH)/bin/fluxd: $(FLUXD_DEPS)
  75. $(GOPATH)/bin/fluxd: cmd/fluxd/*.go
  76. go install ./cmd/fluxd
  77. $(GOPATH)/bin/helm-operator: $(HELM_OPERATOR_DEPS)
  78. $(GOPATH)/bin/help-operator: cmd/helm-operator/*.go
  79. go install ./cmd/helm-operator
  80. integration-test: all
  81. test/bin/test-flux
  82. check-generated:
  83. ./bin/helm/update_codegen.sh
  84. git diff --exit-code -- integrations/apis intergrations/client