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: store early decoded deploy config and bump terraform-schema #1798

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/ENHANCEMENTS-20240816-134804.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: ENHANCEMENTS
body: Early decode deployment config to support references to store blocks
time: 2024-08-16T13:48:04.258277+02:00
custom:
Issue: "390"
Repository: terraform-schema
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/hashicorp/terraform-exec v0.21.0
github.com/hashicorp/terraform-json v0.22.1
github.com/hashicorp/terraform-registry-address v0.2.3
github.com/hashicorp/terraform-schema v0.0.0-20240815154350-b24c4f7b5a39
github.com/hashicorp/terraform-schema v0.0.0-20240819084908-27f3526335d0
github.com/mcuadros/go-defaults v1.2.0
github.com/mh-cbon/go-fmt-fail v0.0.0-20160815164508-67765b3fbcb5
github.com/mitchellh/cli v1.1.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7
github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A=
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
github.com/hashicorp/terraform-schema v0.0.0-20240815154350-b24c4f7b5a39 h1:5N90p3PaMtyAuwXtTJPtdtKPxOfx7FIC/7zAzuvLfWs=
github.com/hashicorp/terraform-schema v0.0.0-20240815154350-b24c4f7b5a39/go.mod h1:Tc8mlcXI3ulpnC1/Ho4O5DeivcXGfezj0U+igIDE3iA=
github.com/hashicorp/terraform-schema v0.0.0-20240819084908-27f3526335d0 h1:OOg9n6z6hEFIbxAbSdJpb5k3+3M6D/GKckeXMbYI0Dk=
github.com/hashicorp/terraform-schema v0.0.0-20240819084908-27f3526335d0/go.mod h1:Tc8mlcXI3ulpnC1/Ho4O5DeivcXGfezj0U+igIDE3iA=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
github.com/hexops/autogold v1.3.1 h1:YgxF9OHWbEIUjhDbpnLhgVsjUDsiHDTyDfy2lrfdlzo=
Expand Down
4 changes: 4 additions & 0 deletions internal/features/stacks/decoder/path_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ func stackPathContext(record *state.StackRecord, stateReader CombinedReader) (*d
Variables: record.Meta.Variables,
Outputs: record.Meta.Outputs,
Filenames: record.Meta.Filenames,
Deployments: record.Meta.Deployments,
Stores: record.Meta.Stores,
}

mergedSchema, err := sm.SchemaForStack(meta)
Expand Down Expand Up @@ -150,6 +152,8 @@ func deployPathContext(record *state.StackRecord) (*decoder.PathContext, error)
Variables: record.Meta.Variables,
Outputs: record.Meta.Outputs,
Filenames: record.Meta.Filenames,
Deployments: record.Meta.Deployments,
Stores: record.Meta.Stores,
ansgarm marked this conversation as resolved.
Show resolved Hide resolved
}

mergedSchema, err := sm.SchemaForDeployment(meta)
Expand Down
17 changes: 17 additions & 0 deletions internal/features/stacks/state/stack_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ type StackMetadata struct {
Variables map[string]tfstack.Variable
Outputs map[string]tfstack.Output
ProviderRequirements map[string]tfstack.ProviderRequirement

Deployments map[string]tfstack.Deployment
Stores map[string]tfstack.Store
}

func (sm StackMetadata) Copy() StackMetadata {
Expand Down Expand Up @@ -50,5 +53,19 @@ func (sm StackMetadata) Copy() StackMetadata {
}
}

if sm.Deployments != nil {
newSm.Deployments = make(map[string]tfstack.Deployment, len(sm.Deployments))
for k, v := range sm.Deployments {
newSm.Deployments[k] = v
}
}

if sm.Stores != nil {
newSm.Stores = make(map[string]tfstack.Store, len(sm.Stores))
for k, v := range sm.Stores {
newSm.Stores[k] = v
}
}

return newSm
}
2 changes: 2 additions & 0 deletions internal/features/stacks/state/stack_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ func (s *StackStore) UpdateMetadata(path string, meta *tfstack.Meta, mErr error)
Outputs: meta.Outputs,
Filenames: meta.Filenames,
ProviderRequirements: meta.ProviderRequirements,
Deployments: meta.Deployments,
Stores: meta.Stores,
}
record.MetaErr = mErr

Expand Down