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

stacks: schema merge remote component sources #406

Merged
merged 1 commit into from
Oct 29, 2024
Merged
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
20 changes: 20 additions & 0 deletions schema/stacks/stack_schema_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ type StateReader interface {
// from different sources.
ProviderSchema(modPath string, addr tfaddr.Provider, vc version.Constraints) (*tfschema.ProviderSchema, error)

// InstalledModulePath checks if there is an installed module available for
// the given normalized source address.
InstalledModulePath(rootPath string, normalizedSource string) (string, bool)

// LocalModuleMeta returns the module meta data for a local module. This is the result
// of the [earlydecoder] when processing module files
LocalModuleMeta(modPath string) (*tfmod.Meta, error)
Expand Down Expand Up @@ -127,6 +131,22 @@ func (m *StackSchemaMerger) SchemaForStack(meta *stack.Meta) (*schema.BodySchema
mergedSchema.Blocks["component"].DependentBody[schema.NewSchemaKey(depKeys)] = depSchema
}
}
case tfmod.RemoteSourceAddr:
installedDir, ok := m.stateReader.InstalledModulePath(meta.Path, sourceAddr.String())
if !ok {
continue
}
path := filepath.Join(meta.Path, installedDir)

// TODO: how to ensure this dir is parsed and available?
modMeta, err := m.stateReader.LocalModuleMeta(path)
if err == nil {
depSchema, err := schemaForDependentComponentBlock(modMeta, comp, name)
if err == nil {
mergedSchema.Blocks["component"].DependentBody[schema.NewSchemaKey(depKeys)] = depSchema
}
}
// TODO: do the same for tfaddr.Module (i.e. registry modules)
}
}

Expand Down