Skip to content

Commit

Permalink
Merge pull request #86 from aenix-io/83-refactor-makefiles
Browse files Browse the repository at this point in the history
Refactor Makefiles #83
  • Loading branch information
themoriarti authored Apr 17, 2024
2 parents 8a2ad90 + 12b70d8 commit fe5d607
Show file tree
Hide file tree
Showing 29 changed files with 67 additions and 223 deletions.
20 changes: 20 additions & 0 deletions hack/package-system.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.DEFAULT_GOAL=help
.PHONY=help show diff apply delete update image

help: ## Show this help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

show: ## Show output of rendered templates
kubectl get hr -n $(NAMESPACE) $(NAME) -o jsonpath='{.spec.values}' | helm template --dry-run=server -n $(NAMESPACE) $(NAME) . -f -

apply: suspend ## Apply Helm release to a Kubernetes cluster
kubectl get hr -n $(NAMESPACE) $(NAME) -o jsonpath='{.spec.values}' | helm upgrade -i -n $(NAMESPACE) $(NAME) . -f -

diff: ## Diff Helm release against objects in a Kubernetes cluster
kubectl get hr -n $(NAMESPACE) $(NAME) -o jsonpath='{.spec.values}' | helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) . -f -

suspend: ## Suspend reconciliation for an existing Helm release
flux suspend hr -n $(NAMESPACE) $(NAME)

resume: ## Resume reconciliation for an existing Helm release
flux resume hr -n $(NAMESPACE) $(NAME)
2 changes: 1 addition & 1 deletion packages/core/fluxcd/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAMESPACE=cozy-fluxcd
NAME=fluxcd
NAMESPACE=cozy-$(NAME)

API_VERSIONS_FLAGS=$(addprefix -a ,$(shell kubectl api-versions))

Expand Down
2 changes: 1 addition & 1 deletion packages/core/installer/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAMESPACE=cozy-system
NAME=installer
NAMESPACE=cozy-system
PUSH := 1
LOAD := 0
REGISTRY := ghcr.io/aenix-io/cozystack
Expand Down
2 changes: 1 addition & 1 deletion packages/core/platform/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAMESPACE=cozy-system
NAME=platform
NAMESPACE=cozy-system

API_VERSIONS_FLAGS=$(addprefix -a ,$(shell kubectl api-versions))

Expand Down
9 changes: 1 addition & 8 deletions packages/system/capi-operator/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=capi-operator
NAMESPACE=cozy-cluster-api

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf charts
Expand Down
9 changes: 1 addition & 8 deletions packages/system/capi-providers/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
NAME=capi-providers
NAMESPACE=cozy-cluster-api

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
9 changes: 1 addition & 8 deletions packages/system/cert-manager-issuers/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
NAME=cert-manager-issuers
NAMESPACE=cozy-cert-manager

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
11 changes: 2 additions & 9 deletions packages/system/cert-manager/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=cert-manager
NAMESPACE=cozy-cert-manager
NAMESPACE=cozy-$(NAME)

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf charts
Expand Down
11 changes: 2 additions & 9 deletions packages/system/cilium/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAMESPACE=cozy-cilium
NAME=cilium
NAMESPACE=cozy-$(NAME)

show:
kubectl get hr -n cozy-cilium cilium -o jsonpath='{.spec.values}' | helm template --dry-run=server -n $(NAMESPACE) $(NAME) . -f -

apply:
kubectl get hr -n cozy-cilium cilium -o jsonpath='{.spec.values}' | helm upgrade -i -n $(NAMESPACE) $(NAME) . -f -

diff:
kubectl get hr -n cozy-cilium cilium -o jsonpath='{.spec.values}' | helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) . -f -
include ../../hack/package-system.mk

