Skip to content

Commit 58dfa70

Browse files
authored
Upgrade TF provider to 1.61.0 (#2011)
## Changes Upgraded to TF provider 1.61.0 ### New Features and Improvements - Added databricks_app resource and data source (databricks/terraform-provider-databricks#4099). - Added databricks_credentials resource and data source
1 parent 4e95cb2 commit 58dfa70

20 files changed

+440
-44
lines changed

bundle/internal/tf/codegen/generator/walker.go

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ package generator
22

33
import (
44
"fmt"
5-
"strings"
6-
75
"slices"
6+
"strings"
87

98
tfjson "github.com/hashicorp/terraform-json"
109
"github.com/iancoleman/strcase"
@@ -70,6 +69,25 @@ func nestedBlockKeys(block *tfjson.SchemaBlock) []string {
7069
return keys
7170
}
7271

72+
func nestedField(name []string, k string, isRef bool) field {
73+
// Collect field properties.
74+
fieldName := strcase.ToCamel(k)
75+
fieldTypePrefix := ""
76+
if isRef {
77+
fieldTypePrefix = "*"
78+
} else {
79+
fieldTypePrefix = "[]"
80+
}
81+
fieldType := fmt.Sprintf("%s%s", fieldTypePrefix, strings.Join(append(name, strcase.ToCamel(k)), ""))
82+
fieldTag := fmt.Sprintf("%s,omitempty", k)
83+
84+
return field{
85+
Name: fieldName,
86+
Type: fieldType,
87+
Tag: fieldTag,
88+
}
89+
}
90+
7391
func (w *walker) walk(block *tfjson.SchemaBlock, name []string) error {
7492
// Produce nested types before this block itself.
7593
// This ensures types are defined before they are referenced.
@@ -91,10 +109,24 @@ func (w *walker) walk(block *tfjson.SchemaBlock, name []string) error {
91109
v := block.Attributes[k]
92110

93111
// Assert the attribute type is always set.
94-
if v.AttributeType == cty.NilType {
112+
if v.AttributeType == cty.NilType && v.AttributeNestedType == nil {
95113
return fmt.Errorf("unexpected nil type for attribute %s", k)
96114
}
97115

116+
// If there is a nested type, walk it and continue to next attribute.
117+
if v.AttributeNestedType != nil {
118+
nestedBlock := &tfjson.SchemaBlock{
119+
Attributes: v.AttributeNestedType.Attributes,
120+
}
121+
err := w.walk(nestedBlock, append(name, strcase.ToCamel(k)))
122+
if err != nil {
123+
return err
124+
}
125+
// Append to list of fields for type.
126+
typ.Fields = append(typ.Fields, nestedField(name, k, v.AttributeNestedType.NestingMode == tfjson.SchemaNestingModeSingle))
127+
continue
128+
}
129+
98130
// Collect field properties.
99131
fieldName := strcase.ToCamel(k)
100132
fieldType := processAttributeType(v.AttributeType)
@@ -117,24 +149,8 @@ func (w *walker) walk(block *tfjson.SchemaBlock, name []string) error {
117149
// Declare nested blocks.
118150
for _, k := range nestedBlockKeys(block) {
119151
v := block.NestedBlocks[k]
120-
121-
// Collect field properties.
122-
fieldName := strcase.ToCamel(k)
123-
fieldTypePrefix := ""
124-
if v.MaxItems == 1 {
125-
fieldTypePrefix = "*"
126-
} else {
127-
fieldTypePrefix = "[]"
128-
}
129-
fieldType := fmt.Sprintf("%s%s", fieldTypePrefix, strings.Join(append(name, strcase.ToCamel(k)), ""))
130-
fieldTag := fmt.Sprintf("%s,omitempty", k)
131-
132152
// Append to list of fields for type.
133-
typ.Fields = append(typ.Fields, field{
134-
Name: fieldName,
135-
Type: fieldType,
136-
Tag: fieldTag,
137-
})
153+
typ.Fields = append(typ.Fields, nestedField(name, k, v.MaxItems == 1))
138154
}
139155

140156
// Append type to list of structs.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package schema
22

3-
const ProviderVersion = "1.59.0"
3+
const ProviderVersion = "1.61.0"

bundle/internal/tf/codegen/templates/root.go.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ const ProviderVersion = "{{ .ProviderVersion }}"
2525

2626
func NewRoot() *Root {
2727
return &Root{
28-
Terraform: map[string]interface{}{
29-
"required_providers": map[string]interface{}{
30-
"databricks": map[string]interface{}{
28+
Terraform: map[string]any{
29+
"required_providers": map[string]any{
30+
"databricks": map[string]any{
3131
"source": ProviderSource,
3232
"version": ProviderVersion,
3333
},
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// Generated from Databricks Terraform provider schema. DO NOT EDIT.
2+
3+
package schema
4+
5+
type DataSourceAppAppActiveDeploymentDeploymentArtifacts struct {
6+
SourceCodePath string `json:"source_code_path,omitempty"`
7+
}
8+
9+
type DataSourceAppAppActiveDeploymentStatus struct {
10+
Message string `json:"message,omitempty"`
11+
State string `json:"state,omitempty"`
12+
}
13+
14+
type DataSourceAppAppActiveDeployment struct {
15+
CreateTime string `json:"create_time,omitempty"`
16+
Creator string `json:"creator,omitempty"`
17+
DeploymentArtifacts *DataSourceAppAppActiveDeploymentDeploymentArtifacts `json:"deployment_artifacts,omitempty"`
18+
DeploymentId string `json:"deployment_id,omitempty"`
19+
Mode string `json:"mode,omitempty"`
20+
SourceCodePath string `json:"source_code_path,omitempty"`
21+
Status *DataSourceAppAppActiveDeploymentStatus `json:"status,omitempty"`
22+
UpdateTime string `json:"update_time,omitempty"`
23+
}
24+
25+
type DataSourceAppAppAppStatus struct {
26+
Message string `json:"message,omitempty"`
27+
State string `json:"state,omitempty"`
28+
}
29+
30+
type DataSourceAppAppComputeStatus struct {
31+
Message string `json:"message,omitempty"`
32+
State string `json:"state,omitempty"`
33+
}
34+
35+
type DataSourceAppAppPendingDeploymentDeploymentArtifacts struct {
36+
SourceCodePath string `json:"source_code_path,omitempty"`
37+
}
38+
39+
type DataSourceAppAppPendingDeploymentStatus struct {
40+
Message string `json:"message,omitempty"`
41+
State string `json:"state,omitempty"`
42+
}
43+
44+
type DataSourceAppAppPendingDeployment struct {
45+
CreateTime string `json:"create_time,omitempty"`
46+
Creator string `json:"creator,omitempty"`
47+
DeploymentArtifacts *DataSourceAppAppPendingDeploymentDeploymentArtifacts `json:"deployment_artifacts,omitempty"`
48+
DeploymentId string `json:"deployment_id,omitempty"`
49+
Mode string `json:"mode,omitempty"`
50+
SourceCodePath string `json:"source_code_path,omitempty"`
51+
Status *DataSourceAppAppPendingDeploymentStatus `json:"status,omitempty"`
52+
UpdateTime string `json:"update_time,omitempty"`
53+
}
54+
55+
type DataSourceAppAppResourcesJob struct {
56+
Id string `json:"id"`
57+
Permission string `json:"permission"`
58+
}
59+
60+
type DataSourceAppAppResourcesSecret struct {
61+
Key string `json:"key"`
62+
Permission string `json:"permission"`
63+
Scope string `json:"scope"`
64+
}
65+
66+
type DataSourceAppAppResourcesServingEndpoint struct {
67+
Name string `json:"name"`
68+
Permission string `json:"permission"`
69+
}
70+
71+
type DataSourceAppAppResourcesSqlWarehouse struct {
72+
Id string `json:"id"`
73+
Permission string `json:"permission"`
74+
}
75+
76+
type DataSourceAppAppResources struct {
77+
Description string `json:"description,omitempty"`
78+
Job *DataSourceAppAppResourcesJob `json:"job,omitempty"`
79+
Name string `json:"name"`
80+
Secret *DataSourceAppAppResourcesSecret `json:"secret,omitempty"`
81+
ServingEndpoint *DataSourceAppAppResourcesServingEndpoint `json:"serving_endpoint,omitempty"`
82+
SqlWarehouse *DataSourceAppAppResourcesSqlWarehouse `json:"sql_warehouse,omitempty"`
83+
}
84+
85+
type DataSourceAppApp struct {
86+
ActiveDeployment *DataSourceAppAppActiveDeployment `json:"active_deployment,omitempty"`
87+
AppStatus *DataSourceAppAppAppStatus `json:"app_status,omitempty"`
88+
ComputeStatus *DataSourceAppAppComputeStatus `json:"compute_status,omitempty"`
89+
CreateTime string `json:"create_time,omitempty"`
90+
Creator string `json:"creator,omitempty"`
91+
DefaultSourceCodePath string `json:"default_source_code_path,omitempty"`
92+
Description string `json:"description,omitempty"`
93+
Name string `json:"name"`
94+
PendingDeployment *DataSourceAppAppPendingDeployment `json:"pending_deployment,omitempty"`
95+
Resources []DataSourceAppAppResources `json:"resources,omitempty"`
96+
ServicePrincipalClientId string `json:"service_principal_client_id,omitempty"`
97+
ServicePrincipalId int `json:"service_principal_id,omitempty"`
98+
ServicePrincipalName string `json:"service_principal_name,omitempty"`
99+
UpdateTime string `json:"update_time,omitempty"`
100+
Updater string `json:"updater,omitempty"`
101+
Url string `json:"url,omitempty"`
102+
}
103+
104+
type DataSourceApp struct {
105+
App *DataSourceAppApp `json:"app,omitempty"`
106+
Name string `json:"name"`
107+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Generated from Databricks Terraform provider schema. DO NOT EDIT.
2+
3+
package schema
4+
5+
type DataSourceAppsAppActiveDeploymentDeploymentArtifacts struct {
6+
SourceCodePath string `json:"source_code_path,omitempty"`
7+
}
8+
9+
type DataSourceAppsAppActiveDeploymentStatus struct {
10+
Message string `json:"message,omitempty"`
11+
State string `json:"state,omitempty"`
12+
}
13+
14+
type DataSourceAppsAppActiveDeployment struct {
15+
CreateTime string `json:"create_time,omitempty"`
16+
Creator string `json:"creator,omitempty"`
17+
DeploymentArtifacts *DataSourceAppsAppActiveDeploymentDeploymentArtifacts `json:"deployment_artifacts,omitempty"`
18+
DeploymentId string `json:"deployment_id,omitempty"`
19+
Mode string `json:"mode,omitempty"`
20+
SourceCodePath string `json:"source_code_path,omitempty"`
21+
Status *DataSourceAppsAppActiveDeploymentStatus `json:"status,omitempty"`
22+
UpdateTime string `json:"update_time,omitempty"`
23+
}
24+
25+
type DataSourceAppsAppAppStatus struct {
26+
Message string `json:"message,omitempty"`
27+
State string `json:"state,omitempty"`
28+
}
29+
30+
type DataSourceAppsAppComputeStatus struct {
31+
Message string `json:"message,omitempty"`
32+
State string `json:"state,omitempty"`
33+
}
34+
35+
type DataSourceAppsAppPendingDeploymentDeploymentArtifacts struct {
36+
SourceCodePath string `json:"source_code_path,omitempty"`
37+
}
38+
39+
type DataSourceAppsAppPendingDeploymentStatus struct {
40+
Message string `json:"message,omitempty"`
41+
State string `json:"state,omitempty"`
42+
}
43+
44+
type DataSourceAppsAppPendingDeployment struct {
45+
CreateTime string `json:"create_time,omitempty"`
46+
Creator string `json:"creator,omitempty"`
47+
DeploymentArtifacts *DataSourceAppsAppPendingDeploymentDeploymentArtifacts `json:"deployment_artifacts,omitempty"`
48+
DeploymentId string `json:"deployment_id,omitempty"`
49+
Mode string `json:"mode,omitempty"`
50+
SourceCodePath string `json:"source_code_path,omitempty"`
51+
Status *DataSourceAppsAppPendingDeploymentStatus `json:"status,omitempty"`
52+
UpdateTime string `json:"update_time,omitempty"`
53+
}
54+
55+
type DataSourceAppsAppResourcesJob struct {
56+
Id string `json:"id"`
57+
Permission string `json:"permission"`
58+
}
59+
60+
type DataSourceAppsAppResourcesSecret struct {
61+
Key string `json:"key"`
62+
Permission string `json:"permission"`
63+
Scope string `json:"scope"`
64+
}
65+
66+
type DataSourceAppsAppResourcesServingEndpoint struct {
67+
Name string `json:"name"`
68+
Permission string `json:"permission"`
69+
}
70+
71+
type DataSourceAppsAppResourcesSqlWarehouse struct {
72+
Id string `json:"id"`
73+
Permission string `json:"permission"`
74+
}
75+
76+
type DataSourceAppsAppResources struct {
77+
Description string `json:"description,omitempty"`
78+
Job *DataSourceAppsAppResourcesJob `json:"job,omitempty"`
79+
Name string `json:"name"`
80+
Secret *DataSourceAppsAppResourcesSecret `json:"secret,omitempty"`
81+
ServingEndpoint *DataSourceAppsAppResourcesServingEndpoint `json:"serving_endpoint,omitempty"`
82+
SqlWarehouse *DataSourceAppsAppResourcesSqlWarehouse `json:"sql_warehouse,omitempty"`
83+
}
84+
85+
type DataSourceAppsApp struct {
86+
ActiveDeployment *DataSourceAppsAppActiveDeployment `json:"active_deployment,omitempty"`
87+
AppStatus *DataSourceAppsAppAppStatus `json:"app_status,omitempty"`
88+
ComputeStatus *DataSourceAppsAppComputeStatus `json:"compute_status,omitempty"`
89+
CreateTime string `json:"create_time,omitempty"`
90+
Creator string `json:"creator,omitempty"`
91+
DefaultSourceCodePath string `json:"default_source_code_path,omitempty"`
92+
Description string `json:"description,omitempty"`
93+
Name string `json:"name"`
94+
PendingDeployment *DataSourceAppsAppPendingDeployment `json:"pending_deployment,omitempty"`
95+
Resources []DataSourceAppsAppResources `json:"resources,omitempty"`
96+
ServicePrincipalClientId string `json:"service_principal_client_id,omitempty"`
97+
ServicePrincipalId int `json:"service_principal_id,omitempty"`
98+
ServicePrincipalName string `json:"service_principal_name,omitempty"`
99+
UpdateTime string `json:"update_time,omitempty"`
100+
Updater string `json:"updater,omitempty"`
101+
Url string `json:"url,omitempty"`
102+
}
103+
104+
type DataSourceApps struct {
105+
App []DataSourceAppsApp `json:"app,omitempty"`
106+
}

bundle/internal/tf/schema/data_source_functions.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,30 @@ type DataSourceFunctionsFunctions struct {
6969
FullDataType string `json:"full_data_type,omitempty"`
7070
FullName string `json:"full_name,omitempty"`
7171
FunctionId string `json:"function_id,omitempty"`
72+
InputParams []DataSourceFunctionsFunctionsInputParams `json:"input_params,omitempty"`
7273
IsDeterministic bool `json:"is_deterministic,omitempty"`
7374
IsNullCall bool `json:"is_null_call,omitempty"`
7475
MetastoreId string `json:"metastore_id,omitempty"`
7576
Name string `json:"name,omitempty"`
7677
Owner string `json:"owner,omitempty"`
7778
ParameterStyle string `json:"parameter_style,omitempty"`
7879
Properties string `json:"properties,omitempty"`
80+
ReturnParams []DataSourceFunctionsFunctionsReturnParams `json:"return_params,omitempty"`
7981
RoutineBody string `json:"routine_body,omitempty"`
8082
RoutineDefinition string `json:"routine_definition,omitempty"`
83+
RoutineDependencies []DataSourceFunctionsFunctionsRoutineDependencies `json:"routine_dependencies,omitempty"`
8184
SchemaName string `json:"schema_name,omitempty"`
8285
SecurityType string `json:"security_type,omitempty"`
8386
SpecificName string `json:"specific_name,omitempty"`
8487
SqlDataAccess string `json:"sql_data_access,omitempty"`
8588
SqlPath string `json:"sql_path,omitempty"`
8689
UpdatedAt int `json:"updated_at,omitempty"`
8790
UpdatedBy string `json:"updated_by,omitempty"`
88-
InputParams []DataSourceFunctionsFunctionsInputParams `json:"input_params,omitempty"`
89-
ReturnParams []DataSourceFunctionsFunctionsReturnParams `json:"return_params,omitempty"`
90-
RoutineDependencies []DataSourceFunctionsFunctionsRoutineDependencies `json:"routine_dependencies,omitempty"`
9191
}
9292

9393
type DataSourceFunctions struct {
9494
CatalogName string `json:"catalog_name"`
95+
Functions []DataSourceFunctionsFunctions `json:"functions,omitempty"`
9596
IncludeBrowse bool `json:"include_browse,omitempty"`
9697
SchemaName string `json:"schema_name"`
97-
Functions []DataSourceFunctionsFunctions `json:"functions,omitempty"`
9898
}

bundle/internal/tf/schema/data_source_jobs.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package schema
44

55
type DataSourceJobs struct {
6-
Id string `json:"id,omitempty"`
7-
Ids map[string]string `json:"ids,omitempty"`
6+
Id string `json:"id,omitempty"`
7+
Ids map[string]string `json:"ids,omitempty"`
8+
JobNameContains string `json:"job_name_contains,omitempty"`
89
}

bundle/internal/tf/schema/data_source_notification_destinations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ type DataSourceNotificationDestinationsNotificationDestinations struct {
1010

1111
type DataSourceNotificationDestinations struct {
1212
DisplayNameContains string `json:"display_name_contains,omitempty"`
13-
Type string `json:"type,omitempty"`
1413
NotificationDestinations []DataSourceNotificationDestinationsNotificationDestinations `json:"notification_destinations,omitempty"`
14+
Type string `json:"type,omitempty"`
1515
}

bundle/internal/tf/schema/data_source_registered_model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type DataSourceRegisteredModelModelInfoAliases struct {
88
}
99

1010
type DataSourceRegisteredModelModelInfo struct {
11+
Aliases []DataSourceRegisteredModelModelInfoAliases `json:"aliases,omitempty"`
1112
BrowseOnly bool `json:"browse_only,omitempty"`
1213
CatalogName string `json:"catalog_name,omitempty"`
1314
Comment string `json:"comment,omitempty"`
@@ -21,7 +22,6 @@ type DataSourceRegisteredModelModelInfo struct {
2122
StorageLocation string `json:"storage_location,omitempty"`
2223
UpdatedAt int `json:"updated_at,omitempty"`
2324
UpdatedBy string `json:"updated_by,omitempty"`
24-
Aliases []DataSourceRegisteredModelModelInfoAliases `json:"aliases,omitempty"`
2525
}
2626

2727
type DataSourceRegisteredModel struct {

0 commit comments

Comments
 (0)