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

support runner env #19

Merged
merged 5 commits into from
Oct 15, 2018
Merged

support runner env #19

merged 5 commits into from
Oct 15, 2018

Conversation

cw-ozaki
Copy link
Contributor

support runner.envoption.

  runner-env:
    runner:
      image: "alpine:3.7"
      command: sh
      args: [-c]
      env:
        FOO: foo
    script: |
      env | grep "FOO=foo"

and, We have made it possible to expand environment variables and autoenv parameters with some runner options.


dockerArgs := []string{}
for _, v := range c.Volumes {
dockerArgs = append(dockerArgs, "-v", os.ExpandEnv(v))
Copy link
Owner

Choose a reason for hiding this comment

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

Thanks for preserving ExpandEnv here!

As far as I remember, this was necessary to expand the HOME env var contained in the src of volume mount, that is useful for mounting .aws or .ssh on the host machine to the container.

dockerArgs = append(dockerArgs, "-e", fmt.Sprintf("%s=%s", k, os.ExpandEnv(v)))
}
if c.Envfile != "" {
dockerArgs = append(dockerArgs, "--env-file", os.ExpandEnv(c.Envfile))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am thinking about specification like $PWD/.env and $HOME/.env as usecase.

Copy link
Owner

Choose a reason for hiding this comment

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

Sounds nice. Thanks for clarifying 👍

dockerArgs = append(dockerArgs, "-v", os.ExpandEnv(v))
}
for k, v := range c.Env {
dockerArgs = append(dockerArgs, "-e", fmt.Sprintf("%s=%s", k, os.ExpandEnv(v)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pass the host's environment variable to docker as a use case.
example:

runner:
  image: ...
  env:
    DOCKER_HOST: $DOCKER_HOST

Copy link
Owner

@mumoshu mumoshu left a comment

Choose a reason for hiding this comment

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

This looks awesome. Thanks for your contribution 👍

@mumoshu mumoshu merged commit 38a1bac into mumoshu:master Oct 15, 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.

None yet

2 participants