# OpenStack metadata source selection
# vim:set filetype=sh:
# shellcheck shell=sh

. "$LIBDIR/tiny-cloud/configdrive"

_openstack_select_source() {
	configdrive_select_source openstack "${IMDS_FORMAT:-auto}" \
		"${IMDS_API_VERSION:-latest}"
}

# Disk metadata needs no bootstrap network; HTTP retains endpoint overrides.
_imds_targets() {
	local source
	source=$(_openstack_select_source) || return
	[ "$source" = http ] || return 0
	printf '%s\n' "$IMDS_ENDPOINTS"
}
