Skip to content

Commit 480357a

Browse files
bin: generate tmp gpg key for init
1 parent 2234a1e commit 480357a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

scripts/sbom/sbom.bash

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ SBOM_FILE="${ROOT}/docs/sbom.json"
2121
SBOM_TEMPLATE_FILE="${ROOT}/docs/sbom.template.json"
2222

2323
# TODO: setting config path here to be able to source common.bash
24-
tmp_config_path=$(mktemp -d --suffix -config-path)
24+
tmp_config_path=$(mktemp -d --suffix -sbom-config-path)
2525
export CK8S_CONFIG_PATH="${tmp_config_path}"
2626

2727
# shellcheck source=bin/common.bash
2828
source "${ROOT}/bin/common.bash"
29+
append_trap "rm -rf ${tmp_config_path} >/dev/null 2>&1" EXIT
2930
# TODO: sources test scripts to set up new Welkin config, this could be generalized to not rely on test path
3031
source "${ROOT}/tests/common/bats/env.bash"
32+
source "${ROOT}/tests/common/bats/gpg.bash"
3133
source "${ROOT}/tests/common/bats/yq.bash"
32-
append_trap "rm -rf ${tmp_config_path} >/dev/null 2>&1" EXIT
3334

3435
usage() {
3536
echo "COMMANDS:" >&2
@@ -47,10 +48,12 @@ usage() {
4748
exit 1
4849
}
4950

50-
# TODO: currently requires CK8S_PGP_FP to be set, look into creating temp key similar to bats tests?
5151
init_welkin_config() {
52+
log_info "Initializing Welkin config used for generating Welkin"
5253
export PATH="${ROOT}/bin:${PATH}"
53-
env.setup
54+
gpg.setup_one >/dev/null 2>&1
55+
# append_trap "gpg.teardown" EXIT
56+
env.setup >/dev/null 2>&1
5457
env.init "${@}"
5558
}
5659

@@ -395,7 +398,7 @@ _generate_helmfile_template_file() {
395398

396399
# adds container images for a specific resource type and chart release based on its location to a input sbom file
397400
_add_container_images_from_template() {
398-
local location sbom_file template_file chart_name type query
401+
local chart_location chart_name chart_version location sbom_file template_file query
399402
sbom_file="${1}"
400403
template_file="${2}"
401404
chart="${3}"
@@ -454,7 +457,7 @@ _add_container_images_for_component() {
454457

455458
# loops over all charts included in the sbom and adds templated container images to a input sbom file
456459
_add_container_images() {
457-
local sbom_file
460+
local chart sbom_file template_file
458461
if [[ "$#" -lt 1 ]] || [[ "$#" -gt 2 ]]; then
459462
log_fatal "usage: _add_container_images <sbom-file>"
460463
fi

0 commit comments

Comments
 (0)