Skip to content

Conversation

@anton-vylushchak
Copy link

@anton-vylushchak anton-vylushchak commented Nov 24, 2022

Context

Current Terrafile format that is supported is a list of sources where each source has a list of versions. e.g.:

git@github.com:segmentio/terracode-modules:
  - 2022-11-22.2

After vendoring module, it will produce the following directory:

./.terrafile/segmentio/terracode-modules/2022-11-22.2

The major downside of current Terrafile format is that output contains the version of the module in path, so when you want to upgrade module version, you need to update Terrafile and all usages of that module in the code, which is kinda losing the major benefit of using Terrafile


Community Terrafile which is supported by github: coretech/terrafile and npm: terrafile doesn't have such drawback, because there have aliases for each module version:

terracode-modules:
  source: "git@github.com:segmentio/terracode-modules"
  version: "2022-11-24"

After vendoring module, it will produce the following directory:

./.terrafile/terracode-modules

In this way, we will be able to reference the module all over the code without specifying the version. So when we will need to update a module version, it will be changed in only one place (Terrafile)

Description

  • Updated README
  • Added community Terrafile format support. Existing SegmentTerrafile format implementation is left untouched to ensure backward compatibility
  • Added end-to-end test for community Terrafile format

Testing

> go build ./...
> go test -v ./...

=== RUN   TestTerrafile
=== RUN   TestTerrafile/Segment_Terrafile_Format
=== RUN   TestTerrafile/Community_Terrafile_Format
--- PASS: TestTerrafile (3.42s)
    --- PASS: TestTerrafile/Segment_Terrafile_Format (1.71s)
    --- PASS: TestTerrafile/Community_Terrafile_Format (1.72s)
PASS
ok  	github.com/segmentio/terrafile	4.050s

@anton-vylushchak anton-vylushchak self-assigned this Nov 24, 2022
@anton-vylushchak anton-vylushchak force-pushed the feature/terrafile-community-format-support branch from bf14822 to 6157949 Compare November 24, 2022 23:14
@anton-vylushchak anton-vylushchak marked this pull request as ready for review November 25, 2022 20:20
Copy link

@Fauzyy Fauzyy left a comment

Choose a reason for hiding this comment

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

One main comment here, I'd also recommend adding some examples to the readme on how to use the community format

@anton-vylushchak
Copy link
Author

One main comment here, I'd also recommend adding some examples to the readme on how to use the community format

Good point, will add examples there

@anton-vylushchak anton-vylushchak merged commit 87b92fe into master Nov 28, 2022
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

Successfully merging this pull request may close these issues.

3 participants