This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into change-snap-to-classic
- Loading branch information
Showing
98 changed files
with
2,783 additions
and
1,179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
.DEFAULT: all | ||
.PHONY: all release-bins clean realclean test integration-test generate-deploy check-generated | ||
.PHONY: all release-bins clean realclean test integration-test generate-deploy check-generated lint-e2e | ||
|
||
SUDO := $(shell docker info > /dev/null 2> /dev/null || echo "sudo") | ||
|
||
TEST_FLAGS?= | ||
|
||
BATS_COMMIT := 3a1c2f28be260f8687ff83183cef4963faabedd6 | ||
SHELLCHECK_VERSION := 0.7.0 | ||
SHFMT_VERSION := 2.6.4 | ||
|
||
include docker/kubectl.version | ||
include docker/kustomize.version | ||
include docker/helm.version | ||
|
@@ -15,7 +19,8 @@ include docker/helm.version | |
ifeq ($(ARCH),) | ||
ARCH=amd64 | ||
endif | ||
CURRENT_OS_ARCH=$(shell echo `go env GOOS`-`go env GOARCH`) | ||
CURRENT_OS=$(shell go env GOOS) | ||
CURRENT_OS_ARCH=$(shell echo $(CURRENT_OS)-`go env GOARCH`) | ||
GOBIN?=$(shell echo `go env GOPATH`/bin) | ||
|
||
godeps=$(shell go list -deps -f '{{if not .Standard}}{{ $$dep := . }}{{range .GoFiles}}{{$$dep.Dir}}/{{.}} {{end}}{{end}}' $(1) | sed "s%${PWD}/%%g") | ||
|
@@ -29,9 +34,11 @@ BUILD_DATE:=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') | |
|
||
DOCS_PORT:=8000 | ||
|
||
GENERATED_TEMPLATES_FILE=pkg/install/generated_templates.gogen.go | ||
|
||
all: $(GOBIN)/fluxctl $(GOBIN)/fluxd build/.flux.done | ||
|
||
release-bins: | ||
release-bins: $(GENERATED_TEMPLATES_FILE) | ||
for arch in amd64; do \ | ||
for os in linux darwin windows; do \ | ||
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/; \ | ||
|
@@ -51,11 +58,23 @@ clean: | |
realclean: clean | ||
rm -rf ./cache | ||
|
||
test: test/bin/helm test/bin/kubectl test/bin/kustomize | ||
test: test/bin/helm test/bin/kubectl test/bin/kustomize $(GENERATED_TEMPLATES_FILE) | ||
PATH="${PWD}/bin:${PWD}/test/bin:${PATH}" go test ${TEST_FLAGS} $(shell go list ./... | grep -v "^github.com/fluxcd/flux/vendor" | sort -u) | ||
|
||
e2e: test/bin/helm test/bin/kubectl build/.flux.done | ||
PATH="${PWD}/test/bin:${PATH}" CURRENT_OS_ARCH=$(CURRENT_OS_ARCH) test/e2e/run.sh | ||
e2e: lint-e2e test/bin/helm test/bin/kubectl test/e2e/bats $(GOBIN)/fluxctl build/.flux.done | ||
PATH="${PWD}/test/bin:${PATH}" CURRENT_OS_ARCH=$(CURRENT_OS_ARCH) test/e2e/run.bash | ||
|
||
E2E_BATS_FILES := test/e2e/*.bats | ||
E2E_BASH_FILES := test/e2e/run.bash test/e2e/lib/* | ||
SHFMT_DIFF_CMD := test/bin/shfmt -i 2 -sr -d | ||
SHFMT_WRITE_CMD := test/bin/shfmt -i 2 -sr -w | ||
lint-e2e: test/bin/shfmt test/bin/shellcheck | ||
@# shfmt is not compatible with .bats files, so we preprocess them to turn '@test's into functions | ||
for I in $(E2E_BATS_FILES); do \ | ||
( cat "$$I" | sed 's%@test.*%test() {%' | $(SHFMT_DIFF_CMD) ) || ( echo "Please correct the diff for file $$I"; exit 1 ); \ | ||
done | ||
$(SHFMT_DIFF_CMD) $(E2E_BASH_FILES) || ( echo "Please run '$(SHFMT_WRITE_CMD) $(E2E_BASH_FILES)'"; exit 1 ) | ||
test/bin/shellcheck $(E2E_BASH_FILES) $(E2E_BATS_FILES) | ||
|
||
build/.%.done: docker/Dockerfile.% | ||
mkdir -p ./build/docker/$* | ||
|
@@ -78,9 +97,11 @@ build/helm: cache/linux-$(ARCH)/helm-$(HELM_VERSION) | |
test/bin/helm: cache/$(CURRENT_OS_ARCH)/helm-$(HELM_VERSION) | ||
build/kustomize: cache/linux-amd64/kustomize-$(KUSTOMIZE_VERSION) | ||
test/bin/kustomize: cache/$(CURRENT_OS_ARCH)/kustomize-$(KUSTOMIZE_VERSION) | ||
test/bin/shellcheck: cache/$(CURRENT_OS_ARCH)/shellcheck-$(SHELLCHECK_VERSION) | ||
test/bin/shfmt: cache/$(CURRENT_OS_ARCH)/shfmt-$(SHFMT_VERSION) | ||
|
||
build/kubectl test/bin/kubectl build/kustomize test/bin/kustomize build/helm test/bin/helm: | ||
mkdir -p build | ||
build/kubectl test/bin/kubectl build/kustomize test/bin/kustomize build/helm test/bin/helm test/bin/shellcheck test/bin/shfmt: | ||
mkdir -p $(@D) | ||
cp $< $@ | ||
if [ `basename $@` = "build" -a $(CURRENT_OS_ARCH) = "linux-$(ARCH)" ]; then strip $@; fi | ||
chmod a+x $@ | ||
|
@@ -104,7 +125,25 @@ cache/%/helm-$(HELM_VERSION): docker/helm.version | |
tar -m -C ./cache -xzf cache/$*/helm-$(HELM_VERSION).tar.gz $*/helm | ||
mv cache/$*/helm $@ | ||
|
||
$(GOBIN)/fluxctl: $(FLUXCTL_DEPS) | ||
cache/%/shellcheck-$(SHELLCHECK_VERSION): | ||
mkdir -p cache/$* | ||
curl --fail -L -o cache/$*/shellcheck-$(SHELLCHECK_VERSION).tar.xz "https://storage.googleapis.com/shellcheck/shellcheck-v$(SHELLCHECK_VERSION).$(CURRENT_OS).x86_64.tar.xz" | ||
tar -C cache/$* --strip-components 1 -xvJf cache/$*/shellcheck-$(SHELLCHECK_VERSION).tar.xz shellcheck-v$(SHELLCHECK_VERSION)/shellcheck | ||
mv cache/$*/shellcheck $@ | ||
|
||
cache/%/shfmt-$(SHFMT_VERSION): | ||
mkdir -p cache/$* | ||
curl --fail -L -o $@ "https://github.com/mvdan/sh/releases/download/v$(SHFMT_VERSION)/shfmt_v$(SHFMT_VERSION)_`echo $* | tr - _`" | ||
|
||
test/e2e/bats: cache/bats-core-$(BATS_COMMIT).tar.gz | ||
mkdir -p $@ | ||
tar -C $@ --strip-components 1 -xzf $< | ||
|
||
cache/bats-core-$(BATS_COMMIT).tar.gz: | ||
# Use 2opremio's fork until https://github.com/bats-core/bats-core/pull/255 is merged | ||
curl --fail -L -o $@ https://github.com/2opremio/bats-core/archive/$(BATS_COMMIT).tar.gz | ||
|
||
$(GOBIN)/fluxctl: $(FLUXCTL_DEPS) $(GENERATED_TEMPLATES_FILE) | ||
go install ./cmd/fluxctl | ||
|
||
$(GOBIN)/fluxd: $(FLUXD_DEPS) | ||
|
@@ -113,14 +152,19 @@ $(GOBIN)/fluxd: $(FLUXD_DEPS) | |
integration-test: all | ||
test/bin/test-flux | ||
|
||
generate-deploy: pkg/install/generated_templates.gogen.go | ||
cd deploy && go run ../pkg/install/generate.go deploy | ||
generate-deploy: $(GOBIN)/fluxctl | ||
$(GOBIN)/fluxctl install -o ./deploy \ | ||
--git-url [email protected]:fluxcd/flux-get-started \ | ||
--git-email [email protected] \ | ||
--git-user 'Flux automation' \ | ||
--git-label flux-sync \ | ||
--namespace flux | ||
|
||
pkg/install/generated_templates.gogen.go: pkg/install/templates/* | ||
cd pkg/install && go run generate.go embedded-templates | ||
$(GENERATED_TEMPLATES_FILE): pkg/install/templates/*.tmpl pkg/install/generate.go | ||
go generate ./pkg/install | ||
|
||
check-generated: generate-deploy pkg/install/generated_templates.gogen.go | ||
git diff --exit-code -- integrations/apis integrations/client pkg/install/generated_templates.gogen.go | ||
check-generated: generate-deploy | ||
git diff --exit-code -- deploy/ | ||
|
||
build-docs: | ||
@cd docs && docker build -t flux-docs . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.