зеркало из https://github.com/microsoft/Oryx.git
modified update_constants.sh
This commit is contained in:
Родитель
5af2897002
Коммит
7a946a0603
|
@ -13,73 +13,44 @@ cat <<EOL > $constants_FILE
|
|||
variables:
|
||||
EOL
|
||||
|
||||
while IFS= read -r line; do
|
||||
# Use yq to parse the YAML line and extract the key and value
|
||||
key=$(echo "$line" | yq e 'keys' - | sed 's/^[[:space:]]*-*//' | sed 's/^[[:space:]]*//')
|
||||
update_constants_file() {
|
||||
while IFS= read -r line; do
|
||||
# Use yq to parse the YAML line and extract the key and value
|
||||
key=$(echo "$line" | yq e 'keys' - | sed 's/^[[:space:]]*-*//' | sed 's/^[[:space:]]*//')
|
||||
|
||||
value=$(echo "$line" | yq e '.[]' -)
|
||||
value=$(echo "$line" | yq e '.[]' -)
|
||||
|
||||
echo "Key: $key, Value: $value,"
|
||||
echo "Key: $key, Value: $value,"
|
||||
|
||||
keyInVariableGroup=$(echo "$key" | tr '[:lower:]' '[:upper:]')
|
||||
keyInVariableGroup=$(echo "$key" | tr '[:lower:]' '[:upper:]')
|
||||
|
||||
# Check if the key exists in the environment variables
|
||||
if printenv "$keyInVariableGroup" > /dev/null; then
|
||||
# If the key exists, get its value
|
||||
valueInVariableGroup=$(printenv "$keyInVariableGroup")
|
||||
echo "The value of $key is: $valueInVariableGroup"
|
||||
# Check if the key exists in the environment variables
|
||||
if printenv "$keyInVariableGroup" > /dev/null; then
|
||||
# If the key exists, get its value
|
||||
valueInVariableGroup=$(printenv "$keyInVariableGroup")
|
||||
echo "The value of $key is: $valueInVariableGroup"
|
||||
|
||||
if [ "$valueInVariableGroup" = "latest" ]; then
|
||||
yq eval ".variables.$key = \"$value\"" -i $constants_FILE
|
||||
echo "Updated constants.yml with latest value $key=$value"
|
||||
elif [ "$valueInVariableGroup" = "dont_change" ]; then
|
||||
old_value = $(yq eval ".$key" $Temp_constants_FILE)
|
||||
if [ "$valueInVariableGroup" = "latest" ]; then
|
||||
yq eval ".variables.$key = \"$value\"" -i $constants_FILE
|
||||
echo "Updated constants.yml with latest value $key=$value"
|
||||
elif [ "$valueInVariableGroup" = "dont_change" ]; then
|
||||
old_value=$(yq eval ".variables.$key" $Temp_constants_FILE)
|
||||
yq eval ".variables.$key = \"$old_value\"" -i $constants_FILE
|
||||
echo "constants.yml with old value $key=$old_value"
|
||||
else
|
||||
yq eval ".variables.$key = \"$valueInVariableGroup\"" -i $constants_FILE
|
||||
echo "Updated constants.yml with given value $key=$valueInVariableGroup"
|
||||
fi
|
||||
|
||||
else
|
||||
old_value=$(yq eval ".variables.$key" $Temp_constants_FILE)
|
||||
yq eval ".variables.$key = \"$old_value\"" -i $constants_FILE
|
||||
echo "constants.yml with old value $key=$old_value"
|
||||
else
|
||||
yq eval ".variables.$key = \"$valueInVariableGroup\"" -i $constants_FILE
|
||||
echo "Updated constants.yml with given value $key=$valueInVariableGroup"
|
||||
fi
|
||||
|
||||
else
|
||||
yq eval ".variables.$key = \"$value\"" -i $constants_FILE
|
||||
echo "Added $key = $value in constants.yml"
|
||||
fi
|
||||
done < <(yq e '.[]' "$1")
|
||||
}
|
||||
|
||||
done < <(yq e '.[]' "override_constants.yaml")
|
||||
|
||||
while IFS= read -r line; do
|
||||
# Use yq to parse the YAML line and extract the key and value
|
||||
key=$(echo "$line" | yq e 'keys' - | sed 's/^[[:space:]]*-*//' | sed 's/^[[:space:]]*//')
|
||||
value=$(echo "$line" | yq e '.[]' -)
|
||||
|
||||
echo "Key: $key, Value: $value,"
|
||||
|
||||
keyInVariableGroup=$(echo "$key" | tr '[:lower:]' '[:upper:]')
|
||||
|
||||
# Check if the key exists in the environment variables
|
||||
if printenv "$keyInVariableGroup" > /dev/null; then
|
||||
# If the key exists, get its value
|
||||
valueInVariableGroup=$(printenv "$keyInVariableGroup")
|
||||
echo "The value of $key is: $valueInVariableGroup"
|
||||
|
||||
if [ "$valueInVariableGroup" = "latest" ]; then
|
||||
yq eval ".variables.$key = \"$value\"" -i $constants_FILE
|
||||
echo "Updated constants.yml with latest value $key=$value"
|
||||
elif [ "$valueInVariableGroup" = "dont_change" ]; then
|
||||
old_value=$(yq eval ".$key" $Temp_constants_FILE)
|
||||
yq eval ".variables.$key = \"$old_value\"" -i $constants_FILE
|
||||
echo "constants.yml with old value $key=$old_value"
|
||||
else
|
||||
yq eval ".variables.$key = \"$valueInVariableGroup\"" -i $constants_FILE
|
||||
echo "Updated constants.yml with given value $key=$valueInVariableGroup"
|
||||
fi
|
||||
|
||||
else
|
||||
yq eval ".variables.$key = \"$value\"" -i $constants_FILE
|
||||
echo "Added $key = $value in constants.yml"
|
||||
fi
|
||||
|
||||
|
||||
done < <(yq e '.[]' "latest_stack_versions.yaml")
|
||||
update_constants_file "override_constants.yaml"
|
||||
update_constants_file "latest_stack_versions.yaml"
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче