Skip to content

Commit

Permalink
Additional feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jpogran committed Jul 16, 2024
1 parent 360fbe5 commit 184b3bc
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
3 changes: 1 addition & 2 deletions internal/features/stacks/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (f *StacksFeature) decodeStack(ctx context.Context, dir document.DirHandle,
Func: func(ctx context.Context) error {
return jobs.LoadStackMetadata(ctx, f.store, path)
},
Type: operation.OpTypeLoadModuleMetadata.String(),
Type: operation.OpTypeLoadStackMetadata.String(),
DependsOn: job.IDs{parseId},
IgnoreState: ignoreState,
})
Expand All @@ -201,7 +201,6 @@ func (f *StacksFeature) decodeStack(ctx context.Context, dir document.DirHandle,
ids = append(ids, metaId)

// TODO: Implement the following functions where appropriate to stacks
// Future: LoadModuleMetadata(ctx, f.Store, path)
// Future: decodeDeclaredModuleCalls(ctx, dir, ignoreState)
// TODO: PreloadEmbeddedSchema(ctx, f.logger, schemas.FS,
// Future: DecodeReferenceTargets(ctx, f.Store, f.rootFeature, path)
Expand Down
18 changes: 11 additions & 7 deletions internal/features/stacks/state/stack_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ import (
tfstack "github.com/hashicorp/terraform-schema/stack"
)

// StackMetadata contains the result of the early decoding of a module,
// StackMetadata contains the result of the early decoding of a Stack,
// it will be used obtain the correct provider and related module schemas
type StackMetadata struct {
Filenames []string
Components map[string]tfstack.Component
Variables map[string]tfstack.Variable
Outputs map[string]tfstack.Output
Filenames []string
Components map[string]tfstack.Component
Variables map[string]tfstack.Variable
Outputs map[string]tfstack.Output
ProviderRequirements map[string]tfstack.ProviderRequirement
}

func (sm StackMetadata) Copy() StackMetadata {
newSm := StackMetadata{
// version.Constraints is practically immutable once parsed
Filenames: sm.Filenames,
Filenames: sm.Filenames,
Components: sm.Components,
Variables: sm.Variables,
Outputs: sm.Outputs,
ProviderRequirements: sm.ProviderRequirements,
}

return newSm
Expand Down
21 changes: 11 additions & 10 deletions internal/features/stacks/state/stack_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,26 +285,27 @@ func (s *StackStore) UpdateMetadata(path string, meta *tfstack.Meta, mErr error)
})
defer txn.Abort()

oldMod, err := stackByPath(txn, path)
oldRecord, err := stackByPath(txn, path)
if err != nil {
return err
}

mod := oldMod.Copy()
mod.Meta = StackMetadata{
Components: meta.Components,
Variables: meta.Variables,
Outputs: meta.Outputs,
Filenames: meta.Filenames,
record := oldRecord.Copy()
record.Meta = StackMetadata{
Components: meta.Components,
Variables: meta.Variables,
Outputs: meta.Outputs,
Filenames: meta.Filenames,
ProviderRequirements: meta.ProviderRequirements,
}
mod.MetaErr = mErr
record.MetaErr = mErr

err = txn.Insert(s.tableName, mod)
err = txn.Insert(s.tableName, record)
if err != nil {
return err
}

err = s.queueRecordChange(oldMod, mod)
err = s.queueRecordChange(oldRecord, record)
if err != nil {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions internal/terraform/module/operation/op_type_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/terraform/module/operation/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ const (
OpTypeReferenceValidation
OpTypeTerraformValidate
OpTypeParseStackConfiguration
OpTypeLoadStackMetadata
OpTypeLoadStackRequiredTerraformVersion
)

0 comments on commit 184b3bc

Please sign in to comment.