-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1367 from dsalaza4/dsalazaratfluid
refac(back): #1364 simplify deploy container
- Loading branch information
Showing
5 changed files
with
89 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,55 @@ | ||
# shellcheck shell=bash | ||
|
||
function deploy { | ||
local attempts="${1}" | ||
local container_image="${2}" | ||
local credentials_token="${3}" | ||
local credentials_user="${4}" | ||
local tag="${5}" | ||
local credentials_token="${1}" | ||
local credentials_user="${2}" | ||
local image="${3}" | ||
local src="${4}" | ||
|
||
: && info Syncing container image: "${tag}" \ | ||
&& command=( | ||
skopeo | ||
--insecure-policy | ||
copy | ||
--dest-creds "${credentials_user}:${credentials_token}" | ||
"docker-archive://${container_image}" | ||
"docker://${tag}" | ||
) \ | ||
&& temp="$(mktemp)" \ | ||
&& seq 1 "${attempts}" > "${temp}" \ | ||
&& mapfile -t nums < "${temp}" \ | ||
&& for num in "${nums[@]}"; do | ||
if "${command[@]}"; then | ||
return 0 | ||
else | ||
info Retrying number "${num}" ... | ||
fi | ||
done \ | ||
&& return 1 \ | ||
|| return 1 | ||
: && info Syncing container image: "${image}" \ | ||
&& skopeo \ | ||
--insecure-policy \ | ||
copy \ | ||
--dest-creds "${credentials_user}:${credentials_token}" \ | ||
"docker-archive://${src}" \ | ||
"docker://${image}" | ||
} | ||
|
||
function sign { | ||
local credentials_token="${1}" | ||
local credentials_user="${2}" | ||
local registry="${3}" | ||
local image="${3}" | ||
local sign="${4}" | ||
local tag="${5}" | ||
|
||
if [ "${sign}" = "1" ]; then | ||
: && info "Signing container image: ${tag}" \ | ||
: && info "Signing container image: ${image}" \ | ||
&& cosign sign \ | ||
--yes=true \ | ||
--registry-username="${credentials_user}" \ | ||
--registry-password="${credentials_token}" \ | ||
"${tag}" | ||
"${image}" | ||
else | ||
: && info "Skipping signing container ${tag}" | ||
: && info "Skipping signing container ${image}" | ||
fi | ||
} | ||
|
||
function main { | ||
local attempts="__argAttempts__" | ||
local container_image="__argContainerImage__" | ||
local credentials_token="${__argCredentialsToken__}" | ||
local credentials_user="${__argCredentialsUser__}" | ||
local registry="__argRegistry__" | ||
local image="__argImage__" | ||
local sign="__argSign__" | ||
local tag="__argTag__" | ||
local src="__argSrc__" | ||
|
||
: && deploy \ | ||
"${attempts}" \ | ||
"${container_image}" \ | ||
"${credentials_token}" \ | ||
"${credentials_user}" \ | ||
"${tag}" \ | ||
"${image}" \ | ||
"${src}" \ | ||
&& sign \ | ||
"${credentials_token}" \ | ||
"${credentials_user}" \ | ||
"${registry}" \ | ||
"${sign}" \ | ||
"${tag}" | ||
"${image}" \ | ||
"${sign}" | ||
} | ||
|
||
main "${@}" |
Oops, something went wrong.