Skip to content

Commit

Permalink
manifest etc
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Oct 25, 2024
1 parent 59dc4d4 commit de3da04
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ tasks:
- <<'EOF'
source {{.PROJECT_REPO_PATH}}/build.env
{{.CONSTRUCTOR_REPO_PATH}}/scripts/local/openstack_image_fetch.bash
EOF
EOF
post-install:
desc: post-install
13 changes: 10 additions & 3 deletions scripts/local/openstack_image_fetch.bash
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ function Openstack::Token::Get.id {
}

function Openstack::Image::Get.uuid {
local -r manifest_file_path="${1}"
local -r jq_filter='.["builds"][0]["artifact_id"]'

cat "${manifest_file_path}" \
| pkgx jq --raw-output "${jq_filter}"
}

function Openstack::Image::Get.name {
local -r manifest_file_path="${1}"
local -r jq_filter='.["builds"][0]["custom_data"]["BUILD_IMAGE_NAME"]'

cat "${manifest_file_path}" \
Expand Down Expand Up @@ -99,6 +101,7 @@ function Openstack::Image.fetch {

function main {
local -r manifest_file_path="${PKR_VAR_TARGET_IMAGE_MANIFEST}"

local -r openstack_cache_dir_path="${PROJECT_REPO_PATH}/.openstack-cache"

mkdir -p "${openstack_cache_dir_path}"
Expand All @@ -108,15 +111,19 @@ function main {
local -r http_unauthorized='401'
local curl_response_code=UNSET
local -r glance_api="$(Openstack::Image::API "${openstack_cache_dir_path}")"
local -r image_uuid="$(Openstack::Image::Get.uuid)"
local -r image_name="$(Openstack::Image::Get.name)"
local -r image_uuid="$(Openstack::Image::Get.uuid "${PROJECT_REPO_PATH}/manifest.json")"
local -r image_name="$(Openstack::Image::Get.name "${PROJECT_REPO_PATH}/manifest.json")"

#
# if we already have a cached token, try to use it
# otherwise re-issue a token
#

[ -z "$(cat $openstack_token_file_path | xargs )" ] && \
rm $openstack_token_file_path || echo "token file found"
test -f "${openstack_token_file_path}" \
|| Openstack::Token.issue "${openstack_token_file_path}"
|| Openstack::Token.issue "${openstack_token_file_path}"

#
#
#
Expand Down
2 changes: 1 addition & 1 deletion scripts/local/ssh_add.bash
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ function main {
ssh-add "${ssh_private_key_file_path}"
}

main
main

0 comments on commit de3da04

Please sign in to comment.