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

Add "APPNAME" headings in .env, and move the "migrate" logic into appvars_create.sh #1745

Open
wants to merge 76 commits into
base: variable-naming
Choose a base branch
from

Conversation

CLHatch
Copy link
Contributor

@CLHatch CLHatch commented Mar 20, 2024

Add headings for each app in the .env in the form of:

#
# APPNAME
#

Pull request

Purpose
Describe the problem or feature in addition to a link to the issues.

Approach
How does this change address the problem?

Open Questions and Pre-Merge TODOs
Check all boxes as they are completed

  • Use github checklists. When solved, check the box and explain the answer.

Learning
Describe the research stage
Links to blog posts, patterns, libraries or addons used to solve this problem

Requirements
Check all boxes as they are completed

Add headings for each app in the .env in the form of:

#
# APPNAME
#
@CLHatch CLHatch requested a review from a team as a code owner March 20, 2024 07:49
@github-actions github-actions bot added the core Automatic label label Mar 20, 2024
Fix indenting
Remove extra spaces to pass linting
Move `APPNAME` != `LAST_APPNAME` test to avoid issues with global variables.
Remove extra spaces to pass linting again.
Add an extra line after the "Global settings", so there's a blank line before the first application variable comment.
@CLHatch CLHatch requested a review from a team as a code owner March 20, 2024 08:34
@github-actions github-actions bot added the apps Automatic label label Mar 20, 2024
@CLHatch CLHatch changed the title Update env_update.sh Add "APPNAME" headings in .env Mar 20, 2024
Add `# APPNAME` and `# APPNAME (User Defined)` headings to .env file.

Change logic to files into arrays and search the arrays instead of reading line by line.
Remove whitespace on blank line
Use `inArray "element" "array"` to check if an element is in an array (fixes "deluge" matching "delugevpn").

Clear `APP_LABEL_LIST` array when a new app is iterated to the `.env` file.
Fix shellcheck errors.
Fix some shellcheck warnings.
Fix more shellcheck warnings.
Fix shell check warning for `'ls`
Fix `shfmt` errors
Fix `shfmt` error
Fix index variable when unsetting element of an array.
Removes `appvars_migrate.sh` and`appvars_migrate_all.sh`.
Migration is done in `appvars_create.sh` if it sees existing variables to be migrated.  Tries to handle not migrating from variables such as `<APPNAME>_PORT_####`, `<APPNAME>_RESTART``, etc.
Fix linting errors.
Check to be sure the the potentially migrated variable name isn't an existing label for the app, instead of using a hardcoded list of exclusions.
Fix linting error
@CLHatch CLHatch changed the title Add "APPNAME" headings in .env Add "APPNAME" headings in .env, and move the "migrate" logic into appvars_create.sh Mar 24, 2024
Use an associative array for default variable values.

APP_VAR_VALUE["VARIABLE"]="default value"

Change naming of variables used in script a bit.
Remove whitespace on blank line.
Add missing quotes around variable
Change to updating the `.env` file to after creating variables, to be sure they are sorted correctly.
Move initialization of `APP_LABEL_LIST` array to before for loop.  It will get reset to empty before each pass of the for loop.

Add a couple more comments.
Remove white space
Add/update comments
Re-order variable definitions to make it a bit clearer.  Add and move comments.
Do all processing in `env_update` internally in arrays, no temp files.

Output the array to the new `.;env` file at the end.
No need to compact array after removing items.
Reduce duplicated "Built In" and "User Defined" section output to a loop for builtin/user user defined.
Shorten a variable name.
Fix unbound variable
More consistent variable naming.
Minor comment changes
No need to keep track of index positions of lines added to sections.  Duplicates have already been handled by the associative array, the only duplicates would be from the variables added from the `.env.example` file.
Minor fix to comment... it's adding to a "section", not necessarily the "built in" section.
Replace all references to `mapfile` with `readarray`.  They are the exact same command, but `readarray` seems clearer on what it does.
Ignore whitespace before and after variable when getting and setting variables, to allow `   VAR   ='value'`

Change `env_set` to a simple "Delete variable in file" and "Add variable to file".
Fix variable output in `fatal` command.
Ignore error when deleting a variable (the `.env` file may not exist).
Remove unused variable.
Remove whitespace
Simplify `grep/sed` commands to a single `sed` command to get all variable lines minus whitespace.
Comment out `debug` line
Move `env_update` after `appvarse_create_all` in the test. `env_update` adds the global variables and sorts.
Ignore whitespace before and after variables.
Ignore whitespace before and after variables.
Make all references to variables names upper case.
Convert all variable names to upper case.
Change sorting of variables to sort using lower case, so that `_` sorts to the top.  This will allow using variables starting with `_` in other variable definitions, such as `VAR="This expands ${_VAR2}"`.

A variable must be defined BEFORE being expanded in another variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apps Automatic label core Automatic label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants