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

feat(example): Allow configuring some parameters with env variables #663

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lanseg
Copy link
Contributor

@lanseg lanseg commented Oct 9, 2024

This change allows to load users from the json file.

That should help to create better test scenarios when using example server as fake Zitadel instance for testing. For example, having several users with different permissions or presence in the internal base (known user, unknown user, blocked user, etc).

We don't need dynamic server for testing, but I could update it to make env variables unified if needed.

This is an extended version of another pull request: #656, which was deleted by mistake.

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.02%. Comparing base (0992c5f) to head (526b6bd).
Report is 98 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #663      +/-   ##
==========================================
+ Coverage   60.06%   61.02%   +0.96%     
==========================================
  Files          80       81       +1     
  Lines        6998     7418     +420     
==========================================
+ Hits         4203     4527     +324     
- Misses       2498     2581      +83     
- Partials      297      310      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@muhlemmer muhlemmer self-requested a review October 15, 2024 11:01
// If there is no such variable defined, then use default values.
func FromEnvVars(defaults *Config) *Config {
if defaults == nil {
defaults = &Config{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't DefaultIssuerPort be set to the Config here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works as planned - if the defaults is nil, then user didn't want to have any defaults and expects everything to be set in the env vars.

if value, ok := os.LookupEnv("USERS_FILE"); ok {
cfg.UsersFile = value
}
if value, ok := os.LookupEnv("REDIRECT_URIS"); ok {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the environment variable name REDIRECT_URI, so we don't break existing uses of this variables.

Suggested change
if value, ok := os.LookupEnv("REDIRECT_URIS"); ok {
if value, ok := os.LookupEnv("REDIRECT_URI"); ok {

@muhlemmer
Copy link
Collaborator

Hi @lanseg I noticed you pushed another commit with additional changes after the initial review was done, not related to the review comments. Although I do not have a problem with the additional change, this is not a nice netiquette. If you intent to continue work on a PR, it should be marked as "draft" and not "ready for review". Please keep that in mind for future contributions to any github project.

You also have introduced a build error that needs to be fixed.

I'll mark this as draft for the moment and please mark it ready for review once you are done.

@muhlemmer muhlemmer marked this pull request as draft October 16, 2024 12:53
@lanseg lanseg force-pushed the main branch 2 times, most recently from 58c9abb to 514c1de Compare October 19, 2024 16:19
@lanseg
Copy link
Contributor Author

lanseg commented Oct 19, 2024

Hi @lanseg I noticed you pushed another commit with additional changes after the initial review was done, not related to the review comments. Although I do not have a problem with the additional change, this is not a nice netiquette. If you intent to continue work on a PR, it should be marked as "draft" and not "ready for review". Please keep that in mind for future contributions to any github project.

You also have introduced a build error that needs to be fixed.

I'll mark this as draft for the moment and please mark it ready for review once you are done.

I'm very sorry for causing a mess, github workflow confused me a bit better.

@lanseg lanseg marked this pull request as ready for review October 19, 2024 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Sprint Backlog
Development

Successfully merging this pull request may close these issues.

3 participants