Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lowercase bool variables values for consistency #16

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/bitops-config/converters/boolean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if [ -n "$DEEP_DEBUG" ]; then
fi

OUTPUT=""
if [ -z "$value" ] || [ "$value" == "" ] || [ "$value" == "False" ]; then
if [ -z "$value" ] || [ "$value" == "" ] || [ "$value" == "False" ] || [ "$value" == "false" ]; then
OUTPUT=""
elif [ "$value" == "True" ]; then
OUTPUT="${cli_flag}"
Expand Down
10 changes: 5 additions & 5 deletions scripts/helm_handle_chart.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ bash $SCRIPTS_DIR/before-deploy.sh "$HELM_CHART_DIRECTORY"

# set kube config
if [[ -z "$KUBECONFIG_BASE64" ]]; then
if [[ "${KUBE_CONFIG_PATH}" == "" ]] || [[ "${KUBE_CONFIG_PATH}" == "''" ]] || [[ "${KUBE_CONFIG_PATH}" == "None" ]]; then
if [[ "${FETCH_KUBECONFIG}" == "True" ]]; then
if [[ "${CLUSTER_NAME}" == "" ]] || [[ "${CLUSTER_NAME}" == "''" ]] || [[ "${CLUSTER_NAME}" == "None" ]]; then
if [[ "${KUBE_CONFIG_PATH}" == "" ]] || [[ "${KUBE_CONFIG_PATH}" == "''" ]] || [[ "${KUBE_CONFIG_PATH}" == "None" ]] || [[ "${KUBE_CONFIG_PATH}" == "none" ]]; then
if [[ "${FETCH_KUBECONFIG}" == "true" ]]; then
if [[ "${CLUSTER_NAME}" == "" ]] || [[ "${CLUSTER_NAME}" == "''" ]] || [[ "${CLUSTER_NAME}" == "None" ]] || [[ "${CLUSTER_NAME}" == "none" ]]; then
>&2 echo "{\"error\":\"CLUSTER_NAME config is required.Exiting...\"}"
exit 1
else
Expand All @@ -56,7 +56,7 @@ if [[ -z "$KUBECONFIG_BASE64" ]]; then
export h="helm --kubeconfig=$BITOPS_KUBE_CONFIG_FILE"
fi
else
if [[ "${FETCH_KUBECONFIG}" == "False" ]]; then
if [[ "${FETCH_KUBECONFIG}" == "false" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the conversation, this one is still coming uppercased.

The ENV var default is defined in the

helm/bitops.schema.yaml

Lines 69 to 71 in ecac7a1

type: boolean
default: true
export_env: FETCH_KUBECONFIG

The context is that Helm chart is using

core_schema_parsing: false

meaning bool var parsing is happening inside the Helm chart with some bash.

We'll need to ideally find the place where it's happening.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like in the helm pack shyaml tool is used for parsing the plugin schema

k="$(cat $SCHEMA_FILE | shyaml keys $rootkey)"

which probably converts bool values to the uppercase.

Worth the debugging here:

elif [ "$value" == "True" ]; then
OUTPUT="${cli_flag}"

default="$($SCRIPTS_DIR/bitops-config/get.sh $SCHEMA_FILE "${full_value_path_schema}.default")"

Copy link
Member

@arm4b arm4b Dec 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative approach is to throw away all this bash insanity https://github.com/bitops-plugins/helm/blob/main/scripts/bitops-config/convert-schema.sh and switch to (now fixed) core_schema_parsing: true

core_schema_parsing: false

>&2 echo "{\"error\":\"'kubeconfig' cannot be false when 'cluster-name' variable is defined in bitops.config.yaml.Exiting...\"}"
exit 1
fi
Expand Down Expand Up @@ -105,7 +105,7 @@ if [ -z $BITOPS_PLUGIN_NAME ]; then
fi

echo "Identify the default root folder for $HELM_CHART helm chart"
if [[ "${DEFAULT_DIR_FLAG}" == "True" ]]; then
if [[ "${DEFAULT_DIR_FLAG}" == "true" ]]; then
echo "Use 'opsrepo_root_default_dir' of bitops.config.yaml build config value for default root directory..."
export DEFAULT_HELM_ROOT="$BITOPS_TEMPDIR/$BITOPS_DEFAULT_ROOT_DIR/$BITOPS_PLUGIN_NAME"
else
Expand Down