-
Notifications
You must be signed in to change notification settings - Fork 840
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
[WIP] resolve !env in yaml#1519
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR.
I think that this would be a nice new feature.
if ((env_var_content = getenv(env_var)) == NULL) | ||
env_var_content = ""; | ||
|
||
yaml_parser_t parser; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming that we can agree that the environment value should be accepted as a scalar (rather than a YAML), what you need to do is:
- free(node->data.scalar)
- initialize node->data.scalar to a string that can be freed using
free
(e.g.h2o_strdup(NULL, s, SIZE_MAX).base
) - increment the refcount of the node
- return the node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kazuho i just realised that only scalars might not be useful enough.
how about numbers? probably the most obvious thing you want to sed is e.g. num-threads.
also being able to use anchors would be neat, so you can "implement" simple switches.
i actually do not see any downside (except for the more complex code) to parsing it correctly.
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just realised that only scalars might not be useful enough.
how about numbers? probably the most obvious thing you want to sed is e.g. num-threads.
In YAML there is no distinction between strings and numbers. Both are scalars.
also being able to use anchors would be neat, so you can "implement" simple switches.
I would rather not take that into consideration when making the decision. I do not think having room to "hack" is bad, but having a straightforward design is more important.
i actually do not see any downside (except for the more complex code) to parsing it correctly.
Users would be required to encode the environment variable in YAML, which is not an easy task.
Consider the case where a script accepts some argument and convert that to a environment variable to be used for substitution in the configuration file. The script would be required to convert the argument to YAML, otherwise things could go wrong depending on the argument.
Not only implementing such escaping is difficult, it is very easy for the author of script to forget implementing it. That means that we could see issues in production...
My anticipation is that majority (if not most) of the use-case can be covered by just supporting scalars to be supplied with environment variables. So I think we should not require escaping for the use case, instead of making it difficult for all users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the clarifications, i think it makes sense. i'll change the implementation
replaced by #1524 |
No description provided.