@@ -62,13 +62,15 @@ function Openstack::Token::Get.id {
6262}
6363
6464function Openstack::Image::Get.uuid {
65+ local -r manifest_file_path=" ${1} "
6566 local -r jq_filter=' .["builds"][0]["artifact_id"]'
6667
6768 cat " ${manifest_file_path} " \
6869 | pkgx jq --raw-output " ${jq_filter} "
6970}
7071
7172function Openstack::Image::Get.name {
73+ local -r manifest_file_path=" ${1} "
7274 local -r jq_filter=' .["builds"][0]["custom_data"]["BUILD_IMAGE_NAME"]'
7375
7476 cat " ${manifest_file_path} " \
@@ -99,6 +101,7 @@ function Openstack::Image.fetch {
99101
100102function main {
101103 local -r manifest_file_path=" ${PKR_VAR_TARGET_IMAGE_MANIFEST} "
104+
102105 local -r openstack_cache_dir_path=" ${PROJECT_REPO_PATH} /.openstack-cache"
103106
104107 mkdir -p " ${openstack_cache_dir_path} "
@@ -108,15 +111,19 @@ function main {
108111 local -r http_unauthorized=' 401'
109112 local curl_response_code=UNSET
110113 local -r glance_api=" $( Openstack::Image::API " ${openstack_cache_dir_path} " ) "
111- local -r image_uuid=" $( Openstack::Image::Get.uuid) "
112- local -r image_name=" $( Openstack::Image::Get.name) "
114+ local -r image_uuid=" $( Openstack::Image::Get.uuid " ${PROJECT_REPO_PATH} /manifest.json " ) "
115+ local -r image_name=" $( Openstack::Image::Get.name " ${PROJECT_REPO_PATH} /manifest.json " ) "
113116
114117 #
115118 # if we already have a cached token, try to use it
116119 # otherwise re-issue a token
117120 #
121+
122+ [ -z " $( cat $openstack_token_file_path | xargs ) " ] && \
123+ rm $openstack_token_file_path || echo " token file found"
118124 test -f " ${openstack_token_file_path} " \
119- || Openstack::Token.issue " ${openstack_token_file_path} "
125+ || Openstack::Token.issue " ${openstack_token_file_path} "
126+
120127 #
121128 #
122129 #
0 commit comments