Skip to content

Commit b9b1740

Browse files
committed
Merge branch 'main' into feature-sp-secret-lifetime
2 parents cd2d308 + 6cc796c commit b9b1740

22 files changed

+2186
-2455
lines changed

.github/workflows/release.yml

+17-1
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,27 @@ jobs:
3838
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
3939
PASSPHRASE: ${{ secrets.PASSPHRASE }}
4040

41+
- name: Set GoReleaser args
42+
run: |
43+
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
44+
RELEASE_NOTES_DIR=$(mktemp -d)
45+
RELEASE_NOTES_FILE="$RELEASE_NOTES_DIR/release-notes.md"
46+
git for-each-ref --format='%(body)' ${{ github.ref }} > "$RELEASE_NOTES_FILE"
47+
echo "Release notes contents:"
48+
cat "$RELEASE_NOTES_FILE"
49+
GORELEASER_ARGS="--release-notes $RELEASE_NOTES_FILE"
50+
echo "GORELEASER_ARGS=$GORELEASER_ARGS" >> $GITHUB_ENV
51+
else
52+
echo "Not a release tag, skipping release notes"
53+
GORELEASER_ARGS="--snapshot"
54+
echo "GORELEASER_ARGS=$GORELEASER_ARGS" >> $GITHUB_ENV
55+
fi
56+
4157
- name: Run GoReleaser
4258
uses: goreleaser/goreleaser-action@v6
4359
with:
4460
version: ~> v2
45-
args: release --clean ${{ !startsWith(github.ref, 'refs/tags/v') && '--snapshot' || '' }} --release-notes <(git for-each-ref --format='%(body)' ${{ github.ref }})
61+
args: release --clean $GORELEASER_ARGS
4662
env:
4763
# use GITHUB_TOKEN that is already available in secrets.GITHUB_TOKEN
4864
# https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#permissions-for-the-github_token

.release_metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"timestamp": "2025-04-10 13:36:07+0000"
2+
"timestamp": "2025-04-07 14:32:14+0000"
33
}

CHANGELOG.md

-24
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
11
# Version changelog
22

