forked from traefik/traefik-helm-chart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (82 loc) · 3.65 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
DIST_DIR ?= $(CURDIR)/dist
CHART_DIR ?= $(CURDIR)/traefik
TMPDIR ?= /tmp
HELM_REPO ?= $(CURDIR)/repo
LINT_USE_DOCKER ?= true
LINT_CMD ?= ct lint --config=lint/ct.yaml
PROJECT ?= github.com/traefik/traefik-helm-chart
################################## Functionnal targets
# Default Target: run all
all: clean test build deploy
test: lint unit-test
# Execute Static Testing
lint: lint-requirements
@echo "== Linting Chart..."
@git remote add traefik https://github.com/traefik/traefik-helm-chart >/dev/null 2>&1 || true
@git fetch traefik master >/dev/null 2>&1 || true
ifeq ($(LINT_USE_DOCKER),true)
@docker run --rm -t -v $(CURDIR):/charts -w /charts quay.io/helmpack/chart-testing:v3.5.0 $(LINT_CMD)
else
cd $(CHART_DIR)/tests && $(LINT_CMD)
endif
@echo "== Linting Finished"
# Execute Unit Testing
unit-test: helm-unittest
@echo "== Unit Testing Chart..."
@helm unittest --color --update-snapshot ./traefik
@echo "== Unit Tests Finished..."
# Generates an artifact containing the Helm Chart in the distribution directory
build: global-requirements $(DIST_DIR)
@echo "== Building Chart..."
@helm package $(CHART_DIR) --destination=$(DIST_DIR)
@echo "== Building Finished"
# Prepare the Helm repository with the latest packaged charts
deploy: global-requirements $(DIST_DIR) $(HELM_REPO)
@echo "== Deploying Chart..."
@rm -rf $(CURDIR)/gh-pages.zip
@curl -sSLO https://$(PROJECT)/archive/gh-pages.zip
@unzip -oj $(CURDIR)/gh-pages.zip -d $(HELM_REPO)/
@cp $(DIST_DIR)/*tgz $(CURDIR)/artifacthub-repo.yml $(HELM_REPO)/
@cp $(CURDIR)/README.md $(HELM_REPO)/index.md
@helm repo index --merge $(HELM_REPO)/index.yaml --url https://helm.traefik.io/traefik/ $(HELM_REPO)
@echo "== Deploying Finished"
# Cleanup leftovers and distribution dir
clean:
@echo "== Cleaning..."
@rm -rf $(DIST_DIR)
@rm -rf $(HELM_REPO)
@echo "== Cleaning Finished"
################################## Technical targets
$(DIST_DIR):
@mkdir -p $(DIST_DIR)
## This directory is git-ignored for now,
## and should become a worktree on the branch gh-pages in the future
$(HELM_REPO):
@mkdir -p $(HELM_REPO)
global-requirements:
@echo "== Checking global requirements..."
ifeq ($(LINT_USE_DOCKER),true)
@command -v docker >/dev/null || ( echo "ERROR: Docker binary not found. Exiting." && exit 1)
@docker info >/dev/null || ( echo "ERROR: command "docker info" is in error. Exiting." && exit 1)
else
@command -v helm >/dev/null || ( echo "ERROR: Helm binary not found. Exiting." && exit 1)
@command -v git >/dev/null || ( echo "ERROR: git binary not found. Exiting." && exit 1)
@echo "== Global requirements are met."
endif
lint-requirements: global-requirements
@echo "== Checking requirements for linting..."
ifeq ($(LINT_USE_DOCKER),true)
@command -v docker >/dev/null || ( echo "ERROR: Docker binary not found. Exiting." && exit 1)
@docker info >/dev/null || ( echo "ERROR: command "docker info" is in error. Exiting." && exit 1)
else
@command -v ct >/dev/null || ( echo "ERROR: ct binary not found. Exiting." && exit 1)
@command -v yamale >/dev/null || ( echo "ERROR: yamale binary not found. Exiting." && exit 1)
@command -v yamllint >/dev/null || ( echo "ERROR: yamllint binary not found. Exiting." && exit 1)
@command -v kubectl >/dev/null || ( echo "ERROR: kubectl binary not found. Exiting." && exit 1)
endif
@echo "== Requirements for linting are met."
helm-unittest: global-requirements
@echo "== Checking that plugin helm-unittest is available..."
@helm plugin list 2>/dev/null | grep unittest >/dev/null || helm plugin install https://github.com/rancher/helm-unittest --debug
@echo "== plugin helm-unittest is ready"
.PHONY: all global-requirements lint-requirements helm-unittest lint build deploy clean