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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. .DEFAULT: all
  2. .PHONY: all release-bins clean realclean test integration-test
  3. SUDO := $(shell docker info > /dev/null 2> /dev/null || echo "sudo")
  4. TEST_FLAGS?=
  5. include docker/kubectl.version
  6. # NB because this outputs absolute file names, you have to be careful
  7. # if you're testing out the Makefile with `-W` (pretend a file is
  8. # new); use the full path to the pretend-new file, e.g.,
  9. # `make -W $PWD/registry/registry.go`
  10. 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}}')
  11. FLUXD_DEPS:=$(call godeps,./cmd/fluxd)
  12. FLUXCTL_DEPS:=$(call godeps,./cmd/fluxctl)
  13. HELM_OPERATOR_DEPS:=$(call godeps,./cmd/helm-operator)
  14. IMAGE_TAG:=$(shell ./docker/image-tag)
  15. VCS_REF:=$(shell git rev-parse HEAD)
  16. BUILD_DATE:=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
  17. all: $(GOPATH)/bin/fluxctl $(GOPATH)/bin/fluxd $(GOPATH)/bin/helm-operator build/.flux.done build/.helm-operator.done
  18. release-bins:
  19. for arch in amd64; do \
  20. for os in linux darwin; do \
  21. 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/; \
  22. done; \
  23. done
  24. clean:
  25. go clean
  26. rm -rf ./build
  27. realclean: clean
  28. rm -rf ./cache
  29. test:
  30. PATH=${PATH}:${PWD}/bin go test ${TEST_FLAGS} $(shell go list ./... | grep -v "^github.com/weaveworks/flux/vendor" | sort -u)
  31. build/.%.done: docker/Dockerfile.%
  32. mkdir -p ./build/docker/$*
  33. cp $^ ./build/docker/$*/
  34. $(SUDO) docker build -t quay.io/weaveworks/$* -t quay.io/weaveworks/$*:$(IMAGE_TAG) \
  35. --build-arg VCS_REF="$(VCS_REF)" \
  36. --build-arg BUILD_DATE="$(BUILD_DATE)" \
  37. -f build/docker/$*/Dockerfile.$* ./build/docker/$*
  38. touch $@
  39. build/.flux.done: build/fluxd build/kubectl docker/ssh_config docker/kubeconfig
  40. build/.helm-operator.done: build/helm-operator build/kubectl docker/ssh_config
  41. build/fluxd: $(FLUXD_DEPS)
  42. build/fluxd: cmd/fluxd/*.go
  43. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/fluxd
  44. build/helm-operator: $(HELM_OPERATOR_DEPS)
  45. build/helm-operator: cmd/helm-operator/*.go
  46. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/helm-operator
  47. build/kubectl: cache/kubectl-$(KUBECTL_VERSION) docker/kubectl.version
  48. cp cache/kubectl-$(KUBECTL_VERSION) $@
  49. strip $@
  50. chmod a+x $@
  51. cache/kubectl-$(KUBECTL_VERSION):
  52. mkdir -p cache
  53. curl -L -o $@ "https://storage.googleapis.com/kubernetes-release/release/$(KUBECTL_VERSION)/bin/linux/amd64/kubectl"
  54. $(GOPATH)/bin/fluxctl: $(FLUXCTL_DEPS)
  55. $(GOPATH)/bin/fluxctl: ./cmd/fluxctl/*.go
  56. go install ./cmd/fluxctl
  57. $(GOPATH)/bin/fluxd: $(FLUXD_DEPS)
  58. $(GOPATH)/bin/fluxd: cmd/fluxd/*.go
  59. go install ./cmd/fluxd
  60. $(GOPATH)/bin/helm-operator: $(HELM_OPERATOR_DEPS)
  61. $(GOPATH)/bin/help-operator: cmd/helm-operator/*.go
  62. go install ./cmd/helm-operator
  63. integration-test: all
  64. test/bin/test-flux