terraform-provider-gitlab icon indicating copy to clipboard operation
terraform-provider-gitlab copied to clipboard

Project Structure

Open timofurrer opened this issue 2 years ago • 3 comments

We've had a brief discussion in #1073 about the project structure w.r.t to the file hierarchy / naming and go packages.

We kinda agree that with the growing amount of resources and data sources it somewhat gets harder to locate files, especially non-resource / datasource files like helpers and utils.

Another problem is that pretty much all other files start with resource_gitlab_ or data_source_gitlab_ which already uses unnecessary spacing on the screen without providing much value, especially the _gitlab_ part.

A few mitigations to discuss:

Mitigation 1

Put helpers like access_level_helpers.go, environment_scope_helper.go, ... into a separate helper package directly related to GitLab functionality.

Mitigation 2

Testing helpers like helper_test.go into separate package.

Mitigation 3

Put generic helpers like util.go into separate package. These may also be combined with (1) to not have too many packages ....

Mitigation 4

Rename resource / data source and schema go files, e.g. remove the gitlab infix - however, I kinda like that the complete terraform object name is in the filename ... what do others think here?

Mitigation 5

Put provider boilerplate code like provider.go, config.go and main.go into separate package.


When we consider to actually implement any of these mitigations I still think it makes sense to weigh to adhere to de-facto best practices (e.g. coming form the scaffolding project) to make it easier for people to contribute.

Originally posted by @PatrickRice-KSC in https://github.com/gitlabhq/terraform-provider-gitlab/pull/1073#discussion_r873079366

timofurrer avatar May 15 '22 09:05 timofurrer

What about all helpers and utils in 1 separate package and folder seeing as there aren't many unless I am mistaken. I would rather go into 1 folder than 3 which have 1-3 files each in them.

For the resources and datasources if we can I would like to put them in separate folders which would reduce the amount of files to look through in the provider directory

I like the gitlab prefix as I can match what I am looking for when I search filenames when looking at other resources/datasources

IMHO the separation of resources and datasources into different directories would be the biggest thing to making it better to navigate the provider

Shocktrooper avatar May 16 '22 05:05 Shocktrooper

I think we should execute at least 1 and 3 (and combine them like you suggest in 3 so we don't have too many new packages). I agree that I prefer having "gitlab" in the resource name even though it's a bit redundant because it matches the resource name.

I do wonder with the new schema pattern if we want schemas in their own package, just because with naming it won't be next to the tests/resources/data sources in the package, so it clickthrough will be needed to get to it anyway in an IDE, and that way it doesn't contribute to additional files in the provider package.

PatrickRice-KSC avatar May 18 '22 03:05 PatrickRice-KSC

Marking this issue as stale due to 120 days of inactivity. If this issue receives no comments in the next 30 days it will be closed. Maintainers can also remove the stale label.

Please comment with more information if you would like this issue to remain open.

github-actions[bot] avatar Sep 15 '22 04:09 github-actions[bot]