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

Feature Request: Ignore paths when creating hosted artifact #83

Open
freakinhippie opened this issue Mar 4, 2025 · 5 comments
Open

Comments

@freakinhippie
Copy link

I have many modules which are relatively small in terms of raw terraform code, but have documentation and tests included which are often multiple times the content.

It would be great if terrareg had something like the .gitignore file (possibly .tfmodignore or just .tfignore) which would exclude some portion of the module's contents from the generated artifacts when hosting them rather than using a git url.

For example, consider the following simplified illustration:

>  tree -a my-module
my-module
├── CHANGELOG.md
├── data.tf
├── docs
│   ├── advanced_usage.md
│   ├── basic_usage.md
│   └── images
│       └── overview.svg
├── examples
│   └── defaults
│       └── main.tf
├── .git # truncated for brevity
├── .gitignore
├── main.tf
├── modules
│   └── sub
│       └── main.tf
├── _module_version_.tf
├── outputs.tf
├── README.md
├── terratests
│   ├── basics_test.go
│   ├── go.mod
│   └── go.sum
├── tests
│   ├── 00_input_validation.tftest.hcl
│   └── 05_basics.tftest.hcl
├── .tfignore
├── variables.tf
└── versions.tf

The only portion that must be served to terraform are these:

>  tree -a my-module
my-module
├── data.tf
├── main.tf
├── modules
│   └── sub
│       └── main.tf
├── _module_version_.tf
├── outputs.tf
├── variables.tf
└── versions.tf

So, if I could create a .tfignore file which follows the same rules as .gitignore, then I could include this to achieve the desired results:

my-module/.tfignore:

README.md
CHANGELOG.md
.git
.gitignore
docs/
examples/
terratests/
tests/

And I guess it would make sense for it to automatically ignore itself, but I wouldn't object to having to make that explicit.

@freakinhippie
Copy link
Author

freakinhippie commented Mar 4, 2025

Hmm, this seems to be basically a duplicate of #41

[Edit] On further inspection, it is not the same. That request was to use a sort of base path to create the archive from.

@MatthewJohn
Copy link
Owner

Created gitlab issue: https://gitlab.dockstudios.co.uk/pub/terrareg/-/issues/561
gitlab-issue-id:561

@MatthewJohn
Copy link
Owner

Interesting! I like this idea.

@MatthewJohn
Copy link
Owner

Fortunately, I've found a parser that supports these kinds of formats (because, whilst it would be interesting to write, it's something that would likely have so many teething issues and unforeseen use-cases).
I don't want to regret this, but since you raised the issue, what do you think you'd like the ignore file to be named? :P

Some I was thinking:

.tfignore
.terraregignore
.tfmoduleignore
.terraform_or_opentofu-module.ignore_:eyes:

@MatthewJohn
Copy link
Owner

Oh, I see you already suggested .tfmodigore and .tfignore.. so let's go with .tfignore :)

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

No branches or pull requests

2 participants