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

Add GetModulePath method #171

Merged
merged 1 commit into from
Jul 31, 2022
Merged

Add GetModulePath method #171

merged 1 commit into from
Jul 31, 2022

Conversation

wata727
Copy link
Member

@wata727 wata727 commented Jul 31, 2022

Fixes #165

This PR adds a new gRPC method called GetModulePath. This method can be called from the Runner and can be used to determine where the current module is in the module tree.

For example, IsRoot() can be used to determine whether a module is a root module:

path, _ := runner.GetModulePath()
if path.IsRoot() {
  // In the root module
}

@wata727 wata727 merged commit 549898f into master Jul 31, 2022
@wata727 wata727 deleted the get_module_path branch July 31, 2022 08:04
@yashg-ti
Copy link

yashg-ti commented Jun 4, 2023

Hi
To be able to use this api in tflint-ruleset's check function, what's the required way of using the tflint command on the root file? I'm assuming it takes some recursive approach of progressing through the terraform tree. If so how to make this recursion happen?

I'm using the iterative approach currently, where I run the tflint command individually on each child module, thinking it picks the path up from the module path parameter in the command, which is kept relative to the root file directory. But that doesn't seem to be the case as it's not working, and returning 'nil' for child modules.

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

Successfully merging this pull request may close these issues.

Provide access to module name on runner
2 participants