Skip to content

Support setting / getting literals in environment variables#48

Merged
sc-olenanosenko merged 3 commits intoSitecore:mainfrom
gwdt:feature/literals_in_env
Oct 12, 2023
Merged

Support setting / getting literals in environment variables#48
sc-olenanosenko merged 3 commits intoSitecore:mainfrom
gwdt:feature/literals_in_env

Conversation

@gwdt
Copy link
Copy Markdown
Contributor

@gwdt gwdt commented May 25, 2023

Hi,
This PR adds support to allow developers to explicitly choose to set environment variables as a literal (ie. wrapped in single quotes).

E.G.
Set-EnvFileVariable -Variable 'VAR4' -Value 'literal$tring' -AsLiteral

Would write the following to the .env
VAR4='literal$tring'

I believe this is an improvement due to:

  • Improved DX giving developers the explicit choice of when to use literals when setting/getting env vars
  • Allows for special characters in keys/secrets when setting/getting env vars that may have been generated in other systems, which in some cases may not be avoided
  • Improves IDE syntax highlighting in .env files when there are special characters (special characters in long strings throw it off)
  • Enhances support for all previous flags when using Get-SitecoreRandomString e.g. -DisallowSpecial, -DisallowDollar etc where used

Bonus: Also fixes a bug where the replacement of $ in Set-EnvFileVariable will result in different outcomes depending on if it was an existing variable (inserted via regex) vs a new variable (interpolated with the $'s doubled) in the .env file.

@sc-olenanosenko sc-olenanosenko merged commit 90b9cf0 into Sitecore:main Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants