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

[Feature] Introduced Terraform Plugin Framework #3751

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ac375fa
temp work
tanmay-db Mar 27, 2024
b1dacae
-
tanmay-db Mar 27, 2024
f7b6a7e
mux support added, compiling works
tanmay-db Mar 27, 2024
232cb55
temp work
tanmay-db Apr 2, 2024
9f657ef
-
tanmay-db Apr 25, 2024
fef1b40
cleanup
tanmay-db Apr 25, 2024
c7be1a6
-
tanmay-db Apr 26, 2024
e3a5bf0
Merge branch 'main' of github.com:databricks/terraform-provider-datab…
tanmay-db Apr 26, 2024
7a6dc2d
more work
tanmay-db May 28, 2024
4b5966c
-
tanmay-db May 28, 2024
356fbbe
-
tanmay-db May 28, 2024
483eb99
added isolation mode support for `databricks_external_location` & `da…
nkvuong Jun 28, 2024
03c71d0
Add terraform support for periodic triggers (#3700)
alexmos-db Jun 28, 2024
f42e1fb
Release v1.48.2 (#3722)
hectorcast-db Jun 28, 2024
d669d7a
remove references to basic auth (#3720)
nkvuong Jun 30, 2024
0c252d4
Fix invalid priviledges in grants.md (#3716)
rayalex Jun 30, 2024
1ba1772
Bump github.com/hashicorp/hcl/v2 from 2.20.1 to 2.21.0 (#3684)
dependabot[bot] Jul 1, 2024
df210b2
Refactored `databricks_cluster(s)` data sources to Go SDK (#3685)
nkvuong Jul 1, 2024
fc889cc
Renamed `databricks_catalog_workspace_binding` to `databricks_workspa…
nkvuong Jul 2, 2024
c6f949c
Exporter: fix generation of `run_as` blocks in `databricks_job` (#3724)
alexott Jul 2, 2024
ff837ab
Adds `databricks_volume` as data source (#3211)
karolusz Jul 3, 2024
0d943ea
Make the schedule.pause_status field read-only (#3692)
touchida Jul 3, 2024
75236a6
Added support for binding storage credentials and external locations …
nkvuong Jul 3, 2024
411f85c
Exporter: use Go SDK structs for `databricks_job` resource (#3727)
alexott Jul 4, 2024
e864065
Change TF registry ownership (#3736)
mgyucht Jul 4, 2024
dfede1a
resolve merge conflicts
tanmay-db Jul 4, 2024
4fdaace
update
tanmay-db Jul 4, 2024
5980fb2
wip
tanmay-db Jul 9, 2024
3b0c0ab
-
tanmay-db Jul 18, 2024
250da8b
-
tanmay-db Jul 18, 2024
a83c471
resolve bug
tanmay-db Jul 19, 2024
0aa0f7b
fix bug
tanmay-db Jul 22, 2024
5c56917
Merge branch 'terraform-plugin-framework' of github.com:databricks/te…
tanmay-db Jul 22, 2024
38c264b
-
tanmay-db Jul 22, 2024
49349bf
fix
tanmay-db Jul 22, 2024
b443076
All passing Unit Tests
tanmay-db Jul 22, 2024
6181245
-
tanmay-db Jul 23, 2024
60aacbc
-
tanmay-db Jul 23, 2024
ac455e6
-
tanmay-db Jul 23, 2024
5b8a9b0
debug
tanmay-db Jul 23, 2024
d95b670
Merge branch 'terraform-plugin-framework' of github.com:databricks/te…
tanmay-db Jul 24, 2024
9e915b4
-
tanmay-db Jul 24, 2024
b165dcf
apply working
tanmay-db Jul 26, 2024
d642880
TF Apply works
tanmay-db Jul 28, 2024
d6536ef
-
tanmay-db Jul 28, 2024
4f3b923
-
tanmay-db Jul 29, 2024
b35195c
-
tanmay-db Jul 29, 2024
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
2 changes: 1 addition & 1 deletion common/customizable_schema_plugin_framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"reflect"

"github.com/hashicorp/terraform-plugin-framework/provider/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
)

type CustomizableSchemaPluginFramework struct {
Expand Down
4 changes: 2 additions & 2 deletions common/customizable_schema_plugin_framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-framework/provider/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -46,7 +46,7 @@ func (v stringLengthBetweenValidator) ValidateString(ctx context.Context, req va
}

func TestCustomizeSchema(t *testing.T) {
scm := pluginFrameworkStructToSchema(DummyTfSdk{}, func(c CustomizableSchemaPluginFramework) CustomizableSchemaPluginFramework {
scm := PluginFrameworkResourceStructToSchema(DummyTfSdk{}, func(c CustomizableSchemaPluginFramework) CustomizableSchemaPluginFramework {
c.AddNewField("new_field", schema.StringAttribute{Required: true})
c.AddNewField("new_field", schema.StringAttribute{Required: true}, "nested")
c.AddNewField("to_be_removed", schema.StringAttribute{Required: true}, "nested")
Expand Down
25 changes: 15 additions & 10 deletions common/reflect_resource_plugin_framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"reflect"
"strings"

"github.com/hashicorp/terraform-plugin-framework/provider/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
)

Expand Down Expand Up @@ -297,7 +297,7 @@ func checkTheStringInForceSendFields(fieldName string, forceSendFields []string)
return false
}

func pluginFrameworkTypeToSchema(v reflect.Value) map[string]schema.Attribute {
func pluginFrameworkResourceTypeToSchema(v reflect.Value) map[string]schema.Attribute {
scm := map[string]schema.Attribute{}
rk := v.Kind()
if rk == reflect.Ptr {
Expand All @@ -320,7 +320,7 @@ func pluginFrameworkTypeToSchema(v reflect.Value) map[string]schema.Attribute {
if kind == reflect.Ptr {
elem := typeField.Type.Elem()
sv := reflect.New(elem).Elem()
nestedScm := pluginFrameworkTypeToSchema(sv)
nestedScm := pluginFrameworkResourceTypeToSchema(sv)
scm[fieldName] = schema.SingleNestedAttribute{Attributes: nestedScm, Optional: isOptional, Required: !isOptional}
} else if kind == reflect.Slice {
elem := typeField.Type.Elem()
Expand All @@ -341,7 +341,7 @@ func pluginFrameworkTypeToSchema(v reflect.Value) map[string]schema.Attribute {
scm[fieldName] = schema.ListAttribute{ElementType: types.StringType, Optional: isOptional, Required: !isOptional}
default:
// Nested struct
nestedScm := pluginFrameworkTypeToSchema(reflect.New(elem).Elem())
nestedScm := pluginFrameworkResourceTypeToSchema(reflect.New(elem).Elem())
scm[fieldName] = schema.ListNestedAttribute{NestedObject: schema.NestedAttributeObject{Attributes: nestedScm}, Optional: isOptional, Required: !isOptional}
}
} else if kind == reflect.Map {
Expand All @@ -363,7 +363,7 @@ func pluginFrameworkTypeToSchema(v reflect.Value) map[string]schema.Attribute {
scm[fieldName] = schema.MapAttribute{ElementType: types.StringType, Optional: isOptional, Required: !isOptional}
default:
// Nested struct
nestedScm := pluginFrameworkTypeToSchema(reflect.New(elem).Elem())
nestedScm := pluginFrameworkResourceTypeToSchema(reflect.New(elem).Elem())
scm[fieldName] = schema.MapNestedAttribute{NestedObject: schema.NestedAttributeObject{Attributes: nestedScm}, Optional: isOptional, Required: !isOptional}
}
} else if kind == reflect.Struct {
Expand All @@ -384,7 +384,7 @@ func pluginFrameworkTypeToSchema(v reflect.Value) map[string]schema.Attribute {
// If it is a real stuct instead of a tfsdk type, recursively resolve it.
elem := typeField.Type
sv := reflect.New(elem)
nestedScm := pluginFrameworkTypeToSchema(sv)
nestedScm := pluginFrameworkResourceTypeToSchema(sv)
scm[fieldName] = schema.SingleNestedAttribute{Attributes: nestedScm, Optional: isOptional, Required: !isOptional}
}
} else if kind == reflect.String {
Expand All @@ -402,13 +402,18 @@ func fieldIsOptional(field reflect.StructField) bool {
return strings.Contains(tagValue, "optional")
}

func pluginFrameworkStructToSchema(v any, customizeSchema func(CustomizableSchemaPluginFramework) CustomizableSchemaPluginFramework) schema.Schema {
attributes := pluginFrameworkTypeToSchema(reflect.ValueOf(v))
func PluginFrameworkResourceStructToSchema(v any, customizeSchema func(CustomizableSchemaPluginFramework) CustomizableSchemaPluginFramework) schema.Schema {
attributes := PluginFrameworkResourceStructToSchemaMap(v, customizeSchema)
return schema.Schema{Attributes: attributes}
}

func PluginFrameworkResourceStructToSchemaMap(v any, customizeSchema func(CustomizableSchemaPluginFramework) CustomizableSchemaPluginFramework) map[string]schema.Attribute {
attributes := pluginFrameworkResourceTypeToSchema(reflect.ValueOf(v))

if customizeSchema != nil {
cs := customizeSchema(*ConstructCustomizableSchema(attributes))
return schema.Schema{Attributes: cs.ToAttributeMap()}
return cs.ToAttributeMap()
} else {
return schema.Schema{Attributes: attributes}
return attributes
}
}
2 changes: 1 addition & 1 deletion common/reflect_resource_plugin_framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ var tfSdkStruct = DummyTfSdk{

func TestGetAndSetPluginFramework(t *testing.T) {
// Also test StructToSchema.
scm := pluginFrameworkStructToSchema(DummyTfSdk{}, nil)
scm := PluginFrameworkResourceStructToSchema(DummyTfSdk{}, nil)
state := tfsdk.State{
Schema: scm,
}
Expand Down
50 changes: 26 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ require (
golang.org/x/mod v0.19.0
)

require golang.org/x/sync v0.7.0 // indirect

require (
cloud.google.com/go/auth v0.4.2 // indirect
cloud.google.com/go/auth v0.6.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
cloud.google.com/go/compute/metadata v0.4.0 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.3-proton // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cloudflare/circl v1.3.9 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
Expand All @@ -42,12 +44,12 @@ require (
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-plugin v1.6.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.6.4 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hc-install v0.7.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.22.1 // indirect
Expand All @@ -68,22 +70,22 @@ require (
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.18.0 // indirect
google.golang.org/api v0.182.0 // indirect
golang.org/x/tools v0.22.0 // indirect
google.golang.org/api v0.187.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading