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

Override env vars #144

Merged
merged 4 commits into from
Sep 10, 2020
Merged

Override env vars #144

merged 4 commits into from
Sep 10, 2020

Conversation

ekcasey
Copy link
Member

@ekcasey ekcasey commented Aug 27, 2020

  • makes override the default behavior for env files w/o a suffix
  • reorders modification types so that the default behavior is easy to find (at the top)
  • reorders modification types alphabetically and moves suffix -> type mapping to a table at the top of the section.

@ekcasey ekcasey requested a review from a team as a code owner August 27, 2020 21:26
@ekcasey ekcasey added this to the Buildpack 0.5 milestone Aug 27, 2020
@ekcasey ekcasey linked an issue Aug 27, 2020 that may be closed by this pull request
buildpack.md Outdated
@@ -666,6 +666,23 @@ For each file written to `<layers>/<layer>/env.launch/` by `/bin/build`, the lif
The lifecycle MUST consider the name of the environment variable to be the name of the file up to the first period (`.`) or to the end of the name if no periods are present.
In all cases, file contents MUST NOT be evaluated by a shell or otherwise modified before inclusion in environment variable values.

##### Override

If the environment variable file name has no period-delimited suffix, then the value of the environment variable MUST be the file contents.
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about adding an examples area to clearly show the association between the file name and the definition of behavior? I think this would also have the benefit of hoisting up the no period-delimited behavior to make it clearer.

Examples
Filename Modification Behavior
<layers>/<layer>/env/<env_var> Override
<layers>/<layer>/env/<env_var>.override Override
<layers>/<layer>/env/<env_var>.default Default
<layers>/<layer>/env/<env_var>.delim Default
<layers>/<layer>/env/<env_var>.prepend Default
<layers>/<layer>/env/<env_var>.append Default

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. I updated the branch to move all of the suffix information into a table at the top. With that change I thought it made sense to alphabetize the modification types (instead of putting the default first).

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we still going to have a .override? We're already breaking compatibility, and I'm not a fan of having two ways to accomplish the same behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

By using .override or .prepend explicitly buildpack authors can currently write buildpacks that will not break when the API changes. This would not be true if we removed .override in buildpack API 0.5.

Also, removing .override would require more buildpacks to update to accomodate this change.

In my mind, the above reasons outweigh the cost of having two ways to accomplish the same behavior. Personally I also like the symmetry of having a suffix for every operation (but that probably not a very good reason).

@ekcasey ekcasey force-pushed the override-env-vars branch 2 times, most recently from 4de1c3e to 7a76cb6 Compare August 28, 2020 16:34
buildpack.md Outdated
- For default environment variable file contents originating from the same buildpack, file contents that are earlier (when sorted alphabetically ascending by associated layer name) MUST override file contents that are later.
- **Default environment variable file contents originating in the same layer MUST be sorted such that file contents in `<layers>/<layer>/env/` override file contents in `<layers>/<layer>/env.build/` or `<layers>/<layer>/env.launch/` which override file contents in `<layers>/<layer>/env.launch/<process>/`.**
The value of the environment variable MUST be a concatenation of the file contents and the contents of other files representing that environment variable.
In either case, within that environment variable value,
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused - what are the two cases here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, this is a remnant from a time when this line was describing either .prepend or no suffix cases.

buildpack.md Outdated Show resolved Hide resolved
@yaelharel
Copy link

I have a general question:
I think that examples can be really helpful in such parts of the spec.
Probably it isn't ideal to add the examples as part of the spec, but maybe we can add a link to an example in a different place.
Did we consider doing it?

@hone
Copy link
Member

hone commented Sep 9, 2020

Do we need to cover how buildpack API 0.4 and 0.5 will work together? It seems doable where you assume the defaults of their respective APIs together and lifecycle and figure it out.

@nebhale nebhale requested a review from a team September 9, 2020 18:17
@nebhale nebhale requested a review from hone September 9, 2020 18:35
ekcasey and others added 4 commits September 10, 2020 10:21
* Alphatbetize modification types
* Improves readability/navigation

Signed-off-by: Emily Casey <[email protected]>
Signed-off-by: Emily Casey <[email protected]>

Co-authored-by: Natalie Arellano <[email protected]>
Signed-off-by: Emily Casey <[email protected]>
@ekcasey
Copy link
Member Author

ekcasey commented Sep 10, 2020

Do we need to cover how buildpack API 0.4 and 0.5 will work together? It seems doable where you assume the defaults of their respective APIs together and lifecycle and figure it out.

Outcome from leadership meeting discussion: This belongs in lifecycle documentation rather than the spec given that another compliant lifecycle implementation may reasonably choose to support only API 0.5.

Also, the lifecycle implementation provided by the CNB project currently supports any combination of buildpacks with APIs >= to 0.2 in a single group. Therefore the above statement about compatibility is not specific to this change but rather is true generally.

@ekcasey ekcasey merged commit 0aea8c9 into buildpack/0.5 Sep 10, 2020
@ekcasey ekcasey deleted the override-env-vars branch September 10, 2020 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC 0051] Override Env Vars by Default
8 participants