Skip to content

Commit

Permalink
Add flux v2 makefile targets (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
uvegla committed Nov 9, 2023
1 parent bbc7a53 commit f6313f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Makefile.custom.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ download-upstream-crds: download-upstream-install $(YQ)
@echo "====> $@"
$(YQ) eval-all 'select(.kind == "CustomResourceDefinition")' output/flux-$(FLUX_VERSION).install.yaml > output/flux-$(FLUX_VERSION).crds.yaml

BUILD_CRD_TARGETS := build-common-crds build-flux-app-crds build-giantswarm-crds
BUILD_CRD_TARGETS := build-common-crds build-common-flux-v2-crds build-flux-app-crds build-flux-app-v2-crds build-giantswarm-crds

.PHONY: $(BUILD_CRD_TARGETS)
build-common-crds: ## Builds bases/crds/common
build-common-flux-v2-crds: ## Builds bases/crds/common-flux-v2
build-flux-app-crds: ## Builds bases/crds/flux-app
build-flux-app-v2-crds: ## Builds bases/crds/flux-app-v2
build-giantswarm-crds: ## Builds bases/crds/giantswarm
$(BUILD_CRD_TARGETS): $(KUSTOMIZE) ## Build CRDs
@echo "====> $@"
Expand Down
14 changes: 10 additions & 4 deletions bases/tools/Makefile.custom.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ARCH ?= $(shell go env GOARCH 2>/dev/null || echo amd64)
BUILD_CATALOG_TARGETS := $(addsuffix -catalogs, $(addprefix build-,$(notdir $(wildcard management-clusters/*))))
BUILD_MC_TARGETS := $(addprefix build-,$(notdir $(wildcard management-clusters/*)))

BUILD_CRD_TARGETS := build-common-crds build-flux-app-crds build-giantswarm-crds
BUILD_CRD_TARGETS := build-common-crds build-common-flux-v2-crds build-flux-app-crds build-flux-app-v2-crds build-giantswarm-crds

BUILD_FLUX_APP_TARGETS := build-flux-app-customer build-flux-app-giantswarm

Expand Down Expand Up @@ -50,7 +50,9 @@ $(BUILD_CATALOG_TARGETS): $(KUSTOMIZE) ## Build Giant Swarm catalogs for managem

.PHONY: $(BUILD_CRD_TARGETS)
build-common-crds: ## Builds https://github.com/giantswarm/management-cluster-bases//bases/crds/common
build-common-flux-v2-crds: ## Builds https://github.com/giantswarm/management-cluster-bases//bases/crds/common-flux-v2
build-flux-app-crds: ## Builds https://github.com/giantswarm/management-cluster-bases//bases/crds/flux-app
build-flux-app-v2-crds: ## Builds https://github.com/giantswarm/management-cluster-bases//bases/crds/flux-app-v2
build-giantswarm-crds: ## Builds https://github.com/giantswarm/management-cluster-bases//bases/crds/giantswarm
$(BUILD_CRD_TARGETS): $(KUSTOMIZE) ## Build CRDs
@echo "====> $@"
Expand All @@ -63,8 +65,8 @@ $(BUILD_CRD_TARGETS): $(KUSTOMIZE) ## Build CRDs
$(KUSTOMIZE) build --load-restrictor LoadRestrictionsNone /tmp/mcb.${MCB_BRANCH}/bases/crds/$(subst build-,,$(subst -crds,,$@)) -o output/$(subst build-,,$(subst -crds,,$@))-crds.yaml

.PHONY: $(BUILD_FLUX_APP_TARGETS)
build-flux-app-customer: ## Builds https://github.com/giantswarm/management-cluster-bases//bases/flux-app/customer. Can take DISABLE_KYVERNO=1 DISABLE_VPA=1 and FORCE_CRDS=1.
build-flux-app-giantswarm: ## Builds https://github.com/giantswarm/management-cluster-bases//bases/flux-app/giantswarm. Can take DISABLE_VPA=1.
build-flux-app-customer: ## Can take FLUX_MAJOR_VERSION=1|2|... DISABLE_KYVERNO=1 DISABLE_VPA=1 and FORCE_CRDS=1.
build-flux-app-giantswarm: ## Can take FLUX_MAJOR_VERSION=1|2|... DISABLE_VPA=1.
$(BUILD_FLUX_APP_TARGETS): SUFFIX = $(lastword $(subst -, ,$@))
$(BUILD_FLUX_APP_TARGETS): TMP_BASE = bases/flux-app-tmp-$(SUFFIX)
$(BUILD_FLUX_APP_TARGETS): $(KUSTOMIZE) $(HELM) $(YQ)
Expand All @@ -77,7 +79,11 @@ $(BUILD_FLUX_APP_TARGETS): $(KUSTOMIZE) $(HELM) $(YQ)

rm -rf $(TMP_BASE)

ifeq ($(FLUX_MAJOR_VERSION),1)
cp -a /tmp/mcb.${MCB_BRANCH}/bases/flux-app/${SUFFIX} $(TMP_BASE)
else
cp -a /tmp/mcb.${MCB_BRANCH}/bases/flux-app-v${FLUX_MAJOR_VERSION}/${SUFFIX} $(TMP_BASE)
endif

@# This will run extra yq calls if VAULTLESS=1
@$(MAKE) VAULTLESS=$(SUFFIX:giantswarm=1) TMP_BASE=$(TMP_BASE) build-flux-app-vaultless-helper
Expand All @@ -92,7 +98,7 @@ ifeq ($(FORCE_CRDS),1)
@# This makes sense only for build-flux-app-cluster, but makes no charm to other targets
$(YQ) e -i '(.helmCharts[] | select(.name == "flux-app") | .valuesInline.crds.install) = true' $(TMP_BASE)/kustomization.yaml
endif
$(KUSTOMIZE) build --load-restrictor LoadRestrictionsNone --enable-helm --helm-command="$(HELM)" $(TMP_BASE) -o output/flux-app-$(SUFFIX).yaml
$(KUSTOMIZE) build --load-restrictor LoadRestrictionsNone --enable-helm --helm-command="$(HELM)" $(TMP_BASE) -o output/flux-app-v${FLUX_MAJOR_VERSION}-$(SUFFIX).yaml
rm -rf $(TMP_BASE)

.PHONY: $(BUILD_MC_TARGETS)
Expand Down

0 comments on commit f6313f7

Please sign in to comment.