Skip to content

Commit 5a886f9

Browse files
authored
Support default non-release version in build-controller-release.sh (#162)
Description of changes: * With the latest addition of presubmit 'release-test' job, service teams are required to execute 'build-controller-release.sh ' script for a successful PR build. 'build-controller-release.sh' script takes VERSION as required parameter. * Sagemaker team provided the feedback on how they do not want to worry about controller versions until they are doing an actual release. which is fair. * So this code change, introduces a default version 'v0.0.0-non-release-version' which allows for successful release-test for service teams without worrying about what VERSION to use until actual release. * This code change also adds the validation for the `VERSION` parameter. Why not use something like `git describe --tags --always --dirty` to generate version ? * The git command works in most cases if the repository already has a legit semver tag. If that is not the case then we need to add additional handling to create an actual semver tag. * Instead of dealing with all the edge cases with above command, having a static non-release version gets the job done. Because it is really just a placeholder value for the release-test execution. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 93f829b commit 5a886f9

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ build-ack-generate: ## Build ack-generate binary
2929
@echo "ok."
3030

3131
build-controller: build-ack-generate ## Generate controller code for SERVICE
32-
@./scripts/install-controller-gen.sh
32+
@./scripts/install-controller-gen.sh
33+
@echo "==== building $(AWS_SERVICE)-controller ===="
3334
@./scripts/build-controller.sh $(AWS_SERVICE)
35+
@echo "==== building $(AWS_SERVICE)-controller release artifacts ===="
36+
@./scripts/build-controller-release.sh $(AWS_SERVICE)
3437

3538
build-controller-image: export LOCAL_MODULES = false
3639
build-controller-image: ## Build container image for SERVICE

scripts/build-controller-release.sh

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,27 @@ TEMPLATES_DIR=${TEMPLATES_DIR:-$DEFAULT_TEMPLATES_DIR}
4141
DEFAULT_RUNTIME_DIR="$ROOT_DIR/../runtime"
4242
RUNTIME_DIR=${RUNTIME_DIR:-$DEFAULT_RUNTIME_DIR}
4343
RUNTIME_API_VERSION=${RUNTIME_API_VERSION:-"v1alpha1"}
44+
DEFAULT_RELEASE_VERSION="v0.0.0-non-release-version"
45+
# If the release version is not provided, use "v0.0.0-non-release-version".
46+
# This non-release version will allow generation of release artifacts and
47+
# executing presubmit 'release-test' job on those artifacts.
48+
# ACK postsubmit release job makes sure this version does not get released to
49+
# public ecr repository.
50+
#
51+
# Using a static non-release version works because this is only a placeholder
52+
# value which gets replaced during presubmit 'release-test' job. Having a
53+
# default non-release value also helps AWS service teams to develop the
54+
# controller without worrying about the version until actual controller
55+
# release.
56+
RELEASE_VERSION=${RELEASE_VERSION:-$DEFAULT_RELEASE_VERSION}
4457

4558
USAGE="
4659
Usage:
47-
$(basename "$0") <service> <release_version>
60+
$(basename "$0") <service>
4861
4962
<service> should be an AWS service API aliases that you wish to build -- e.g.
5063
's3' 'sns' or 'sqs'
5164
52-
<release_version> should be the SemVer version tag for the release -- e.g.
53-
'v0.1.3'
54-
5565
Environment variables:
5666
ACK_GENERATE_CACHE_DIR Overrides the directory used for caching
5767
AWS API models used by the ack-generate
@@ -90,10 +100,11 @@ Environment variables:
90100
generating the RBAC manifests for the
91101
custom resource definitions.
92102
Default: $K8S_RBAC_ROLE_NAME
103+
RELEASE_VERSION: SemVer version tag for the release.
104+
Default: v0.0.0-non-release-version
93105
"
94-
95-
if [ $# -ne 2 ]; then
96-
echo "ERROR: $(basename "$0") accepts exactly two parameters, the SERVICE and the RELEASE_VERSION" 1>&2
106+
if [ $# -ne 1 ]; then
107+
echo "ERROR: $(basename "$0") accepts only one required parameter, the SERVICE" 1>&2
97108
echo "$USAGE"
98109
exit 1
99110
fi
@@ -131,7 +142,15 @@ if [[ ! -d $SERVICE_CONTROLLER_SOURCE_PATH ]]; then
131142
exit 1
132143
fi
133144

134-
RELEASE_VERSION="$2"
145+
if [[ $RELEASE_VERSION != $DEFAULT_RELEASE_VERSION ]]; then
146+
# validate that release version is in the format vx.y.z , where x,y,z are
147+
# positive real numbers
148+
if ! (echo "$RELEASE_VERSION" | grep -Eq "^v[0-9]+\.[0-9]+\.[0-9]+$"); then
149+
echo "Release version should have following regex format: ^v[0-9]+\.[0-9]+\.[0-9]+$"
150+
exit 1
151+
fi
152+
fi
153+
135154
K8S_RBAC_ROLE_NAME=${K8S_RBAC_ROLE_NAME:-"ack-$SERVICE-controller"}
136155
ACK_GENERATE_SERVICE_ACCOUNT_NAME=${ACK_GENERATE_SERVICE_ACCOUNT_NAME:-"ack-$SERVICE-controller"}
137156

0 commit comments

Comments
 (0)