Skip to content

Commit

Permalink
Revert the depends_on change
Browse files Browse the repository at this point in the history
It causes data sources to be read too late resulting in unexpected changes.

See https://itnext.io/beware-of-depends-on-for-modules-it-might-bite-you-da4741caac70
  • Loading branch information
mvantellingen committed Feb 15, 2023
1 parent 89d4359 commit 13a8904
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 79 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 2.6.6 (2023-02-14)
- Revert the `depends_on` change since it causes data sources to be read too
late resulting in unexpected changes.
See https://itnext.io/beware-of-depends-on-for-modules-it-might-bite-you-da4741caac70

## 2.6.5 (2023-02-14)
- Set `depends_on` on components (modules) when output variables are used. This
turned out to be neccessary when the variables were used in data sources.
Expand Down
36 changes: 0 additions & 36 deletions internal/generator/finder.go

This file was deleted.

31 changes: 0 additions & 31 deletions internal/generator/finder_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion internal/generator/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func renderComponent(cfg *config.MachConfig, site *config.SiteConfig, component
Source: component.Definition.Source,
PluginResources: []string{},
PluginVariables: []string{},
PluginDependsOn: findDependsOn(component.Variables),
PluginDependsOn: []string{},
PluginProviders: []string{},
}

Expand Down
11 changes: 0 additions & 11 deletions internal/generator/hcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
)

var regexVars = regexp.MustCompilePOSIX(`"\$\$\{([^\}]+)\}"`)
var regexTFVar = regexp.MustCompilePOSIX(`\$\{([^\}]+)\}`)

func serializeToHCL(attributeName string, data any) (string, error) {
val, err := asCTY(data)
Expand Down Expand Up @@ -55,13 +54,3 @@ func asCTY(source any) (cty.Value, error) {

return ctyJsonVal.Value, nil
}

func findVariables(input string) []string {
matches := regexTFVar.FindAllStringSubmatch(input, -1)
result := []string{}
for _, match := range matches {
item := match[1]
result = append(result, item)
}
return result
}

0 comments on commit 13a8904

Please sign in to comment.