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

!env for respecting environment variables from the configuration file#1524

Merged
merged 2 commits into from
Jan 5, 2018

Conversation

yannick
Copy link
Contributor

@yannick yannick commented Dec 7, 2017

implements #1520 , replaces #1519

  • documentation

@yannick yannick changed the title !env as scalar [WIP] !env as scalar Dec 7, 2017
env_var_content = "";

free(node->data.scalar);
node->data.scalar = h2o_strdup(NULL, env_var_content, SIZE_MAX).base;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

what is the reason the pointer from getenv cant be assigned directly to node->data.scalar ?

Copy link
Member

Choose a reason for hiding this comment

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

Because node->data.scalar eventually gets freed in yoml_free.

@yannick
Copy link
Contributor Author

yannick commented Dec 8, 2017

Q: should we allow a default value? if so how, just strstr for the first space?

@yannick yannick changed the title [WIP] !env as scalar !env support in config Dec 9, 2017
@kazuho
Copy link
Member

kazuho commented Dec 11, 2017

@yannick

Q: should we allow a default value? if so how, just strstr for the first space?

Could you please elaborate what you mean by "default"? To me the current code that uses an empty string upon the absence the environment variable seems sufficient to me.

@yannick
Copy link
Contributor Author

yannick commented Dec 11, 2017

@kazuho one could catch the null and then set the variable to a default that was supplied. Like !env H2O_PORT 8080

If you think thats useless im fine as is.

Use case for me would be to simplify deployment of mini services in containers

@kazuho
Copy link
Member

kazuho commented Dec 22, 2017

@yannick Sorry for the belated response.

Like !env H2O_PORT 8080.

We could do that, but the syntax could be an issue. Personally I'd prefer using a syntax similar to bash (e.g., !env "H2O_ROOT:-8080"). The reason why I'm hesitant with the proposed syntax is that it seems to imply that H2O_PORT and 8080 are different objects whereas the truth is that it is a shorthand for !env "H2O_PORT 8080".

What do you think? Alternatively, we could leave default value support to another PR.

@yannick
Copy link
Contributor Author

yannick commented Dec 22, 2017

@kazuho i am fine with this idea. i'd say we leave it as is and if i manage i'll do a 2nd pr to add defaults.

@kazuho kazuho merged commit 436a7c9 into h2o:master Jan 5, 2018
kazuho added a commit that referenced this pull request Jan 5, 2018
@kazuho
Copy link
Member

kazuho commented Jan 5, 2018

Thank you for working on the PR. The changes have been merged to master.

@kazuho kazuho changed the title !env support in config !env for respecting environment variables from the configuration file Jan 16, 2018
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