Skip to content

Commit

Permalink
fix for #25 and ibm classic legacy json fix
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtavian committed Feb 13, 2025
1 parent 2c5b0b1 commit a495b24
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 48 deletions.
39 changes: 35 additions & 4 deletions interact/account-helpers/hetzner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,45 @@ function hetznersetup(){
done

default_region=nbg1
echo -e "${BGreen}Listing regions${Color_Off}"

hcloud location list --output json | jq -r '
sort_by(.country)
| (["Name","Country","City"] | @tsv),
(.[]
| [ .name, .country, .city ]
| @tsv
)
' | column -t -s $'\t'

echo -e -n "${BGreen}Please enter your default region (you can always change this later with axiom-region select \$region): Default '$default_region', press enter \n>> ${Color_Off}"
read region
if [[ "$region" == "" ]]; then
if [[ "$region" == "" ]]; then
echo -e "${BGreen}Selected default option '$default_region'${Color_Off}"
region="$default_region"
fi
echo -e -n "${BGreen}Please enter your default size (you can always change this later with axiom-sizes select \$size): Default 'cx22', press enter \n>> ${Color_Off}"
read size
fi

echo -e "${BGreen}Listing Sizes${Color_Off}"
echo -e "${BYellow}Recommended Architecture: ${Color_Off}'${BGreen}x86${Color_Off}'${BYellow}. Pick a size that is available in region: ${Color_Off}'${BGreen}${region}${Color_Off}'${BYellow}.${Color_Off}"
hcloud server-type list --output json | jq -r '
[
"Name","Cores","Memory (GB)","Disk (GB)",
"CPU Type","Architecture","Price (€/Month)",
"Price (€/Hour)","Price per TB Traffic (€/TB)","Locations"
],
(
.[] | [
.name,.cores, .memory, .disk, .cpu_type, .architecture,
(.prices[0].price_monthly.net | tonumber),
(.prices[0].price_hourly.net | tonumber),
(.prices[0].price_per_tb_traffic.net | tonumber),
([ .prices[].location ] | unique | sort | join(", "))
]
)
| @tsv
' | iconv -c -t UTF-8 | column -t -s $'\t'
echo -e -n "${BGreen}Please enter your default size (you can always change this later with axiom-sizes select \$size): Default 'cx22', press enter \n>> ${Color_Off}"
read size
if [[ "$size" == "" ]]; then
echo -e "${BGreen}Selected default option 'cx22'${Color_Off}"
size="cx22"
Expand Down
56 changes: 30 additions & 26 deletions interact/axiom-build
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ done
#############################################################################################################
# IBM Cloud Classic specific logic here:
# Update legacy account config to use instance flavor instead of CPU/MEM
# Change packer version for IBM Cloud Classic
#
if [[ "$provider" == "ibm-classic" ]] || [[ "$provider" == "ibm" ]]; then

Expand All @@ -158,31 +157,6 @@ if [[ "$provider" == "ibm-classic" ]] || [[ "$provider" == "ibm" ]]; then
echo -e "${BYellow}You can always change this later by running ${Color_Off}'${BGreen}ax sizes ls${Color_Off}' ${BYellow}to list all sizes${Color_Off}"
echo -e "${BYellow}Then select a new default_size ${Color_Off}'${BGreen}ax sizes select \$size${Color_Off}'"
fi

if [[ "$extension" == "json" ]]; then
mkdir -p ~/.packer.d/plugins/
mkdir -p /tmp/packer-ibm/
if [[ ! -f /tmp/packer-ibm/packer ]] || [[ ! -f "$HOME/.packer.d/plugins/packer-builder-ibmcloud" ]]; then
if [[ $BASEOS == "Linux" ]]; then
wget -q -O /tmp/packer.zip https://releases.hashicorp.com/packer/1.5.6/packer_1.5.6_linux_amd64.zip && unzip -qq /tmp/packer.zip -d /tmp/packer-ibm/ && rm /tmp/packer.zip
wget -q https://github.com/IBM/packer-plugin-ibmcloud/releases/download/v1.0.1/packer-builder-ibmcloud_1.0.1_linux_64-bit.tar.gz -O - | tar -xz -C ~/.packer.d/plugins/
elif [[ $BASEOS == "Darwin" ]]; then
wget -q -O /tmp/packer.zip https://releases.hashicorp.com/packer/1.5.6/packer_1.5.6_darwin_amd64.zip && unzip -qq /tmp/packer.zip -d /tmp/packer-ibm/ && rm /tmp/packer.zip
wget -q https://github.com/IBM/packer-plugin-ibmcloud/releases/download/v1.0.1/packer-builder-ibmcloud_1.0.1_macOS_64-bit.tar.gz -O - | tar -xz -C ~/.packer.d/plugins/
fi
fi

BASEOS="$(uname)"
case $BASEOS in
'Darwin')
PATH="/tmp/packer-ibm/:$(brew --prefix coreutils)/libexec/gnubin:$PATH"
;;
'Linux')
PATH="/tmp/packer-ibm:$PATH"
;;
*) ;;
esac
fi
fi