3-
## Release v1.73.0
4-
5-
### New Features and Improvements
6-
7-
* Add a new settings resource `databricks_disable_legacy_dbfs_setting` ([#4605](https://github.com/databricks/terraform-provider-databricks/pull/4605))
8-
9-
### Bug Fixes
10-
11-
* Increase the default HTTP timeout to 65 seconds.
12-
13-
### Documentation
14-
15-
* Document `user_api_scopes` in `databricks_app` resource and data sources ([#4614](https://github.com/databricks/terraform-provider-databricks/pull/4614))
16-
* Document new fields in `databricks_model_serving` resource ([#4615](https://github.com/databricks/terraform-provider-databricks/pull/4615))
17-
18-
### Exporter
19-
20-
* Add export of `databricks_mws_network_connectivity_config` and `databricks_mws_ncc_private_endpoint_rule` ([#4613](https://github.com/databricks/terraform-provider-databricks/pull/4613))
21-
22-
### Internal Changes
23-
24-
* Add `TestMwsAccGcpWorkspaces` and `TestMwsAccGcpByovpcWorkspaces` to flaky test ([#4624](https://github.com/databricks/terraform-provider-databricks/pull/4624)).
25-
26-
273
## Release v1.72.0
284

295
### New Features and Improvements

NEXT_CHANGELOG.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
# NEXT CHANGELOG
22

3-
## Release v1.74.0
3+
## Release v1.73.0
44

55
### New Features and Improvements
66

77
* Support for `lifetime` attribute in `databricks_service_principal_secret` resource ([#4633](https://github.com/databricks/terraform-provider-databricks/pull/4633)).
8+
* Add a new settings resource `databricks_disable_legacy_dbfs_setting` ([#4605](https://github.com/databricks/terraform-provider-databricks/pull/4605))
89

910
### Bug Fixes
1011

12+
* Increase the default HTTP timeout to 65 seconds.
13+
1114
### Documentation
1215

16+
* Document `user_api_scopes` in `databricks_app` resource and data sources ([#4614](https://github.com/databricks/terraform-provider-databricks/pull/4614))
17+
* Document new fields in `databricks_model_serving` resource ([#4615](https://github.com/databricks/terraform-provider-databricks/pull/4615))
18+
1319
### Exporter
1420

21+
* Add export of `databricks_mws_network_connectivity_config` and `databricks_mws_ncc_private_endpoint_rule` ([#4613](https://github.com/databricks/terraform-provider-databricks/pull/4613))
22+
1523
### Internal Changes
24+
25+
* Refactor `databricks_mws_workspaces` resource and datasource, as well as `databricks_mws_ncc_binding`, to use the Go SDK ([#4633](https://github.com/databricks/terraform-provider-databricks/pull/4633)).
26+
* Add `TestMwsAccGcpWorkspaces` and `TestMwsAccGcpByovpcWorkspaces` to flaky test ([#4624](https://github.com/databricks/terraform-provider-databricks/pull/4624)).

common/client.go

+56-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/client_test.go

+98
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@ package common
22

33
import (
44
"context"
5+
"fmt"
56
"log"
67
"net/http"
78
"path/filepath"
89
"strings"
910
"testing"
1011

12+
"github.com/databricks/databricks-sdk-go"
1113
"github.com/databricks/databricks-sdk-go/client"
1214
"github.com/databricks/databricks-sdk-go/config"
15+
"github.com/databricks/databricks-sdk-go/experimental/mocks"
1316
"github.com/databricks/databricks-sdk-go/service/iam"
17+
"github.com/databricks/databricks-sdk-go/service/provisioning"
1418
"github.com/stretchr/testify/assert"
19+
"github.com/stretchr/testify/mock"
1520
"github.com/stretchr/testify/require"
1621
)
1722

@@ -335,3 +340,96 @@ func TestCachedMe_Me_MakesSingleRequest(t *testing.T) {
335340
cm.Me(context.Background())
336341
assert.Equal(t, 1, mock.count)
337342
}
343+
344+
func TestWorkspaceClientForWorkspace_WorkspaceDoesNotExist(t *testing.T) {
345+
mockAcc := mocks.NewMockAccountClient(t)
346+
mockWorkspacesAPI := mockAcc.GetMockWorkspacesAPI()
347+
348+
// Setup the mock to return an error for non-existent workspace
349+
mockWorkspacesAPI.EXPECT().Get(mock.Anything, provisioning.GetWorkspaceRequest{
350+
WorkspaceId: 12345,
351+
}).Return(nil, fmt.Errorf("workspace not found"))
352+
353+
// Create a DatabricksClient with the mock account client
354+
dc := &DatabricksClient{
355+
DatabricksClient: &client.DatabricksClient{
356+
Config: &config.Config{},
357+
},
358+
}
359+
dc.SetAccountClient(mockAcc.AccountClient)
360+
361+
// Call the method with a non-existent workspace ID
362+
_, err := dc.WorkspaceClientForWorkspace(context.Background(), 12345)
363+
364+
// Verify the error
365+
assert.Error(t, err)
366+
assert.Contains(t, err.Error(), "workspace not found")
367+
}
368+
369+
func TestWorkspaceClientForWorkspace_WorkspaceExistsNotInCache(t *testing.T) {
370+
mockAcc := mocks.NewMockAccountClient(t)
371+
mockAcc.AccountClient.Config = &config.Config{
372+
Token: "dapi123", // Instantiating WorkspaceClient attempts authentication, this allows Configure() to complete quickly.
373+
}
374+
mockWorkspacesAPI := mockAcc.GetMockWorkspacesAPI()
375+
376+
// Create a mock workspace
377+
mockWorkspace := &provisioning.Workspace{
378+
WorkspaceId: 12345,
379+
WorkspaceName: "test-workspace",
380+
DeploymentName: "test-deployment",
381+
}
382+
383+
// Setup the mock to return the workspace
384+
mockWorkspacesAPI.EXPECT().Get(mock.Anything, provisioning.GetWorkspaceRequest{
385+
WorkspaceId: 12345,
386+
}).Return(mockWorkspace, nil)
387+
388+
// Create a DatabricksClient with the mock account client
389+
dc := &DatabricksClient{
390+
DatabricksClient: &client.DatabricksClient{
391+
Config: &config.Config{},
392+
},
393+
}
394+
dc.SetAccountClient(mockAcc.AccountClient)
395+
396+
// Call the method with the workspace ID
397+
workspaceClient, err := dc.WorkspaceClientForWorkspace(context.Background(), 12345)
398+
399+
// Verify no error and client is returned
400+
assert.NoError(t, err)
401+
assert.NotNil(t, workspaceClient)
402+
403+
// Verify the workspace client is configured correctly
404+
assert.Equal(t, fmt.Sprintf("https://%s.cloud.databricks.com", mockWorkspace.DeploymentName), workspaceClient.Config.Host)
405+
406+
// Verify the client is cached
407+
dc.mu.Lock()
408+
cachedClient, exists := dc.cachedWorkspaceClients[12345]
409+
dc.mu.Unlock()
410+
411+
assert.True(t, exists)
412+
assert.Equal(t, workspaceClient, cachedClient)
413+
}
414+
415+
func TestWorkspaceClientForWorkspace_WorkspaceExistsInCache(t *testing.T) {
416+
// Create a mock workspace client
417+
mockWorkspaceClient := &databricks.WorkspaceClient{}
418+
419+
// Create a DatabricksClient with the mock workspace client in cache
420+
dc := &DatabricksClient{
421+
DatabricksClient: &client.DatabricksClient{
422+
Config: &config.Config{},
423+
},
424+
}
425+
426+
// Set the workspace client in cache
427+
dc.SetWorkspaceClientForWorkspace(12345, mockWorkspaceClient)
428+
429+
// Call the method with the workspace ID
430+
workspaceClient, err := dc.WorkspaceClientForWorkspace(context.Background(), 12345)
431+
432+
// Verify no error and the cached client is returned
433+
assert.NoError(t, err)
434+
assert.Equal(t, mockWorkspaceClient, workspaceClient)
435+
}

common/constants.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package common
2+
3+
import "context"
4+
5+
var (
6+
// ResourceName is resource name without databricks_ prefix
7+
ResourceName contextKey = 1
8+
// Provider is the current instance of provider
9+
Provider contextKey = 2
10+
// Current is the current name of integration test
11+
Current contextKey = 3
12+
// If current resource is data
13+
IsData contextKey = 4
14+
// apiVersion
15+
Api contextKey = 5
16+
// SDK used
17+
Sdk contextKey = 6
18+
)
19+
20+
type contextKey int
21+
22+
func (k contextKey) GetOrUnknown(ctx context.Context) string {
23+
rn, ok := ctx.Value(k).(string)
24+
if !ok {
25+
return "unknown"
26+
}
27+
return rn
28+
}

common/version.go

+1-27
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,6 @@
11
package common
22

3-
import "context"
4-
5-
var (
6-
version = "1.73.0"
7-
// ResourceName is resource name without databricks_ prefix
8-
ResourceName contextKey = 1
9-
// Provider is the current instance of provider
10-
Provider contextKey = 2
11-
// Current is the current name of integration test
12-
Current contextKey = 3
13-
// If current resource is data
14-
IsData contextKey = 4
15-
// apiVersion
16-
Api contextKey = 5
17-
// SDK used
18-
Sdk contextKey = 6
19-
)
20-
21-
type contextKey int
22-
23-
func (k contextKey) GetOrUnknown(ctx context.Context) string {
24-
rn, ok := ctx.Value(k).(string)
25-
if !ok {
26-
return "unknown"
27-
}
28-
return rn
29-
}
3+
var version = "1.72.0"
304

315
// Version returns version of provider
326
func Version() string {

docs/resources/access_control_rule_set.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ subcategory: "Security"
99
This resource allows you to manage access rules on Databricks account level resources. For convenience we allow accessing this resource through the Databricks account and workspace.
1010

1111
-> Currently, we only support managing access rules on specific object resources (service principal, group, budget policies and account) through `databricks_access_control_rule_set`.
12+
1213
!> `databricks_access_control_rule_set` cannot be used to manage access rules for resources supported by [databricks_permissions](permissions.md). Refer to its documentation for more information.
1314

1415
~> This resource is _authoritative_ for permissions on objects. Configuring this resource for an object will **OVERWRITE** any existing permissions of the same type unless imported, and changes made outside of Terraform will be reset.

0 commit comments

Comments
 (0)