diff --git a/internal/features/stacks/events.go b/internal/features/stacks/events.go index d90f59fc..94d5f8a2 100644 --- a/internal/features/stacks/events.go +++ b/internal/features/stacks/events.go @@ -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, }) @@ -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) diff --git a/internal/features/stacks/state/stack_meta.go b/internal/features/stacks/state/stack_meta.go index a82e2913..671fdabc 100644 --- a/internal/features/stacks/state/stack_meta.go +++ b/internal/features/stacks/state/stack_meta.go @@ -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 diff --git a/internal/features/stacks/state/stack_store.go b/internal/features/stacks/state/stack_store.go index fb9900fb..1f5a2696 100644 --- a/internal/features/stacks/state/stack_store.go +++ b/internal/features/stacks/state/stack_store.go @@ -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 } diff --git a/internal/terraform/module/operation/op_type_string.go b/internal/terraform/module/operation/op_type_string.go index e590c792..0e7e3dd3 100644 --- a/internal/terraform/module/operation/op_type_string.go +++ b/internal/terraform/module/operation/op_type_string.go @@ -27,12 +27,13 @@ func _() { _ = x[OpTypeReferenceValidation-16] _ = x[OpTypeTerraformValidate-17] _ = x[OpTypeParseStackConfiguration-18] - _ = x[OpTypeLoadStackRequiredTerraformVersion-19] + _ = x[OpTypeLoadStackMetadata-19] + _ = x[OpTypeLoadStackRequiredTerraformVersion-20] } -const _OpType_name = "OpTypeUnknownOpTypeGetTerraformVersionOpTypeGetInstalledTerraformVersionOpTypeObtainSchemaOpTypeParseModuleConfigurationOpTypeParseVariablesOpTypeParseModuleManifestOpTypeLoadModuleMetadataOpTypeDecodeReferenceTargetsOpTypeDecodeReferenceOriginsOpTypeDecodeVarsReferencesOpTypeGetModuleDataFromRegistryOpTypeParseProviderVersionsOpTypePreloadEmbeddedSchemaOpTypeSchemaModuleValidationOpTypeSchemaVarsValidationOpTypeReferenceValidationOpTypeTerraformValidateOpTypeParseStackConfigurationOpTypeLoadStackRequiredTerraformVersion" +const _OpType_name = "OpTypeUnknownOpTypeGetTerraformVersionOpTypeGetInstalledTerraformVersionOpTypeObtainSchemaOpTypeParseModuleConfigurationOpTypeParseVariablesOpTypeParseModuleManifestOpTypeLoadModuleMetadataOpTypeDecodeReferenceTargetsOpTypeDecodeReferenceOriginsOpTypeDecodeVarsReferencesOpTypeGetModuleDataFromRegistryOpTypeParseProviderVersionsOpTypePreloadEmbeddedSchemaOpTypeSchemaModuleValidationOpTypeSchemaVarsValidationOpTypeReferenceValidationOpTypeTerraformValidateOpTypeParseStackConfigurationOpTypeLoadStackMetadataOpTypeLoadStackRequiredTerraformVersion" -var _OpType_index = [...]uint16{0, 13, 38, 72, 90, 120, 140, 165, 189, 217, 245, 271, 302, 329, 356, 384, 410, 435, 458, 487, 526} +var _OpType_index = [...]uint16{0, 13, 38, 72, 90, 120, 140, 165, 189, 217, 245, 271, 302, 329, 356, 384, 410, 435, 458, 487, 510, 549} func (i OpType) String() string { if i >= OpType(len(_OpType_index)-1) { diff --git a/internal/terraform/module/operation/operation.go b/internal/terraform/module/operation/operation.go index 441e3bbc..75933754 100644 --- a/internal/terraform/module/operation/operation.go +++ b/internal/terraform/module/operation/operation.go @@ -36,5 +36,6 @@ const ( OpTypeReferenceValidation OpTypeTerraformValidate OpTypeParseStackConfiguration + OpTypeLoadStackMetadata OpTypeLoadStackRequiredTerraformVersion )