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

feat: Add support for set env vars inside hook runtime #408

Merged
merged 4 commits into from
Jul 5, 2022

Conversation

MaxymVlasov
Copy link
Collaborator

Put an x into the box if that apply:

  • This PR introduces breaking change.
  • This PR fixes a bug.
  • This PR adds new functionality.
  • This PR enhances existing functionality.

@MaxymVlasov MaxymVlasov added the feature New feature or request label Jul 5, 2022
hooks/_common.sh Outdated Show resolved Hide resolved
@@ -60,6 +64,11 @@ function common::parse_cmdline {
TF_INIT_ARGS+=("$1")
shift
;;
-e | --envs)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@antonbabenko Any ideas on how it can be better named?

Main idea:

You can specify environment variables that will be passed to the hook runtime.

Config example for now

- id: terraform_validate
  args:
    - --envs=AWS_DEFAULT_REGION="us-west-2"
    - --envs=AWS_ACCESS_KEY_ID="anaccesskey"
    - --envs=AWS_SECRET_ACCESS_KEY="asecretkey"

Copy link
Collaborator Author

@MaxymVlasov MaxymVlasov Jul 5, 2022

Choose a reason for hiding this comment

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

@yermulnik proposed --env-vars, but I don't think that much better option, to introduce it and then remove --envs in 2.0.0

Copy link
Owner

Choose a reason for hiding this comment

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

env-vars sounds perfect to me

Copy link
Collaborator

@yermulnik yermulnik left a comment

Choose a reason for hiding this comment

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

LGTM. Style comments/suggestions may be considered (or not) later and in scope of another PR.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Comment on lines +298 to +300
- --envs=AWS_DEFAULT_REGION="us-west-2"
- --envs=AWS_ACCESS_KEY_ID="anaccesskey"
- --envs=AWS_SECRET_ACCESS_KEY="asecretkey"
Copy link
Collaborator

Choose a reason for hiding this comment

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

As discussed privately we'll get back to reconsidering this option's name later (e.g. to --env-vars or something like that)

hooks/_common.sh Outdated Show resolved Hide resolved
hooks/_common.sh Outdated Show resolved Hide resolved
MaxymVlasov and others added 2 commits July 5, 2022 19:06
Co-authored-by: George L. Yermulnik <yz@yz.kiev.ua>
@MaxymVlasov MaxymVlasov merged commit dfeee5e into pre-release Jul 5, 2022
@MaxymVlasov MaxymVlasov deleted the feat/add_env_support branch July 5, 2022 16:07
antonbabenko pushed a commit that referenced this pull request Jul 12, 2022
# [1.74.0](v1.73.0...v1.74.0) (2022-07-12)

### Bug Fixes

* Add `--env-vars`, deprecate `--envs` ([#410](#410)) ([2b35cad](2b35cad))
* Add `--tf-init-args`, deprecate `--init-args` ([#407](#407)) ([c4f8251](c4f8251))

### Features

* Add support for set env vars inside hook runtime ([#408](#408)) ([d490231](d490231))
* Allow `terraform_providers_lock` specify terraform init args ([#406](#406)) ([32b232f](32b232f))
* Suppress color for all hooks if `PRE_COMMIT_COLOR=never` set ([#409](#409)) ([b12f0c6](b12f0c6))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants