Skip to content

Commit bcb5ce1

Browse files
committed
Migrate schema package into tfsdk package
Reference: #76 This is now stuck at the below: ``` package github.com/hashicorp/terraform-plugin-framework/internal/proto6 imports github.com/hashicorp/terraform-plugin-framework/tfsdk imports github.com/hashicorp/terraform-plugin-framework/internal/proto6: import cycle not allowed ```
1 parent b61fdeb commit bcb5ce1

19 files changed

+68
-89
lines changed

internal/proto6/schema.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import (
55
"errors"
66
"sort"
77

8-
"github.com/hashicorp/terraform-plugin-framework/schema"
9-
8+
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
109
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
1110
"github.com/hashicorp/terraform-plugin-go/tftypes"
1211
)
1312

14-
// Schema returns the *tfprotov6.Schema equivalent of a schema.Schema. At least
13+
// Schema returns the *tfprotov6.Schema equivalent of a tfsdk.Schema. At least
1514
// one attribute must be set in the schema, or an error will be returned.
16-
func Schema(ctx context.Context, s schema.Schema) (*tfprotov6.Schema, error) {
15+
func Schema(ctx context.Context, s tfsdk.Schema) (*tfprotov6.Schema, error) {
1716
result := &tfprotov6.Schema{
1817
Version: s.Version,
1918
}
@@ -55,9 +54,9 @@ func Schema(ctx context.Context, s schema.Schema) (*tfprotov6.Schema, error) {
5554
}
5655

5756
// Attribute returns the *tfprotov6.SchemaAttribute equivalent of a
58-
// schema.Attribute. Errors will be tftypes.AttributePathErrors based on
57+
// tfsdk.Attribute. Errors will be tftypes.AttributePathErrors based on
5958
// `path`. `name` is the name of the attribute.
60-
func Attribute(ctx context.Context, name string, attr schema.Attribute, path *tftypes.AttributePath) (*tfprotov6.SchemaAttribute, error) {
59+
func Attribute(ctx context.Context, name string, attr tfsdk.Attribute, path *tftypes.AttributePath) (*tfprotov6.SchemaAttribute, error) {
6160
a := &tfprotov6.SchemaAttribute{
6261
Name: name,
6362
Required: attr.Required,
@@ -85,13 +84,13 @@ func Attribute(ctx context.Context, name string, attr schema.Attribute, path *tf
8584
}
8685
nm := attr.Attributes.GetNestingMode()
8786
switch nm {
88-
case schema.NestingModeSingle:
87+
case tfsdk.NestingModeSingle:
8988
object.Nesting = tfprotov6.SchemaObjectNestingModeSingle
90-
case schema.NestingModeList:
89+
case tfsdk.NestingModeList:
9190
object.Nesting = tfprotov6.SchemaObjectNestingModeList
92-
case schema.NestingModeSet:
91+
case tfsdk.NestingModeSet:
9392
object.Nesting = tfprotov6.SchemaObjectNestingModeSet
94-
case schema.NestingModeMap:
93+
case tfsdk.NestingModeMap:
9594
object.Nesting = tfprotov6.SchemaObjectNestingModeMap
9695
default:
9796
return nil, path.NewErrorf("unrecognized nesting mode %v", nm)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package schema
1+
package tfsdk
22

33
import (
44
"errors"

tfsdk/config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import (
66

77
"github.com/hashicorp/terraform-plugin-framework/attr"
88
"github.com/hashicorp/terraform-plugin-framework/internal/reflect"
9-
"github.com/hashicorp/terraform-plugin-framework/schema"
109
"github.com/hashicorp/terraform-plugin-go/tftypes"
1110
)
1211

1312
// Config represents a Terraform config.
1413
type Config struct {
1514
Raw tftypes.Value
16-
Schema schema.Schema
15+
Schema Schema
1716
}
1817

1918
// Get populates the struct passed as `target` with the entire config.

tfsdk/data_source.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package tfsdk
33
import (
44
"context"
55

6-
"github.com/hashicorp/terraform-plugin-framework/schema"
76
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
87
)
98

@@ -12,7 +11,7 @@ import (
1211
// return an instance of it in the map returned by Provider.GetDataSources.
1312
type DataSourceType interface {
1413
// GetSchema returns the schema for this data source.
15-
GetSchema(context.Context) (schema.Schema, []*tfprotov6.Diagnostic)
14+
GetSchema(context.Context) (Schema, []*tfprotov6.Diagnostic)
1615

1716
// NewDataSource instantiates a new DataSource of this DataSourceType.
1817
NewDataSource(context.Context, Provider) (DataSource, []*tfprotov6.Diagnostic)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package schema
1+
package tfsdk
22

33
import (
44
"fmt"

tfsdk/plan.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import (
66

77
"github.com/hashicorp/terraform-plugin-framework/attr"
88
"github.com/hashicorp/terraform-plugin-framework/internal/reflect"
9-
"github.com/hashicorp/terraform-plugin-framework/schema"
109
"github.com/hashicorp/terraform-plugin-go/tftypes"
1110
)
1211

1312
// Plan represents a Terraform plan.
1413
type Plan struct {
1514
Raw tftypes.Value
16-
Schema schema.Schema
15+
Schema Schema
1716
}
1817

1918
// Get populates the struct passed as `target` with the entire plan.

tfsdk/provider.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ package tfsdk
33
import (
44
"context"
55

6-
"github.com/hashicorp/terraform-plugin-framework/schema"
76
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
87
)
98

109
// Provider is the core interface that all Terraform providers must implement.
1110
type Provider interface {
1211
// GetSchema returns the schema for this provider's configuration. If
1312
// this provider has no configuration, return an empty schema.Schema.
14-
GetSchema(context.Context) (schema.Schema, []*tfprotov6.Diagnostic)
13+
GetSchema(context.Context) (Schema, []*tfprotov6.Diagnostic)
1514

1615
// Configure is called at the beginning of the provider lifecycle, when
1716
// Terraform sends to the provider the values the user specified in the
@@ -38,5 +37,5 @@ type Provider interface {
3837
type ProviderWithProviderMeta interface {
3938
Provider
4039
// GetMetaSchema returns the provider meta schema.
41-
GetMetaSchema(context.Context) (schema.Schema, []*tfprotov6.Diagnostic)
40+
GetMetaSchema(context.Context) (Schema, []*tfprotov6.Diagnostic)
4241
}

tfsdk/resource.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package tfsdk
33
import (
44
"context"
55

6-
"github.com/hashicorp/terraform-plugin-framework/schema"
76
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
87
)
98

@@ -12,7 +11,7 @@ import (
1211
// instance of it in the map returned by Provider.GeResources.
1312
type ResourceType interface {
1413
// GetSchema returns the schema for this resource.
15-
GetSchema(context.Context) (schema.Schema, []*tfprotov6.Diagnostic)
14+
GetSchema(context.Context) (Schema, []*tfprotov6.Diagnostic)
1615

1716
// NewResource instantiates a new Resource of this ResourceType.
1817
NewResource(context.Context, Provider) (Resource, []*tfprotov6.Diagnostic)

schema/schema.go renamed to tfsdk/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package schema
1+
package tfsdk
22

33
import (
44
"context"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package schema
1+
package tfsdk
22

33
import (
44
"testing"

0 commit comments

Comments
 (0)