############################################################################################################
Expand Down Expand Up @@ -268,6 +242,36 @@ if [ ! -f "$packer_builder_path" ]; then
fi
fi

#############################################################################################################
# Change packer version for IBM Cloud Classic
#
if [[ "$provider" == "ibm-classic" ]] || [[ "$provider" == "ibm" ]]; then
if [[ "$extension" == "json" ]]; then
mkdir -p ~/.packer.d/plugins/
mkdir -p /tmp/packer-ibm/
if [[ ! -f /tmp/packer-ibm/packer ]] || [[ ! -f "$HOME/.packer.d/plugins/packer-builder-ibmcloud" ]]; then
if [[ $BASEOS == "Linux" ]]; then
wget -q -O /tmp/packer.zip https://releases.hashicorp.com/packer/1.5.6/packer_1.5.6_linux_amd64.zip && unzip -qq /tmp/packer.zip -d /tmp/packer-ibm/ && rm /tmp/packer.zip
wget -q https://github.com/IBM/packer-plugin-ibmcloud/releases/download/v1.0.1/packer-builder-ibmcloud_1.0.1_linux_64-bit.tar.gz -O - | tar -xz -C ~/.packer.d/plugins/
elif [[ $BASEOS == "Darwin" ]]; then
wget -q -O /tmp/packer.zip https://releases.hashicorp.com/packer/1.5.6/packer_1.5.6_darwin_amd64.zip && unzip -qq /tmp/packer.zip -d /tmp/packer-ibm/ && rm /tmp/packer.zip
wget -q https://github.com/IBM/packer-plugin-ibmcloud/releases/download/v1.0.1/packer-builder-ibmcloud_1.0.1_macOS_64-bit.tar.gz -O - | tar -xz -C ~/.packer.d/plugins/
fi
fi

BASEOS="$(uname)"
case $BASEOS in
'Darwin')
PATH="/tmp/packer-ibm/:$(brew --prefix coreutils)/libexec/gnubin:$PATH"
;;
'Linux')
PATH="/tmp/packer-ibm:$PATH"
;;
*) ;;
esac
fi
fi

############################################################################################################
# Generate the Packer final provisioner by combining the Cloud Provider builder and provisioner file
#
Expand Down
36 changes: 18 additions & 18 deletions providers/hetzner-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -324,24 +324,24 @@ instance_id() {
# Used by ax sizes
#
sizes_list() {
hcloud server-type list --output json | jq -r '
["ID", "Name", "Description", "Cores", "Memory (GB)", "Disk (GB)", "Storage Type", "CPU Type", "Architecture", "Price (€/Month)", "Price (€/Hour)", "Price per TB Traffic (€/TB)"],
(.[]
| [
.id,
.name,
.description,
.cores,
.memory,
.disk,
.storage_type,
.cpu_type,
.architecture,
(.prices[0].price_monthly.net | tonumber),
(.prices[0].price_hourly.net | tonumber),
(.prices[0].price_per_tb_traffic.net | tonumber)
]) | @tsv
' | iconv -c -t UTF-8 | column -t -s $'\t'
hcloud server-type list --output json | jq -r '
[
"Name","Cores","Memory (GB)","Disk (GB)",
"CPU Type","Architecture","Price (€/Month)",
"Price (€/Hour)","Price per TB Traffic (€/TB)","Locations"
],
(
.[] | [
.name, .cores, .memory, .disk,
.cpu_type, .architecture,
(.prices[0].price_monthly.net | tonumber),
(.prices[0].price_hourly.net | tonumber),
(.prices[0].price_per_tb_traffic.net | tonumber),
([ .prices[].location ] | unique | sort | join(", "))
]
)
| @tsv
' | iconv -c -t UTF-8 | column -t -s $'\t'
}

###################################################################
Expand Down

0 comments on commit a495b24

Please sign in to comment.