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

Improve configuration process #25

Open
4 of 6 tasks
relu91 opened this issue Sep 19, 2022 · 8 comments
Open
4 of 6 tasks

Improve configuration process #25

relu91 opened this issue Sep 19, 2022 · 8 comments
Assignees
Labels
effort: days priority: high (2) High-priority issue that should be resolved as soon as possible status: wip ⚡ When there is a PR associated with the issue and it is in a draft mode or pending review type: discussion type: enhancement New feature or request

Comments

@relu91
Copy link
Member

relu91 commented Sep 19, 2022

Currently, Zion utilizes a simple Env base configuration workflow. We should organize configuration parameters in a hierarchical data structure. Moreover, we have to keep in mind different developer workflows and experiences. This means that we need the flexibility to configure Zion from different sources with different priorities (like JSON/YAML files, CLI parameters, ENVs). This issue serves also as a place to evaluate different ideas before going to the PR phase.

Todos:

  • Refactoring code to have a structured config model
  • Support different development environments
  • Hooks on package.json
  • Configuration file support
  • CLI support
  • Review and check the defaults

Sources:

  1. Nest configuration
  2. Commander in Nest
@relu91 relu91 added type: enhancement New feature or request priority: high (2) High-priority issue that should be resolved as soon as possible effort: days type: discussion labels Sep 19, 2022
@relu91
Copy link
Member Author

relu91 commented Sep 20, 2022

To summarize today's call:

  • Refactoring code to have a structured config model
  • Support different development environments (prod, dev, staging)
  • Hooks on package.json
  • Configuration file support (maybe)
  • Review and check the defaults
  • CLI support (next up)

@relu91
Copy link
Member Author

relu91 commented Oct 18, 2022

Configuration file support (maybe)

Some feedback from today's call. We discussed the possibility of implementing support for a configuration file and CLI argument but we didn't find a concrete agreement.

But we've found these truths:

  • Is that is not that standard to use only envs as configuration
  • There's no standard priority schema in regards to envs and config files
  • It seems that CLI args always has a priority
  • Config files have the advantage of providing structure to configs
  • We agree that config files can be used to create different software structures (or flavors). They can be useful to pre-ship a docker already configured for a particular use case.

@hyperloris clear view: we should have three ways to configure the system (envs, config, CLI) BUT there should be a precise mapping between the three. The priority should be CLI > ENVs > File. He doesn't know the structure of the config file. Here is an example:

@relu91
Copy link
Member Author

relu91 commented Oct 18, 2022

So we decided the final task list that can be find in the issue description

@relu91
Copy link
Member Author

relu91 commented Oct 18, 2022

@ivanzy still thinks that right now File support is overkill and should be deferred.

@relu91 relu91 added the status: wip ⚡ When there is a PR associated with the issue and it is in a draft mode or pending review label Oct 20, 2022
@relu91
Copy link
Member Author

relu91 commented Oct 27, 2022

@hyperloris clear view: we should have three ways to configure the system (envs, config, CLI) BUT there should be a precise mapping between the three. The priority should be CLI > ENVs > File. He doesn't know the structure of the config file.

After #28, @ivanzy may I ask you to implement the logic above?

@ivanzy
Copy link
Contributor

ivanzy commented Oct 28, 2022

Okay, I will start to work on that. Just to clarify:

  • CLI means to set ENV when executing the command, e.g.,NODE_ENV=production node dist/src/main; or it is through custom designed flags?
  • ENVs are clear
  • File is a custom configuration file in YAML. Is there the need or motivation to use another structure?

@relu91
Copy link
Member Author

relu91 commented Oct 29, 2022

CLI means to set ENV when executing the command, e.g.,NODE_ENV=production node dist/src/main; or it is through custom designed flags?

custom flags, to follow what @hyperloris said:

BUT there should be a precise mapping between the three

I think if an ENV is ZION_PERSISTENCE_DB_PORT then the corresponding CLI parameter is --persistence.db.port.

File is a custom configuration file in YAML. Is there the need or motivation to use another structure?

If there is already some support for YAML, I won't complain. But I also like JSON + JSONSchema as a file configuration ( I little bit overkill but it depends on how much zion will grow).

@relu91
Copy link
Member Author

relu91 commented Oct 31, 2022

ZION_PERSISTENCE_DB_PORT

By the way, I've just noticed all the ENVs should be prefixed with ZION. It is a good practice to avoid conflicts with other services in non-docker environments.

relu91 added a commit that referenced this issue Mar 27, 2023
As discussed in [github comment](#25 (comment)),
common practice is to prepend to all env variables with the name of the
project/application/library. This commit does that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: days priority: high (2) High-priority issue that should be resolved as soon as possible status: wip ⚡ When there is a PR associated with the issue and it is in a draft mode or pending review type: discussion type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants