diff --git a/catalog/resource_lakehouse_monitor.go b/catalog/resource_lakehouse_monitor.go index ac57786a3d..8e7c0db778 100644 --- a/catalog/resource_lakehouse_monitor.go +++ b/catalog/resource_lakehouse_monitor.go @@ -16,7 +16,7 @@ const lakehouseMonitorDefaultProvisionTimeout = 15 * time.Minute func WaitForMonitor(w *databricks.WorkspaceClient, ctx context.Context, monitorName string) error { return retry.RetryContext(ctx, lakehouseMonitorDefaultProvisionTimeout, func() *retry.RetryError { - endpoint, err := w.LakehouseMonitors.GetByTableName(ctx, monitorName) + endpoint, err := w.QualityMonitors.GetByTableName(ctx, monitorName) if err != nil { return retry.NonRetryableError(err) } @@ -68,7 +68,7 @@ func ResourceLakehouseMonitor() common.Resource { common.DataToStructPointer(d, monitorSchema, &create) create.TableName = d.Get("table_name").(string) - endpoint, err := w.LakehouseMonitors.Create(ctx, create) + endpoint, err := w.QualityMonitors.Create(ctx, create) if err != nil { return err } @@ -84,7 +84,7 @@ func ResourceLakehouseMonitor() common.Resource { if err != nil { return err } - endpoint, err := w.LakehouseMonitors.GetByTableName(ctx, d.Id()) + endpoint, err := w.QualityMonitors.GetByTableName(ctx, d.Id()) if err != nil { return err @@ -99,7 +99,7 @@ func ResourceLakehouseMonitor() common.Resource { var update catalog.UpdateMonitor common.DataToStructPointer(d, monitorSchema, &update) update.TableName = d.Get("table_name").(string) - _, err = w.LakehouseMonitors.Update(ctx, update) + _, err = w.QualityMonitors.Update(ctx, update) if err != nil { return err } @@ -110,7 +110,7 @@ func ResourceLakehouseMonitor() common.Resource { if err != nil { return err } - return w.LakehouseMonitors.DeleteByTableName(ctx, d.Id()) + return w.QualityMonitors.DeleteByTableName(ctx, d.Id()) }, Schema: monitorSchema, Timeouts: &schema.ResourceTimeout{ diff --git a/catalog/resource_lakehouse_monitor_test.go b/catalog/resource_lakehouse_monitor_test.go index 652fd7d4b7..af1e6d852f 100644 --- a/catalog/resource_lakehouse_monitor_test.go +++ b/catalog/resource_lakehouse_monitor_test.go @@ -16,7 +16,7 @@ func TestLakehouseMonitorCornerCases(t *testing.T) { func TestLakehouseMonitorCreateTimeseries(t *testing.T) { qa.ResourceFixture{ MockWorkspaceClientFunc: func(w *mocks.MockWorkspaceClient) { - e := w.GetMockLakehouseMonitorsAPI().EXPECT() + e := w.GetMockQualityMonitorsAPI().EXPECT() e.Create(mock.Anything, catalog.CreateMonitor{ TableName: "test_table", OutputSchemaName: "output.schema", @@ -57,7 +57,7 @@ func TestLakehouseMonitorCreateTimeseries(t *testing.T) { func TestLakehouseMonitorCreateInference(t *testing.T) { qa.ResourceFixture{ MockWorkspaceClientFunc: func(w *mocks.MockWorkspaceClient) { - e := w.GetMockLakehouseMonitorsAPI().EXPECT() + e := w.GetMockQualityMonitorsAPI().EXPECT() e.Create(mock.Anything, catalog.CreateMonitor{ TableName: "test_table", OutputSchemaName: "output.schema", @@ -109,7 +109,7 @@ func TestLakehouseMonitorCreateInference(t *testing.T) { func TestLakehouseMonitorCreateSnapshot(t *testing.T) { qa.ResourceFixture{ MockWorkspaceClientFunc: func(w *mocks.MockWorkspaceClient) { - e := w.GetMockLakehouseMonitorsAPI().EXPECT() + e := w.GetMockQualityMonitorsAPI().EXPECT() e.Create(mock.Anything, catalog.CreateMonitor{ TableName: "test_table", OutputSchemaName: "output.schema", @@ -143,7 +143,7 @@ func TestLakehouseMonitorCreateSnapshot(t *testing.T) { func TestLakehouseMonitorGet(t *testing.T) { qa.ResourceFixture{ MockWorkspaceClientFunc: func(w *mocks.MockWorkspaceClient) { - e := w.GetMockLakehouseMonitorsAPI().EXPECT() + e := w.GetMockQualityMonitorsAPI().EXPECT() e.GetByTableName(mock.Anything, "test_table").Return(&catalog.MonitorInfo{ TableName: "test_table", Status: catalog.MonitorInfoStatusMonitorStatusActive, @@ -166,7 +166,7 @@ func TestLakehouseMonitorGet(t *testing.T) { func TestLakehouseMonitorUpdate(t *testing.T) { qa.ResourceFixture{ MockWorkspaceClientFunc: func(w *mocks.MockWorkspaceClient) { - e := w.GetMockLakehouseMonitorsAPI().EXPECT() + e := w.GetMockQualityMonitorsAPI().EXPECT() e.Update(mock.Anything, catalog.UpdateMonitor{ TableName: "test_table", OutputSchemaName: "output.schema", @@ -228,7 +228,7 @@ func TestLakehouseMonitorUpdate(t *testing.T) { func TestLakehouseMonitorDelete(t *testing.T) { qa.ResourceFixture{ MockWorkspaceClientFunc: func(w *mocks.MockWorkspaceClient) { - e := w.GetMockLakehouseMonitorsAPI().EXPECT() + e := w.GetMockQualityMonitorsAPI().EXPECT() e.DeleteByTableName(mock.Anything, "test_table").Return(nil) }, Resource: ResourceLakehouseMonitor(), diff --git a/catalog/resource_system_schema.go b/catalog/resource_system_schema.go index 1da5b3e682..19c3e371fa 100644 --- a/catalog/resource_system_schema.go +++ b/catalog/resource_system_schema.go @@ -43,7 +43,7 @@ func ResourceSystemSchema() common.Resource { //enable new schema err = w.SystemSchemas.Enable(ctx, catalog.EnableRequest{ MetastoreId: metastoreSummary.MetastoreId, - SchemaName: catalog.EnableSchemaName(new), + SchemaName: new, }) //ignore "schema already exists" error if err != nil && !strings.Contains(err.Error(), "already exists") { @@ -53,7 +53,7 @@ func ResourceSystemSchema() common.Resource { if old != "" { err = w.SystemSchemas.Disable(ctx, catalog.DisableRequest{ MetastoreId: metastoreSummary.MetastoreId, - SchemaName: catalog.DisableSchemaName(old), + SchemaName: old, }) if err != nil { return err @@ -106,7 +106,7 @@ func ResourceSystemSchema() common.Resource { } return w.SystemSchemas.Disable(ctx, catalog.DisableRequest{ MetastoreId: metastoreSummary.MetastoreId, - SchemaName: catalog.DisableSchemaName(schemaName), + SchemaName: schemaName, }) }, } diff --git a/clusters/resource_cluster.go b/clusters/resource_cluster.go index 3b7bd63fb6..14cbdc638e 100644 --- a/clusters/resource_cluster.go +++ b/clusters/resource_cluster.go @@ -248,7 +248,6 @@ func (ClusterSpec) CustomizeSchemaResourceSpecific(s *common.CustomizableSchema) } func (ClusterSpec) CustomizeSchema(s *common.CustomizableSchema) *common.CustomizableSchema { - s.SchemaPath("cluster_source").SetReadOnly() s.SchemaPath("enable_elastic_disk").SetComputed() s.SchemaPath("enable_local_disk_encryption").SetComputed() s.SchemaPath("node_type_id").SetComputed().SetConflictsWith([]string{"driver_instance_pool_id", "instance_pool_id"}) diff --git a/exporter/exporter_test.go b/exporter/exporter_test.go index 7ca0e25eb2..174a766409 100644 --- a/exporter/exporter_test.go +++ b/exporter/exporter_test.go @@ -293,7 +293,7 @@ var emptyStorageCrdentials = qa.HTTPFixture{ var emptyConnections = qa.HTTPFixture{ Method: "GET", - Resource: "/api/2.1/unity-catalog/connections", + Resource: "/api/2.1/unity-catalog/connections?", Response: catalog.ListConnectionsResponse{}, } diff --git a/exporter/importables.go b/exporter/importables.go index 00f364c95f..165081f12c 100644 --- a/exporter/importables.go +++ b/exporter/importables.go @@ -2714,7 +2714,7 @@ var resourcesMap map[string]importable = map[string]importable{ return connectionType + "_" + connectionName }, List: func(ic *importContext) error { - connections, err := ic.workspaceClient.Connections.ListAll(ic.Context) + connections, err := ic.workspaceClient.Connections.ListAll(ic.Context, catalog.ListConnectionsRequest{}) if err != nil { return err } diff --git a/exporter/importables_test.go b/exporter/importables_test.go index 0c395d9dd4..116919d3eb 100644 --- a/exporter/importables_test.go +++ b/exporter/importables_test.go @@ -1843,7 +1843,7 @@ func TestConnections(t *testing.T) { { ReuseRequest: true, Method: "GET", - Resource: "/api/2.1/unity-catalog/connections", + Resource: "/api/2.1/unity-catalog/connections?", Response: catalog.ListConnectionsResponse{ Connections: []catalog.ConnectionInfo{ { diff --git a/go.mod b/go.mod index 646afb47fd..512971fc42 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/databricks/terraform-provider-databricks go 1.21 require ( - github.com/databricks/databricks-sdk-go v0.40.1 + github.com/databricks/databricks-sdk-go v0.41.0 github.com/golang-jwt/jwt/v4 v4.5.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/hcl v1.0.0 diff --git a/go.sum b/go.sum index ba7f338594..b163b8bb5d 100644 --- a/go.sum +++ b/go.sum @@ -24,10 +24,8 @@ github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBS github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= -github.com/databricks/databricks-sdk-go v0.40.0 h1:H9KAyRbM5lwnY8t9nY/xAYHVTBsLqFuIRwVaRGqYJe0= -github.com/databricks/databricks-sdk-go v0.40.0/go.mod h1:Yjy1gREDLK65g4axpVbVNKYAHYE2Sqzj0AB9QWHCBVM= -github.com/databricks/databricks-sdk-go v0.40.1 h1:rE5yP9gIW2oap+6CnumixnZSDIsXwVojAuDBuKUl5GU= -github.com/databricks/databricks-sdk-go v0.40.1/go.mod h1:rLIhh7DvifVLmf2QxMr/vMRGqdrTZazn8VYo4LilfCo= +github.com/databricks/databricks-sdk-go v0.41.0 h1:OyhYY+Q6+gqkWeXmpGEiacoU2RStTeWPF0x4vmqbQdc= +github.com/databricks/databricks-sdk-go v0.41.0/go.mod h1:rLIhh7DvifVLmf2QxMr/vMRGqdrTZazn8VYo4LilfCo= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -223,8 +221,6 @@ go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -245,8 +241,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -273,14 +267,12 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/jobs/resource_job.go b/jobs/resource_job.go index 633fc13c23..2fff33d74b 100644 --- a/jobs/resource_job.go +++ b/jobs/resource_job.go @@ -589,7 +589,6 @@ func (JobSettingsResource) CustomizeSchema(s *common.CustomizableSchema) *common s.SchemaPath("task", "for_each_task", "task", "run_if").SetSuppressDiffWithDefault(jobs.RunIfAllSuccess) s.SchemaPath("task", "for_each_task", "task", "new_cluster", "cluster_id").Schema.Computed = false - s.SchemaPath("task", "for_each_task", "task", "new_cluster").RemoveField("cluster_source") // ======= To keep consistency with the manually maintained schema, should be reverted once full migration is done. ====== s.SchemaPath("task", "task_key").SetOptional() diff --git a/libraries/libraries_api.go b/libraries/libraries_api.go index 6392f6791a..c3c4ee87b0 100644 --- a/libraries/libraries_api.go +++ b/libraries/libraries_api.go @@ -43,7 +43,7 @@ func NewLibraryFromInstanceState(i any) (lib compute.Library) { } // Diff returns install/uninstall lists given a cluster lib status -func GetLibrariesToInstallAndUninstall(cll []compute.Library, cls *compute.ClusterStatusResponse) ([]compute.Library, []compute.Library) { +func GetLibrariesToInstallAndUninstall(cll []compute.Library, cls *compute.ClusterLibraryStatuses) ([]compute.Library, []compute.Library) { inConfig := map[string]compute.Library{} for _, lib := range cll { inConfig[lib.String()] = lib diff --git a/libraries/libraries_api_sdk.go b/libraries/libraries_api_sdk.go index 441393fcf8..09a8531d03 100644 --- a/libraries/libraries_api_sdk.go +++ b/libraries/libraries_api_sdk.go @@ -16,7 +16,7 @@ import ( // Given a compute.Wait struct, returns library statuses based on the input parameter. // If wait.IsRunning is set to true, this function will wait until all of the libraries are installed to return. Otherwise, it will directly return the list of libraries. -func WaitForLibrariesInstalledSdk(ctx context.Context, w *databricks.WorkspaceClient, wait compute.Wait, timeout time.Duration) (result *compute.ClusterStatusResponse, err error) { +func WaitForLibrariesInstalledSdk(ctx context.Context, w *databricks.WorkspaceClient, wait compute.Wait, timeout time.Duration) (result *compute.ClusterLibraryStatuses, err error) { err = resource.RetryContext(ctx, timeout, func() *resource.RetryError { libsClusterStatus, err := w.Libraries.ClusterStatusByClusterId(ctx, wait.ClusterID) if err != nil { diff --git a/qa/test_credentials_provider.go b/qa/test_credentials_provider.go index 741af8ffd5..9d5741d6a8 100644 --- a/qa/test_credentials_provider.go +++ b/qa/test_credentials_provider.go @@ -6,6 +6,7 @@ import ( "net/http" "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/databricks-sdk-go/credentials" ) type testCredentialsProvider struct { @@ -16,9 +17,10 @@ func (testCredentialsProvider) Name() string { return "test" } -func (t testCredentialsProvider) Configure(ctx context.Context, cfg *config.Config) (func(*http.Request) error, error) { - return func(r *http.Request) error { +func (t testCredentialsProvider) Configure(ctx context.Context, cfg *config.Config) (credentials.CredentialsProvider, error) { + fun := func(r *http.Request) error { r.Header.Set("Authorization", fmt.Sprintf("Bearer %s", t.token)) return nil - }, nil + } + return credentials.NewCredentialsProvider(fun), nil } diff --git a/qa/testing.go b/qa/testing.go index ee7adf60cf..663b09ef69 100644 --- a/qa/testing.go +++ b/qa/testing.go @@ -18,6 +18,7 @@ import ( "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/common/environment" "github.com/databricks/databricks-sdk-go/config" "github.com/databricks/databricks-sdk-go/experimental/mocks" "github.com/databricks/terraform-provider-databricks/common" @@ -181,20 +182,20 @@ func (f ResourceFixture) prepareExecution(r *schema.Resource) (resourceCRUD, err func (f ResourceFixture) setDatabricksEnvironmentForTest(client *common.DatabricksClient, host string) { if f.Azure || f.AzureSPN { - client.Config.DatabricksEnvironment = &config.DatabricksEnvironment{ - Cloud: config.CloudAzure, + client.Config.DatabricksEnvironment = &environment.DatabricksEnvironment{ + Cloud: environment.CloudAzure, DnsZone: host, AzureApplicationID: "azure-login-application-id", - AzureEnvironment: &config.AzurePublicCloud, + AzureEnvironment: &environment.AzurePublicCloud, } } else if f.Gcp { - client.Config.DatabricksEnvironment = &config.DatabricksEnvironment{ - Cloud: config.CloudGCP, + client.Config.DatabricksEnvironment = &environment.DatabricksEnvironment{ + Cloud: environment.CloudGCP, DnsZone: host, } } else { - client.Config.DatabricksEnvironment = &config.DatabricksEnvironment{ - Cloud: config.CloudAWS, + client.Config.DatabricksEnvironment = &environment.DatabricksEnvironment{ + Cloud: environment.CloudAWS, DnsZone: host, } }