Skip to content

Commit 5ae6249

Browse files
committed
[DEX] Add possibility in 'upload-cookbook.sh' to specify an optional scope to disambiguate different cookbooks for the same version.
Signed-off-by: Giacomo Marciani <[email protected]>
1 parent 7eb840f commit 5ae6249

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

util/upload-cookbook.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ _help() {
2424
--profile <aws-profile> AWS profile name to use for the upload
2525
(optional, default is AWS_PROFILE env variable or "default")
2626
--region <aws-region> Region to use for AWSCli commands (optional, default is "us-east-1")
27+
--scope <string> Disambiguation string used in the S3 path to avoid collisions (default is empty)
2728
-h, --help Print this help message
2829
EOF
2930
}
@@ -40,6 +41,8 @@ main() {
4041
--profile=*) _profile="${1#*=}";;
4142
--region) _region="$2"; shift;;
4243
--region=*) _region="${1#*=}";;
44+
--scope) _scope="$2"; shift;;
45+
--scope=*) _scope="${1#*=}";;
4346
-h|--help|help) _help; exit 0;;
4447
*) _help; echo "[error] Unrecognized option '$1'"; exit 1;;
4548
esac
@@ -66,6 +69,10 @@ main() {
6669
_info "--region parameter not specified, using 'us-east-1'"
6770
_region="us-east-1"
6871
fi
72+
if [ -z "${_scope}" ]; then
73+
_info "--scope parameter not specified, no scope will be used"
74+
_scope=""
75+
fi
6976

7077
# check bucket or create it
7178
aws ${_profile} s3api head-bucket --bucket "${_bucket}" --region "${_region}"
@@ -94,6 +101,9 @@ main() {
94101

95102
# upload packages
96103
_key_path="parallelcluster/${_version}/cookbooks"
104+
if [ -n "${_scope}" ]; then
105+
_key_path="${_key_path}/${_scope}"
106+
fi
97107
aws ${_profile} --region "${_region}" s3 cp aws-parallelcluster-cookbook-${_version}.tgz s3://${_bucket}/${_key_path}/aws-parallelcluster-cookbook-${_version}.tgz || _error_exit 'Failed to push cookbook to S3'
98108
aws ${_profile} --region "${_region}" s3 cp aws-parallelcluster-cookbook-${_version}.md5 s3://${_bucket}/${_key_path}/aws-parallelcluster-cookbook-${_version}.md5 || _error_exit 'Failed to push cookbook md5 to S3'
99109
aws ${_profile} --region "${_region}" s3api head-object --bucket ${_bucket} --key ${_key_path}/aws-parallelcluster-cookbook-${_version}.tgz --output text --query LastModified > aws-parallelcluster-cookbook-${_version}.tgz.date || _error_exit 'Failed to fetch LastModified date'

0 commit comments

Comments
 (0)