Skip to content

feat: Add support for relative path for tflint#264

Closed
MaxymVlasov wants to merge 1 commit intomasterfrom
feat/support_relative_path
Closed

feat: Add support for relative path for tflint#264
MaxymVlasov wants to merge 1 commit intomasterfrom
feat/support_relative_path

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.

Description of your changes

tflint: Add relative path support.

Add common functions that will be moved to separately file in the future.
For DRY reason

Relates: #252, #255, #259, #262

How has this code been tested

Run pre-commit run -a for each configuration. Results should be the same.

repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
  rev: 0f7aa9e92024ed3656954306c327ea563ce0e868
  hooks:
  - id: terraform_tflint
    args:
      - '--args=--config=.tflint.hcl'
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
  rev: 0f7aa9e92024ed3656954306c327ea563ce0e868
  hooks:
  - id: terraform_tflint
    args:
      - '--args=--config=__GIT_WORKING_DIR__/.tflint.hcl'

Add common funtions that will be moved to separaty file in future.
For DRY reason
@MaxymVlasov MaxymVlasov added feature New feature or request hook/terraform_tflint Bash hook estimate/1h Need 1 hour to be done labels Oct 25, 2021
@MaxymVlasov MaxymVlasov self-assigned this Oct 25, 2021
@MaxymVlasov MaxymVlasov changed the title feat: Add support for relative path feat: Add support for relative path for tflint Oct 25, 2021
@MaxymVlasov
Copy link
Collaborator Author

@gravitybacklight jfyi

@MaxymVlasov
Copy link
Collaborator Author

Had a conversation with Anton about __GIT_WORKING_DIR__ and found that can be used non-default config names in many subdirectories like

tflint --config other_config.hcl

https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md

So that PR break that and, also, decreases exciting functional.

Maybe, I will investigate GIT_DIR var in the future, as git native replacement for __GIT_WORKING_DIR__. If not - I will add __GIT_WORKING_DIR__ for all hooks

@MaxymVlasov MaxymVlasov deleted the feat/support_relative_path branch October 26, 2021 10:30
@antonbabenko
Copy link
Owner

@MaxymVlasov GIT_DIR does not exist in many cases and for many users.

I use this hook in my .bash_profile:

precmd() {
	GIT_REPO_DIR=$(git rev-parse --show-toplevel 2>/dev/null)
	if [[ -n "$GIT_REPO_DIR" ]]; then
	  export GIT_REPO_DIR="$GIT_REPO_DIR"
	fi
}

@yermulnik
Copy link
Collaborator

I use this hook in my .bash_profile

jfyi, it should be safe to replace it with a oneliner:

precmd() {
        GIT_REPO_DIR=$(git rev-parse --show-toplevel 2>/dev/null) && export GIT_REPO_DIR || unset GIT_REPO_DIR
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

estimate/1h Need 1 hour to be done feature New feature or request hook/terraform_tflint Bash hook

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants