Skip to content

Commit 1d4fe76

Browse files
authored
feat: store early decoded deploy config and bump terraform-schema (#1798)
* feat: support storing early decoded deploy config * chore: add changie entry * Bump terraform-schema to `27f3526`
1 parent eec1f97 commit 1d4fe76

File tree

6 files changed

+32
-3
lines changed

6 files changed

+32
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: ENHANCEMENTS
2+
body: Early decode deployment config to support references to store blocks
3+
time: 2024-08-16T13:48:04.258277+02:00
4+
custom:
5+
Issue: "390"
6+
Repository: terraform-schema

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/hashicorp/terraform-exec v0.21.0
1919
github.com/hashicorp/terraform-json v0.22.1
2020
github.com/hashicorp/terraform-registry-address v0.2.3
21-
github.com/hashicorp/terraform-schema v0.0.0-20240815154350-b24c4f7b5a39
21+
github.com/hashicorp/terraform-schema v0.0.0-20240819084908-27f3526335d0
2222
github.com/mcuadros/go-defaults v1.2.0
2323
github.com/mh-cbon/go-fmt-fail v0.0.0-20160815164508-67765b3fbcb5
2424
github.com/mitchellh/cli v1.1.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7
229229
github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A=
230230
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
231231
github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
232-
github.com/hashicorp/terraform-schema v0.0.0-20240815154350-b24c4f7b5a39 h1:5N90p3PaMtyAuwXtTJPtdtKPxOfx7FIC/7zAzuvLfWs=
233-
github.com/hashicorp/terraform-schema v0.0.0-20240815154350-b24c4f7b5a39/go.mod h1:Tc8mlcXI3ulpnC1/Ho4O5DeivcXGfezj0U+igIDE3iA=
232+
github.com/hashicorp/terraform-schema v0.0.0-20240819084908-27f3526335d0 h1:OOg9n6z6hEFIbxAbSdJpb5k3+3M6D/GKckeXMbYI0Dk=
233+
github.com/hashicorp/terraform-schema v0.0.0-20240819084908-27f3526335d0/go.mod h1:Tc8mlcXI3ulpnC1/Ho4O5DeivcXGfezj0U+igIDE3iA=
234234
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
235235
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
236236
github.com/hexops/autogold v1.3.1 h1:YgxF9OHWbEIUjhDbpnLhgVsjUDsiHDTyDfy2lrfdlzo=

internal/features/stacks/decoder/path_reader.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ func stackPathContext(record *state.StackRecord, stateReader CombinedReader) (*d
8989
Variables: record.Meta.Variables,
9090
Outputs: record.Meta.Outputs,
9191
Filenames: record.Meta.Filenames,
92+
Deployments: record.Meta.Deployments,
93+
Stores: record.Meta.Stores,
9294
}
9395

9496
mergedSchema, err := sm.SchemaForStack(meta)
@@ -150,6 +152,8 @@ func deployPathContext(record *state.StackRecord) (*decoder.PathContext, error)
150152
Variables: record.Meta.Variables,
151153
Outputs: record.Meta.Outputs,
152154
Filenames: record.Meta.Filenames,
155+
Deployments: record.Meta.Deployments,
156+
Stores: record.Meta.Stores,
153157
}
154158

155159
mergedSchema, err := sm.SchemaForDeployment(meta)

internal/features/stacks/state/stack_meta.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ type StackMetadata struct {
1515
Variables map[string]tfstack.Variable
1616
Outputs map[string]tfstack.Output
1717
ProviderRequirements map[string]tfstack.ProviderRequirement
18+
19+
Deployments map[string]tfstack.Deployment
20+
Stores map[string]tfstack.Store
1821
}
1922

2023
func (sm StackMetadata) Copy() StackMetadata {
@@ -50,5 +53,19 @@ func (sm StackMetadata) Copy() StackMetadata {
5053
}
5154
}
5255

56+
if sm.Deployments != nil {
57+
newSm.Deployments = make(map[string]tfstack.Deployment, len(sm.Deployments))
58+
for k, v := range sm.Deployments {
59+
newSm.Deployments[k] = v
60+
}
61+
}
62+
63+
if sm.Stores != nil {
64+
newSm.Stores = make(map[string]tfstack.Store, len(sm.Stores))
65+
for k, v := range sm.Stores {
66+
newSm.Stores[k] = v
67+
}
68+
}
69+
5370
return newSm
5471
}

internal/features/stacks/state/stack_store.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ func (s *StackStore) UpdateMetadata(path string, meta *tfstack.Meta, mErr error)
301301
Outputs: meta.Outputs,
302302
Filenames: meta.Filenames,
303303
ProviderRequirements: meta.ProviderRequirements,
304+
Deployments: meta.Deployments,
305+
Stores: meta.Stores,
304306
}
305307
record.MetaErr = mErr
306308

0 commit comments

Comments
 (0)