forked from fluidattacks/makes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refac(back): fluidattacks#1364 simplify deploy container
- Make it simpler and consistent with deployContainerManifest - Remove `images` option in favor of a flat approach - Remove attempts logic for simplicity - Update documentation Signed-off-by: Daniel Salazar <podany270895@gmail.com>
- Loading branch information
Showing
5 changed files
with
91 additions
and
192 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}" \ | ||
"${credentials_token}" \ | ||
"${credentials_user}" \ | ||
"${image}" \ | ||
"${src}" \ | ||
&& sign \ | ||
"${credentials_token}" \ | ||
"${credentials_user}" \ | ||
"${registry}" \ | ||
"${sign}" \ | ||
"${tag}" | ||
"${image}" \ | ||
"${sign}" | ||
} | ||
|
||
main "${@}" |
Oops, something went wrong.