Skip to content

Commit a464161

Browse files
authored
cache compressed versions of the kots and embedded-cluster-operator binaries (#720)
* cache compressed versions of the kots and embedded-cluster-operator binaries * check new location for file presence * upload a file that actually exists
1 parent cc92043 commit a464161

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

cmd/embedded-cluster/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ func gatherVersionMetadata() (*types.ReleaseMetadata, error) {
106106
}
107107

108108
artifacts := map[string]string{
109-
"kots": fmt.Sprintf("kots-binaries/%s", adminconsole.KotsVersion),
110-
"operator": fmt.Sprintf("operator-binaries/%s", embeddedclusteroperator.Version),
109+
"kots": fmt.Sprintf("kots-binaries/%s.tar.gz", adminconsole.KotsVersion),
110+
"operator": fmt.Sprintf("operator-binaries/%s.tar.gz", embeddedclusteroperator.Version),
111111
"local-artifact-mirror-image": defaults.LocalArtifactMirrorImage,
112112
}
113113

scripts/cache-files.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function operatorbin() {
7272

7373
# check if the binary already exists in the bucket
7474
local operator_binary_exists=
75-
operator_binary_exists=$(aws s3api head-object --bucket "${S3_BUCKET}" --key "operator-binaries/${operator_version}" || true)
75+
operator_binary_exists=$(aws s3api head-object --bucket "${S3_BUCKET}" --key "operator-binaries/${operator_version}.tar.gz" || true)
7676

7777
# if the binary already exists, we don't need to upload it again
7878
if [ -n "${operator_binary_exists}" ]; then
@@ -84,8 +84,13 @@ function operatorbin() {
8484
echo "downloading embedded cluster operator binary from https://github.com/replicatedhq/embedded-cluster-operator/releases/download/v${operator_version}/manager"
8585
curl --fail-with-body -L -o "${operator_version}" "https://github.com/replicatedhq/embedded-cluster-operator/releases/download/v${operator_version}/manager"
8686

87+
chmod +x "${operator_version}"
88+
89+
# compress the operator binary
90+
tar -czf "${operator_version}.tar.gz" "${operator_version}"
91+
8792
# upload the binary to the bucket
88-
retry 3 aws s3 cp "${operator_version}" "s3://${S3_BUCKET}/operator-binaries/${operator_version}"
93+
retry 3 aws s3 cp "${operator_version}.tar.gz" "s3://${S3_BUCKET}/operator-binaries/${operator_version}.tar.gz"
8994
}
9095

9196
function kotsbin() {
@@ -100,7 +105,7 @@ function kotsbin() {
100105

101106
# check if the binary already exists in the bucket
102107
local kots_binary_exists=
103-
kots_binary_exists=$(aws s3api head-object --bucket "${S3_BUCKET}" --key "kots-binaries/${kots_version}" || true)
108+
kots_binary_exists=$(aws s3api head-object --bucket "${S3_BUCKET}" --key "kots-binaries/${kots_version}.tar.gz" || true)
104109

105110
# if the binary already exists, we don't need to upload it again
106111
if [ -n "${kots_binary_exists}" ]; then
@@ -117,11 +122,8 @@ function kotsbin() {
117122
curl --fail-with-body -L -o "kots_linux_amd64.tar.gz" "https://github.com/replicatedhq/kots/releases/download/${kots_version}/kots_linux_amd64.tar.gz"
118123
fi
119124

120-
# decompress the bundle, as we only care about the binary and not the sbom/license/readme
121-
tar -xvf kots_linux_amd64.tar.gz
122-
123125
# upload the binary to the bucket
124-
retry 3 aws s3 cp "kots" "s3://${S3_BUCKET}/kots-binaries/${kots_version}"
126+
retry 3 aws s3 cp "kots_linux_amd64.tar.gz" "s3://${S3_BUCKET}/kots-binaries/${kots_version}.tar.gz"
125127
}
126128

127129
function metadata() {

0 commit comments

Comments
 (0)