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

Sort environment variables based on kubernetes style referencing #3116

Closed
wants to merge 1 commit into from
Closed

Sort environment variables based on kubernetes style referencing #3116

wants to merge 1 commit into from

Conversation

esselius
Copy link
Contributor

Fixes #3108

/cc @zendesk/samson

Tasks

  • 👍 from team

Risks

  • Level: Low

@esselius esselius requested a review from a team as a code owner January 10, 2019 09:05
@esselius
Copy link
Contributor Author

@grosser Does this seem appropriate? :)


### Ordering environment variables based on references

In kubernetes, you can reference an environment variable from another using the syntax: `FOO: $(BAR)`. However, in this case `BAR` needs to be defined before `FOO` for it to work. This is due to an implementation detail in kubernetes itself.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In kubernetes, you can reference an environment variable from another using the syntax: `FOO: $(BAR)`. However, in this case `BAR` needs to be defined before `FOO` for it to work. This is due to an implementation detail in kubernetes itself.
In kubernetes, you can reference an environment variable from another using the syntax: `FOO: ${BAR}`. However, in this case `BAR` needs to be defined before `FOO` for it to work. This is due to an implementation detail in kubernetes itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

... maybe I understood your proposal wrong ...
samson does env variable replacement too with ${FOO} which works for non-kubernetes projects too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically, what we want is to be able to reference $DEPLOY_GROUP, which is not available when the env-plugin runs it's resolve_dollar_variables()-method in EnvironmentVariable, triggered by the Samson::Hook in the kubernetes-plugin.

We decided to make this an optional feature to please kubernetes, enabled by setting a environment variable, rather than refactoring how the kubernetes and env (and possibly other) plugins pass around env vars through hooks without knowing if that was a appropriate design decision.

What do you think @grosser ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the problem is that resolve_dollar_variables (and preview / resolve-secrets) belongs into base and not into the env plugins since we should only resolve once we have collected all env vars from base+plugins.

A solution would be to add a new Samson::EnvResolver class that collects env (can be given a base env too) and handles preview/merge/resolve/secrets ... then use that from template_filler and from plugins/env/app/controllers/env/environment_controller.rb.

... with that any other plugin can add env vars via deploy_group_env hook and they automatically get resolved/previewed

... sounds good ?

(base make a fresh PR for that so this here does not get too cluttered)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds great, we'll try to produce a PR in the coming days

Should we still include the $(FOO)-based sorting logic?

@grosser
Copy link
Contributor

grosser commented Jan 15, 2019 via email

@grosser grosser closed this Feb 25, 2019
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