Skip to content

Commit

Permalink
fix(starship): set_helm_args accounts for multiple chains with script…
Browse files Browse the repository at this point in the history
… directives
  • Loading branch information
0xpatrickdev committed Oct 31, 2024
1 parent 726839b commit c0f9a73
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions multichain-testing/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function setup_helm() {
}

function set_helm_args() {
# Initialize args with existing flags
if [[ $TIMEOUT ]]; then
args="$args --timeout $TIMEOUT --wait --debug"
fi
Expand All @@ -56,24 +57,44 @@ function set_helm_args() {
if [[ $DRY_RUN ]]; then
args="$args --dry-run --debug"
fi

# Get number of chains (subtract 1 for 0-based index)
num_chains=$(yq -r ".chains | length - 1" ${CONFIGFILE})
if [[ $num_chains -lt 0 ]]; then
echo "No chains to parse: num: $num_chains"
return 0
echo "No chains found in config file"
return 1
fi

# Get the absolute path of the config file's directory
datadir="$(cd "$(dirname -- "${CONFIGFILE}")" > /dev/null && pwd -P)"

# Iterate through each chain
for i in $(seq 0 $num_chains); do
# Check if chain has scripts section
scripts=$(yq -r ".chains[$i].scripts" ${CONFIGFILE})
if [[ "$scripts" == "null" ]]; then
return 0
echo "No scripts found for chain $i"
continue # Skip to next chain instead of returning
fi
datadir="$(
cd "$(dirname -- "${CONFIGFILE}")" > /dev/null
pwd -P
)"
for script in $(yq -r ".chains[$i].scripts | keys | .[]" ${CONFIGFILE}); do
args="$args --set-file chains[$i].scripts.$script.data=$datadir/$(yq -r ".chains[$i].scripts.$script.file" ${CONFIGFILE})"
done

# Process each script for the current chain
while IFS= read -r script; do
if [[ -n "$script" ]]; then # Only process non-empty script names
script_file=$(yq -r ".chains[$i].scripts.$script.file" ${CONFIGFILE})
if [[ "$script_file" != "null" && -n "$script_file" ]]; then
full_path="$datadir/$script_file"
if [[ -f "$full_path" ]]; then
args="$args --set-file chains[$i].scripts.$script.data=$full_path"
echo "Added script $script for chain $i: $full_path"
else
echo "Warning: Script file not found: $full_path"
fi
fi
fi
done < <(yq -r ".chains[$i].scripts | keys | .[]" ${CONFIGFILE})
done

echo "Final helm args: $args"
}

function install_chart() {
Expand Down

0 comments on commit c0f9a73

Please sign in to comment.