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

feat: DependsOn files #305

Merged
merged 1 commit into from
May 24, 2024
Merged

Conversation

vincenthsh
Copy link
Owner

Add ability to depend on files

implements #304

Comment on lines +156 to +158
{{ range $key, $val := .LocalsBlock }}
{{ $key }} = {{ $val }}
{{ end }}
Copy link
Owner Author

@vincenthsh vincenthsh May 23, 2024

Choose a reason for hiding this comment

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

these will always be sorted!

gotemplate sorts maps by keys
golang/go@a5950df

Comment on lines 118 to 121
locals {
bar = jsondecode(file("../../../bar.json"))
foofoofoo = yamldecode(file("../../../foofoofoo.yaml"))
}
Copy link
Owner Author

Choose a reason for hiding this comment

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

Adding file dependencies makes their content available through locals.

Comment on lines 511 to 535
func (c *Config) ValidateFileDependencies(fs afero.Fs) error {
var errs *multierror.Error
c.WalkComponents(func(component string, comms ...Common) {
files := ResolveOptionalStringSlice(DependsOnFilesGetter, comms...)
for _, file := range files {
if _, err := fs.Stat(file); os.IsNotExist(err) {
errs = multierror.Append(err, fmt.Errorf("File does not exist: %s\n", file))
}
}
})

return errs.ErrorOrNil()
}
Copy link
Owner Author

Choose a reason for hiding this comment

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

fogg validates file dependencies exist

@vincenthsh vincenthsh force-pushed the feat-depends-on-file branch from 72e8909 to 70f9dcc Compare May 24, 2024 13:54
Comment on lines +119 to +120
bar = jsondecode(file("../../../bar.json"))
foo_foo_foo = yamldecode(file("../../../foo-fooFoo.yaml"))
Copy link
Owner Author

Choose a reason for hiding this comment

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

tf vars are tflint naming convention compliant

Comment on lines 520 to 525
if convertedNames[convertedName] {
errs = multierror.Append(errs, fmt.Errorf("files %v, Collision detected for converted filename: %s\n", convertedName, files))
} else {
Copy link
Owner Author

Choose a reason for hiding this comment

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

config validation detects variable name collisions

@vincenthsh vincenthsh force-pushed the feat-depends-on-file branch from 70f9dcc to 7043937 Compare May 24, 2024 14:11
- Add ability to depend on files
- Convert file names to terraform naming convention (snake_case).
- Validate file name collisions in config

implements #304
@vincenthsh vincenthsh force-pushed the feat-depends-on-file branch from 7043937 to 9fe63c1 Compare May 24, 2024 14:21
@vincenthsh vincenthsh enabled auto-merge (squash) May 24, 2024 14:31
@vincenthsh vincenthsh disabled auto-merge May 24, 2024 14:31
@vincenthsh vincenthsh merged commit 76fd9e3 into feat-multi-module-components May 24, 2024
3 checks passed
@vincenthsh vincenthsh deleted the feat-depends-on-file branch May 24, 2024 14:31
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.

1 participant