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

Adding skip-deploy bitops configuration option #13

Merged
merged 6 commits into from
Nov 10, 2022
Merged

Conversation

PhillypHenning
Copy link
Contributor

Updating the README with the skip-deploy action

Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

Looks like the older version SKIP_DEPLOY is listed in the docs, will need updating too:
https://bitops.sh/tool-configuration/configuration-helm/#options-configuration

* **Environment Variable:** `HELM_SKIP_DEPLOY`
* **default:** `none`
* **Required:** `false`
* **Description:** If set to true, regardless of the stack-action, deployment actions will be skipped.
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 it's not true, but True upper-case per code here:

# Check for helm skip deploy condition
if [ "$HELM_SKIP_DEPLOY" == "True" ]; then
echo "helm.options.skip-deploy (HELM_SKIP_DEPLOY) set. Skipping deployment for $ENVIRONMENT/helm/$HELM_CHART"
exit 0
fi

Sounds like a bug? I see we use true lowercase for other plugins.

README.md Outdated
will skip helm execution
* **Environment Variable:** `HELM_SKIP_DEPLOY`
* **default:** `none`
* **Required:** `false`
Copy link
Member

Choose a reason for hiding this comment

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

I see only one config setting namespace in this README mentions the required.

Do we really need to list the required property? What's the convention we'd like to go with?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All other documentation has the "required" flag. Defaults to false.

How did you want to handle this?

@arm4b arm4b added the documentation Improvements or additions to documentation label Nov 9, 2022
@PhillypHenning PhillypHenning changed the title Updating README skip-deploy option Adding skip-deploy bitops configuration option Nov 10, 2022
@PhillypHenning
Copy link
Contributor Author

Adding "tolowercase" before check to ensure standard input

test.sh

HELM_SKIP_DEPLOY=$1

SANITIZED_HELM_SKIP_DEPLOY=$(echo "$HELM_SKIP_DEPLOY" | tr '[:upper:]' '[:lower:]')

if [ "$SANITIZED_HELM_SKIP_DEPLOY" == "true" ]; then
    echo "helm.options.skip-deploy (HELM_SKIP_DEPLOY) set.  Skipping deployment for $ENVIRONMENT/helm/$HELM_CHART"
    exit 0
fi

output

[Bitovi] [helm] $ ./test.sh True
helm.options.skip-deploy (HELM_SKIP_DEPLOY) set.  Skipping deployment for /helm/

@PhillypHenning
Copy link
Contributor Author

bitops.sh doc updated
bitovi/bitops#354

Comment on lines 19 to 20
if [ "$HELM_SKIP_DEPLOY" == "True" ]; then
SANITIZED_HELM_SKIP_DEPLOY=$(echo "$HELM_SKIP_DEPLOY" | tr '[:upper:]' '[:lower:]')
if [ "$SANITIZED_HELM_SKIP_DEPLOY" == "true" ]; then
Copy link
Member

@arm4b arm4b Nov 10, 2022

Choose a reason for hiding this comment

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

This works for $HELM_SKIP_DEPLOY, but doesn't scale well as there are many ENV vars in the script, and doing it only for one var but leaving others broken is not consistent. Also, there might be other plugins having the same issue.

Just look below, there are many such vars in this script:

if [[ "${FETCH_KUBECONFIG}" == "True" ]]; then

The ideal approach would be:
Creating a bash function, list all the boolean-type ENV vars and apply a lowercase function for all of them.
For scaling out, because this function should be common for all the plugins, we can create a repo with bash libs we can share via git submodule with all the plugins. It may be a home for other reusable helpers like color support, different logging levels, casting 0,1,yes,no to "bool" string and so on.

With that,
The simple approach with a filter for a single var is not enough as we fix bug only for one var.
The second overhaul approach is too much for the current PR scope.


For now the pragmatic way I think is just to change True -> true in the code and call it done. Considering the level of current adoption and the fact that lowercase was documented it should be OK.
We just need to keep in mind to use lowercase true/false in the future where possible. Worth checking other scripts and vars for the same bug.

For the future we can document an enhancement creating a shared repo with bash helpers.

@PhillypHenning WDYT?

Copy link
Contributor Author

@PhillypHenning PhillypHenning Nov 10, 2022

Choose a reason for hiding this comment

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

I agree and have already applied the same sanity check for the SKIP_DEPLOY option across all plugins. I agree that the scope of this PR isn't enough to make the large scale change you're mentioning.

Finally - this is a change that only needs to be done and noted ON OUR SIDE. From the client perspective, they shouldn't know about the sanitation we do. I.E this doesn't need doc updates

@PhillypHenning PhillypHenning merged commit 011ab6b into main Nov 10, 2022
@arm4b arm4b deleted the skip-deploy-doc branch November 10, 2022 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants