artifacts: include the artifact maps info (debs/packages) both as keys and values in the artifact JSON info

- this is valuable for the debs-to-repo process; we can now know which exact .debs are produced, and all the ways we can refer to them
This commit is contained in:
Ricardo Pardini 2023-05-09 13:48:11 +02:00
parent 234232085d
commit 1fa54e030d
1 changed files with 24 additions and 1 deletions

View File

@ -109,11 +109,20 @@ function obtain_complete_artifact() {
[[ "${artifact_version}" =~ ^${artifact_prefix_version} ]] || exit_with_error "artifact_version '${artifact_version}' does not begin with artifact_prefix_version '${artifact_prefix_version}'"
fi
declare -a artifact_map_debs_values=() artifact_map_packages_values=() artifact_map_debs_keys=() artifact_map_packages_keys=()
# validate artifact_type... it must be one of the supported types
case "${artifact_type}" in
deb | deb-tar)
# validate artifact_version begins with a digit
[[ "${artifact_version}" =~ ^[0-9] ]] || exit_with_error "${artifact_type}: artifact_version '${artifact_version}' does not begin with a digit"
# grab the the deb maps, and add them to plain arrays.
artifact_map_debs_keys=("${!artifact_map_debs[@]}")
artifact_map_debs_values=("${artifact_map_debs[@]}")
artifact_map_packages_keys=("${!artifact_map_packages[@]}")
artifact_map_packages_values=("${artifact_map_packages[@]}")
;;
tar.zst)
: # valid, no restrictions on tar.zst versioning
@ -171,12 +180,26 @@ function obtain_complete_artifact() {
artifact_final_file_basename
artifact_file_relative
artifact_full_oci_target
# arrays
artifact_map_debs_keys
artifact_map_debs_values
artifact_map_packages_keys
artifact_map_packages_values
)
declare -A ARTIFACTS_VAR_DICT=()
for var in "${wanted_vars[@]}"; do
ARTIFACTS_VAR_DICT["${var}"]="$(declare -p "${var}")"
declare declaration=""
declaration="$(declare -p "${var}")"
# Special handling for arrays. Syntax is not pretty, but works.
if [[ "${declaration}" =~ "declare -a" ]]; then
eval "declare ${var}_ARRAY=\"\${${var}[*]}\""
ARTIFACTS_VAR_DICT["${var}_ARRAY"]="$(declare -p "${var}_ARRAY")"
else
ARTIFACTS_VAR_DICT["${var}"]="${declaration}"
fi
done
display_alert "Dumping JSON" "for ${#ARTIFACTS_VAR_DICT[@]} variables" "ext"