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

Consider changing env vars so that all are expected to be prefixed with SHLINK #1805

Open
acelaya opened this issue Jun 4, 2023 · 0 comments

Comments

@acelaya
Copy link
Member

acelaya commented Jun 4, 2023

For some time, Shlink can be configured via env vars.

This feature started as a way to provide configuration for the docker image, which incidentally made them have too generic names in many cases, because there was no risk of conflicting.

Later this mechanism was extended to be supported outside of docker as well. This means you could have other apps running on the same environment, with env vars of their own which could potentially conflict with Shlink ones.

Because of this, it would be good to change Shlink so that all its env vars are prefixed with SHLINK. For example:

  • PORT becomes SHLINK_PORT.
  • DB_DRIVER becomes SHLINK_DB_DRIVER.
  • DEFAULT_DOMAIN becomes SHLINK_DEFAULT_DOMAIN.
  • RABBITMQ_HOST becomes SHLINK_RABBITMQ_HOST.
  • Etc.

This should be done in a backwards compatible way, so when loading nev vars, we should try to fall-back to their non-prefixed version if the prefixed one is not found.

The non-prefixed ones will become deprecated, and removed in Shlink 4.0.0 5.0.0

This change also affects the installer, which generates a map of options that are later promoted as env vars by shlink-config's EnvVarLoaderProvider. There are two ways to address this:

  • The Shlink installer starts generating prefixed options.
    • That is a breaking change if someone tries to use a newer version of the installer with an older version of Shlink. Unlikely, but not impossible if someone tries to build Shlink from sources, due to the lack of locked dependencies.
    • The installer could introspect Shlink's config to know the version, and prefix the options or not based on that.
  • EnvVarLoaderProvider accepts an optional prefix that is prepended to options before promoting them to env vars, unless they already start by that prefix.
    • This change is backwards compatible, and will continue working if eventually or accidentally the installer includes the prefixes.

There are some edge cases, like SHELL_VERBOSITY. This env var is referenced in many places to help debug Shlink, but it's not directly consumed by Shlink itself, but one if its dependencies.

Should SHLINK_SHELL_VERBOSITY be supported as well, mapping it to SHELL_VERBOSITY if defined? Or should this one have a special treatment?

@acelaya acelaya added this to the 3.7.0 milestone Jun 4, 2023
@acelaya acelaya changed the title Change env vars so that all are prefixed with SHLINK Change env vars so that all are expected to be prefixed with SHLINK Jun 9, 2023
@acelaya acelaya moved this to Todo in Shlink Jul 31, 2023
@acelaya acelaya removed this from the 3.7.0 milestone Oct 20, 2023
@acelaya acelaya changed the title Change env vars so that all are expected to be prefixed with SHLINK Consider changing env vars so that all are expected to be prefixed with SHLINK Oct 20, 2023
@acelaya acelaya removed the status in Shlink Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant