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

chore: Expose typeBelongsToProvider to outside callers #443

Merged
merged 1 commit into from
Jan 17, 2025
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
10 changes: 5 additions & 5 deletions schema/schema_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (m *SchemaMerger) SchemaForModule(meta *tfmod.Meta) (*schema.BodySchema, er

// No explicit association is required
// if the resource prefix matches provider name
if typeBelongsToProvider(rName, localRef) {
if TypeBelongsToProvider(rName, localRef) {
depKeys := schema.DependencyKeys{
Labels: []schema.LabelDependent{
{Index: 0, Value: rName},
Expand Down Expand Up @@ -168,7 +168,7 @@ func (m *SchemaMerger) SchemaForModule(meta *tfmod.Meta) (*schema.BodySchema, er

// No explicit association is required
// if the ephemeral resource prefix matches provider name
if typeBelongsToProvider(erName, localRef) {
if TypeBelongsToProvider(erName, localRef) {
depKeys := schema.DependencyKeys{
Labels: []schema.LabelDependent{
{Index: 0, Value: erName},
Expand Down Expand Up @@ -222,7 +222,7 @@ func (m *SchemaMerger) SchemaForModule(meta *tfmod.Meta) (*schema.BodySchema, er

// No explicit association is required
// if the resource prefix matches provider name
if typeBelongsToProvider(dsName, localRef) {
if TypeBelongsToProvider(dsName, localRef) {
depKeys := schema.DependencyKeys{
Labels: []schema.LabelDependent{
{Index: 0, Value: dsName},
Expand Down Expand Up @@ -329,12 +329,12 @@ func (m *SchemaMerger) SchemaForModule(meta *tfmod.Meta) (*schema.BodySchema, er
return mergedSchema, nil
}

// typeBelongsToProvider returns true if the given type
// TypeBelongsToProvider returns true if the given type
// (resource or data source) name belongs to a particular provider.
//
// This reflects internal implementation in Terraform at
// https://github.com/hashicorp/terraform/blob/488bbd80/internal/addrs/resource.go#L68-L77
func typeBelongsToProvider(typeName string, pRef tfmod.ProviderRef) bool {
func TypeBelongsToProvider(typeName string, pRef tfmod.ProviderRef) bool {
return typeName == pRef.LocalName || strings.HasPrefix(typeName, pRef.LocalName+"_")
}

Expand Down
Loading