Skip to content

Commit

Permalink
charts: Generate versions from VERSION file
Browse files Browse the repository at this point in the history
Use the top-of-tree VERSION file to generate the chart versions and
update the pull policy using the following rules:

  * Set the helm chart versions to the VERSION in the file
  * If the VERSION file ends with ".90":
    - Set the cilium tag to 'latest'
    - Set the pullPolicy to 'Always'
  * If the VERSION file does not end with ".90":
    - Set the cilium tag to the VERSION in the file
    - Set the pullPolicy to 'IfNotPresent'
  * Set the managed-etcd version tag to the version specified at the top
    of this Makefile. This must be manually bumped, it does not appear
    to follow the standard Cilium docker image tag process.

Signed-off-by: Joe Stringer <joe@cilium.io>
  • Loading branch information
joestringer authored and aanm committed Feb 13, 2020
1 parent c4b6095 commit 640b7a6
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions install/kubernetes/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
QUICK_INSTALL=quick-install.yaml
include ../../Makefile.defs
include $(ROOT_DIR)/Makefile.quiet

all: $(QUICK_INSTALL)
MANAGED_ETCD_VERSION := "v2.0.7"

QUICK_INSTALL := "$(ROOT_DIR)/$(RELATIVE_DIR)/quick-install.yaml"
MANAGED_ETCD_PATH := "$(ROOT_DIR)/$(RELATIVE_DIR)/cilium/charts/managed-etcd/values.yaml"
CILIUM_CHARTS := "$(ROOT_DIR)/$(RELATIVE_DIR)/cilium/"
CILIUM_VALUES := "$(CILIUM_CHARTS)/values.yaml"

VERSION_REGEX := '[0-9]\+\.[0-9]\+\.[0-9]\+.*'
DEV_VERSION_REGEX := '[0-9]\+\.[0-9]\+\.90'
CILIUM_CHART_REGEX := '\([vV]ersion:\) '$(VERSION_REGEX)
CILIUM_TAG_REGEX := '\(tag:\) \(v'$(VERSION_REGEX)'\|latest\)'
CILIUM_PULLPOLICY_REGEX := '\(pullPolicy:\) .*'

all: update-versions $(QUICK_INSTALL)

$(QUICK_INSTALL): $(shell find cilium/ -type f)
helm template cilium --namespace=kube-system $(OPTS) > $(QUICK_INSTALL)
$(QUIET)helm template cilium --namespace=kube-system $(OPTS) > $(QUICK_INSTALL)

update-versions:
$(ECHO_GEN) " -> Updating version to $(VERSION)"
@# Update chart versions to point to the current version.
$(QUIET)grep -lRZ -e "version:" -e "appVersion:" $(CILIUM_CHARTS) | \
xargs -0 -l sed -i -e 's/'$(CILIUM_CHART_REGEX)'/\1 $(VERSION)/g'
@# Fix up the cilium tag
$(QUIET)if echo $(VERSION) | grep -q $(DEV_VERSION_REGEX); then \
sed -i 's/'$(CILIUM_TAG_REGEX)'/\1 latest/' $(CILIUM_VALUES); \
sed -i 's/'$(CILIUM_PULLPOLICY_REGEX)'/\1 Always/' $(CILIUM_VALUES); \
else \
sed -i 's/'$(CILIUM_TAG_REGEX)'/\1 v$(VERSION)/' $(CILIUM_VALUES); \
sed -i 's/'$(CILIUM_PULLPOLICY_REGEX)'/\1 IfNotPresent/' $(CILIUM_VALUES); \
fi
@# Fix up the managed etcd version, as that has its own scheme
$(QUIET)sed -i 's/'$(VERSION)'/'$(MANAGED_ETCD_VERSION)'/' $(MANAGED_ETCD_PATH)

clean:
$(RM) $(QUICK_INSTALL)

.phony: all clean update-versions

0 comments on commit 640b7a6

Please sign in to comment.