update:
rm -rf charts
Expand Down
9 changes: 1 addition & 8 deletions packages/system/clickhouse-operator/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=clickhouse-operator
NAMESPACE=cozy-clickhouse-operator

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf charts
Expand Down
11 changes: 2 additions & 9 deletions packages/system/dashboard/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
NAME=dashboard
NAMESPACE=cozy-dashboard
NAMESPACE=cozy-$(NAME)
PUSH := 1
LOAD := 0
REPOSITORY := ghcr.io/aenix-io/cozystack
TAG := v0.2.0

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update: update-chart update-dockerfiles
image: image-dashboard image-kubeapps-apis
Expand Down
9 changes: 1 addition & 8 deletions packages/system/grafana-operator/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=grafana-operator
NAMESPACE=cozy-grafana-operator

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf charts
Expand Down
11 changes: 2 additions & 9 deletions packages/system/ingress-nginx/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=ingress-nginx
NAMESPACE=cozy-ingress-nginx
NAMESPACE=cozy-$(NAME)

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf charts
Expand Down
11 changes: 2 additions & 9 deletions packages/system/kafka-operator/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=kafka-operator
NAMESPACE=cozy-kafka-operator
NAMESPACE=cozy-$(NAME)

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf charts
Expand Down
12 changes: 2 additions & 10 deletions packages/system/kamaji/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
NAME=kamaji
NAMESPACE=cozy-kamaji
NAMESPACE=cozy-$(NAME)

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
flux suspend hr kamaji -n cozy-kamaji || true
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf charts
Expand Down
11 changes: 2 additions & 9 deletions packages/system/kubeovn/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAMESPACE=cozy-kubeovn
NAME=kubeovn
NAMESPACE=cozy-$(NAME)

show:
kubectl get hr -n $(NAMESPACE) $(NAME) -o jsonpath='{.spec.values}' | helm template --dry-run=server -n $(NAMESPACE) $(NAME) . -f -

apply:
kubectl get hr -n $(NAMESPACE) $(NAME) -o jsonpath='{.spec.values}' | helm upgrade -i -n $(NAMESPACE) $(NAME) . -f -

diff:
kubectl get hr -n $(NAMESPACE) $(NAME) -o jsonpath='{.spec.values}' | helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) . -f -
include ../../hack/package-system.mk

update:
rm -rf charts && mkdir -p charts/kube-ovn
Expand Down
9 changes: 1 addition & 8 deletions packages/system/kubevirt-cdi-operator/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=kubevirt-cdi-operator
NAMESPACE=cozy-kubevirt-cdi

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf templates
Expand Down
11 changes: 2 additions & 9 deletions packages/system/kubevirt-cdi/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=kubevirt-cdi
NAMESPACE=cozy-kubevirt-cdi
NAMESPACE=cozy-$(NAME)

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf templates
Expand Down
11 changes: 2 additions & 9 deletions packages/system/kubevirt-operator/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
NAME=kubevirt-operator
NAMESPACE=cozy-kubevirt

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf templates
mkdir templates
export RELEASE=$$(curl https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt) && \
wget https://github.com/kubevirt/kubevirt/releases/download/$${RELEASE}/kubevirt-operator.yaml -O templates/kubevirt-operator.yaml && \
sed -i 's/namespace: kubevirt/namespace: cozy-kubevirt/g' templates/kubevirt-operator.yaml
sed -i 's/namespace: kubevirt/namespace: $(NAMESPACE)/g' templates/kubevirt-operator.yaml
awk -i inplace -v RS="---" '!/kind: Namespace/{printf "%s", $$0 RS}' templates/kubevirt-operator.yaml
11 changes: 2 additions & 9 deletions packages/system/kubevirt/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=kubevirt
NAMESPACE=cozy-kubevirt
NAMESPACE=cozy-$(NAME)

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf templates
Expand Down
11 changes: 2 additions & 9 deletions packages/system/linstor/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
NAME=linstor
NAMESPACE=cozy-linstor
NAMESPACE=cozy-$(NAME)

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
11 changes: 2 additions & 9 deletions packages/system/mariadb-operator/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=mariadb-operator
NAMESPACE=cozy-mariadb-operator
NAMESPACE=cozy-$(NAME)

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf charts
Expand Down
11 changes: 2 additions & 9 deletions packages/system/metallb/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=metallb
NAMESPACE=cozy-metallb
NAMESPACE=cozy-$(NAME)

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf charts
Expand Down
11 changes: 2 additions & 9 deletions packages/system/monitoring/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=monitoring
NAMESPACE=cozy-monitoring
NAMESPACE=cozy-$(NAME)

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf charts
Expand Down
11 changes: 2 additions & 9 deletions packages/system/postgres-operator/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
NAME=postgres-operator
NAMESPACE=cozy-postgres-operator
NAMESPACE=cozy-$(NAME)

show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .

apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .

diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

update:
rm -rf charts
Expand Down
Loading

0 comments on commit fe5d607

Please sign in to comment.