-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: env_name.txt to always have the used env name (IN-1895) #316
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,17 +17,14 @@ steps: | |
| - run: | ||
| name: Suspend Environment | ||
| command: | | ||
| echo "Contents of << parameters.env-name-path >>:" | ||
| cat << parameters.env-name-path >> | ||
| if [[ -f << parameters.env-name-path >> ]]; then | ||
| if [ -f << parameters.env-name-path >> ] && | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we use [[ ]] for safer shell scripting ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, i've been writing my scripts to be posix compliant for alpine shells, but we bash it up in CircleCI |
||
| [ -n "$(cat << parameters.env-name-path >> )" ] && | ||
| [ "$(cat << parameters.env-name-path >> )" != "null" ]; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, should we maybe just cat the env-name-path once. This block does reduce the lines of code. My suggestion here, more lines of code however we don't have to call cat twice
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup, we can do it in one, though instead of nesting i'd rather: |
||
|
|
||
| echo "Using env_name from file << parameters.env-name-path >> in the suspend action" | ||
| env_name=$(cat << parameters.env-name-path >>) | ||
| else | ||
| env_name="<< parameters.env-name >>" | ||
| fi | ||
| if [[ "$env_name" == "null" ]] || [[ -z "$env_name" ]]; then | ||
| # If env_name from file is "null" or empty, use the default parameter | ||
| env_name="<< parameters.env-name >>" | ||
| fi | ||
|
|
||
| vfcli env suspend "$env_name" --interactive false --wait --track-file "<< parameters.track-file >>" | ||
| echo "Using env: ${env_name-}" | ||
| vfcli env suspend "${env_name-}" --interactive false --wait --track-file "<< parameters.track-file >>" | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new logic cleanly simplifies things, however I am concerned that it drops most of the explicit signals we have encountered with several edge cases on circleCI
In the force case, it does not modify env_name.txt after its initial assignment. It doesn't ensure environment creation is forced. Also this comparism
[[ $(cat env_name.txt) != "<< parameters.env-name >>" ]]could lead to ambiguity in edge cases if << parameters.env-name >> is not set correctly or the file’s content is modifiedWe lose alot of the explict signals. I think in the early days of development, we noticed some weird behavior, hence, reason for the explicit signals. If we can have that with this simplified code, could help us overcome some edge case behavior in circleCI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so my thoughts around this are:
env_name.txtnot properly set (As it is only set in the above step)Here is a chart of logical outcomes from the previous logic:
I took this and simplified it to