From c9ad2244b2cade652381a584ae31c349e5e4230c Mon Sep 17 00:00:00 2001 From: Chris Koehnke Date: Wed, 18 Mar 2020 14:23:40 -0400 Subject: [PATCH] Version bumping script enhancements Add the ability to switch the namespace and override versions to bump with using environment variables. --- helpers/bumper.py | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/helpers/bumper.py b/helpers/bumper.py index 2d05aa205..af5088c67 100755 --- a/helpers/bumper.py +++ b/helpers/bumper.py @@ -1,4 +1,16 @@ #!/usr/bin/env python2 + +# +# Usage: +# ./bumper.py +# +# Configurable environment variables: +# - BUMPER_VERSION_6 overrides the 6.x.x version. +# - BUMPER_VERSION_7 overrides the 7.x.x version. +# - BUMPER_USE_STAGING_IMAGES set to "true" causes the +# docker.elastic.co/staging/ docker registry namespace to be used. +# + import re import os import glob @@ -7,13 +19,13 @@ os.chdir(os.path.join(os.path.dirname(__file__), "..")) -chart_version = "7.6.1" - versions = { - 6: "6.8.7", - 7: "7.6.1", + 6: os.environ.get("BUMPER_VERSION_6", "6.8.7"), + 7: os.environ.get("BUMPER_VERSION_7", "7.6.1"), } +chart_version = versions[7] + file_patterns = [ "*/examples/*/test/goss*.y*ml", "*/examples/*/*.y*ml", @@ -40,3 +52,22 @@ print(r.sub(chart_version, line.rstrip())) else: print(r.sub(version, line.rstrip())) + +if os.environ.get("BUMPER_USE_STAGING_IMAGES") == "true": + image_file_patterns = file_patterns + [ + "*/tests/*.py", + "**/templates/*.tpl", + "**/Makefile", + ] + + for pattern in image_file_patterns: + for f in glob.glob(pattern): + print(f) + for line in fileinput.input([f], inplace=True): + print( + re.sub( + r"docker.elastic.co/.+/", + "docker.elastic.co/staging/", + line.rstrip(), + ) + )