Skip to content

Commit cae7cb2

Browse files
Default AWS_SDK_GO_VERSION to go.mod version (#137)
Issue #, if available: Fixes aws-controllers-k8s/community#878 Description of changes: Rather than defaulting to a set version of the AWS SDK, this pull request will read the `go.mod` in the service controller's repository and infer the `github.com/aws/aws-sdk-go` version. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 619ff29 commit cae7cb2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

scripts/build-controller-release.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ACK_GENERATE_BIN_PATH=${ACK_GENERATE_BIN_PATH:-$DEFAULT_ACK_GENERATE_BIN_PATH}
3333
ACK_GENERATE_API_VERSION=${ACK_GENERATE_API_VERSION:-"v1alpha1"}
3434
ACK_GENERATE_CONFIG_PATH=${ACK_GENERATE_CONFIG_PATH:-""}
3535
ACK_METADATA_CONFIG_PATH=${ACK_METADATA_CONFIG_PATH:-""}
36-
AWS_SDK_GO_VERSION=${AWS_SDK_GO_VERSION:-"v1.35.5"}
36+
AWS_SDK_GO_VERSION=${AWS_SDK_GO_VERSION:-""}
3737

3838
DEFAULT_TEMPLATES_DIR="$ROOT_DIR/../../aws-controllers-k8s/code-generator/templates"
3939
TEMPLATES_DIR=${TEMPLATES_DIR:-$DEFAULT_TEMPLATES_DIR}
@@ -85,7 +85,7 @@ Environment variables:
8585
Default: $ACK_GENERATE_SERVICE_ACCOUNT_NAME
8686
AWS_SDK_GO_VERSION: Overrides the version of github.com/aws/aws-sdk-go used
8787
by 'ack-generate' to fetch the service API Specifications.
88-
Default: $AWS_SDK_GO_VERSION
88+
Default: Version of aws/aws-sdk-go in service go.mod
8989
K8S_RBAC_ROLE_NAME: Name of the Kubernetes Role to use when
9090
generating the RBAC manifests for the
9191
custom resource definitions.
@@ -136,6 +136,10 @@ RELEASE_VERSION="$2"
136136
K8S_RBAC_ROLE_NAME=${K8S_RBAC_ROLE_NAME:-"ack-$SERVICE-controller"}
137137
ACK_GENERATE_SERVICE_ACCOUNT_NAME=${ACK_GENERATE_SERVICE_ACCOUNT_NAME:-"ack-$SERVICE-controller"}
138138

139+
if [ -z "$AWS_SDK_GO_VERSION" ]; then
140+
AWS_SDK_GO_VERSION=$(go list -m -f '{{ .Version }}' -modfile $SERVICE_CONTROLLER_SOURCE_PATH/go.mod github.com/aws/aws-sdk-go)
141+
fi
142+
139143
# If there's a generator.yaml in the service's directory and the caller hasn't
140144
# specified an override, use that.
141145
if [ -z "$ACK_GENERATE_CONFIG_PATH" ]; then

scripts/build-controller.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Environment variables:
5757
Default: metadata.yaml
5858
AWS_SDK_GO_VERSION: Overrides the version of github.com/aws/aws-sdk-go used
5959
by 'ack-generate' to fetch the service API Specifications.
60+
Default: Version of aws/aws-sdk-go in service go.mod
6061
TEMPLATES_DIR: Overrides the directory containg ack-generate templates
6162
Default: $TEMPLATES_DIR
6263
K8S_RBAC_ROLE_NAME: Name of the Kubernetes Role to use when generating
@@ -128,6 +129,10 @@ echo "Copying common custom resource definitions into $SERVICE"
128129
mkdir -p $config_output_dir/crd/common
129130
cp -r $RUNTIME_CRD_DIR/crd/* $config_output_dir/crd/common/
130131

132+
if [ -z "$AWS_SDK_GO_VERSION" ]; then
133+
AWS_SDK_GO_VERSION=$(go list -m -f '{{ .Version }}' -modfile $SERVICE_CONTROLLER_SOURCE_PATH/go.mod github.com/aws/aws-sdk-go)
134+
fi
135+
131136
# If there's a generator.yaml in the service's directory and the caller hasn't
132137
# specified an override, use that.
133138
if [ -z "$ACK_GENERATE_CONFIG_PATH" ]; then

0 commit comments

Comments
 (0)