Skip to content

Commit a6bb3ac

Browse files
authored
Prepare release 0.2.6 (#360)
* Updated documentation * Updated dependency versions * github.com/Azure/go-autorest/autorest v0.11.6 * github.com/Azure/go-autorest/autorest/adal v0.9.4 * github.com/Azure/go-autorest/autorest/azure/auth v0.5.2 * github.com/Azure/go-autorest/autorest/azure/cli v0.4.1 * github.com/aws/aws-sdk-go v1.35.0 * gopkg.in/ini.v1 v1.61.0 Co-authored-by: Serge Smertin <[email protected]>
1 parent 719e774 commit a6bb3ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4084
-1245
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ updates:
33
- package-ecosystem: "gomod"
44
directory: "/" # Location of package manifests
55
schedule:
6-
interval: "weekly"
6+
interval: "monthly"

docs/changelog.md renamed to CHANGELOG.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@
77
* Added `databricks_user_instance_profile` resource.
88
* Added `databricks_group` data source.
99

10+
Updated dependency versions:
11+
12+
* github.com/Azure/go-autorest/autorest v0.11.6
13+
* github.com/Azure/go-autorest/autorest/adal v0.9.4
14+
* github.com/Azure/go-autorest/autorest/azure/auth v0.5.2
15+
* github.com/Azure/go-autorest/autorest/azure/cli v0.4.1
16+
* gopkg.in/ini.v1 v1.61.0
17+
1018
**Deprecations**
11-
* `databricks_scim_user` is no longer receiving fixes and will be removed in `0.3`, please rewrite using `databricks_user` resource, which has more consistent semantics with `databricks_group` and works better with identity provider SCIM sync.
12-
* `databricks_scim_group` is no longer receiving fixes and will be removed in `0.3`, please rewrite using `databricks_group` resource.
19+
* `databricks_scim_user` is no longer receiving fixes and will be removed in `0.3`, please rewrite using the `databricks_user` resource, which has more consistent semantics with `databricks_group` and works better with identity provider SCIM sync.
20+
* `databricks_scim_group` is no longer receiving fixes and will be removed in `0.3`. Please rewrite using the `databricks_group` resource.
1321
* `databricks_default_user_roles` is no longer receiving fixes and will be removed in `0.3`, please rewrite using `databricks_user` & `databricks_group` resources.
1422

1523
**Behavior changes**
@@ -55,4 +63,4 @@ Updated dependency versions:
5563
* `azure_auth` provider block is no longer receiving fixesand will be removed in `0.3`, please use `azure_*` options
5664

5765
**Behavior changes**
58-
* Previously, mounts code paths were different functions. This release unifies them to be a single testable codebase with different configuration options & re-use of the critical code paths. For maintainability reasons, there's no longer check performed on container & storage account names, but rather on high-level *mount source uri*.
66+
* Previously, mounts code paths were different functions. This release unifies them to be a single testable codebase with different configuration options & re-use of the critical code paths. For maintainability reasons, there's no longer check performed on container & storage account names, but rather on high-level *mount source uri*.

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,5 +210,4 @@ crucial for making sure that the provider behaves as expected on all supported c
210210
1. `make test-azure`
211211
2. `make test-mws` if MWS related code changed given release.
212212
3. Create release notes.
213-
4. Perfrom backwards-compatibility checks and make proper notes.
214-
5.
213+
4. Perfrom backwards-compatibility checks and make proper notes.

README.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,44 @@
22

33
[![Build Status](https://travis-ci.org/databrickslabs/terraform-provider-databricks.svg?branch=master)](https://travis-ci.org/databrickslabs/terraform-provider-databricks) [![codecov](https://codecov.io/gh/databrickslabs/terraform-provider-databricks/branch/master/graph/badge.svg)](https://codecov.io/gh/databrickslabs/terraform-provider-databricks)
44

5-
[Authentication](docs/index.md)
5+
End-to-end workspace creation on [AWS](scripts/awsmt-integration) or [Azure](scripts/azvnet-integration/databricks.tf)
6+
| [Authentication](docs/index.md)
67
| [databricks_aws_s3_mount](docs/resources/aws_s3_mount.md)
8+
| [databricks_aws_assume_role_policy](docs/data-sources/aws_assume_role_policy.md) data
9+
| [databricks_aws_bucket_policy](docs/data-sources/aws_bucket_policy.md) data
10+
| [databricks_aws_crossaccount_policy](docs/data-sources/aws_crossaccount_policy.md) data
711
| [databricks_azure_adls_gen1_mount](docs/resources/azure_adls_gen1_mount.md)
812
| [databricks_azure_adls_gen2_mount](docs/resources/azure_adls_gen2_mount.md)
913
| [databricks_azure_blob_mount](docs/resources/azure_blob_mount.md)
1014
| [databricks_cluster](docs/resources/cluster.md)
1115
| [databricks_cluster_policy](docs/resources/cluster_policy.md)
1216
| [databricks_dbfs_file](docs/resources/dbfs_file.md)
17+
| [databricks_dbfs_file_paths](docs/data-sources/dbfs_file_paths.md) data
18+
| [databricks_dbfs_file](docs/data-sources/dbfs_file.md) data
1319
| [databricks_group](docs/resources/group.md)
20+
| [databricks_group](docs/data-sources/group.md) data
1421
| [databricks_group_instance_profile](docs/resources/group_instance_profile.md)
1522
| [databricks_group_member](docs/resources/group_member.md)
1623
| [databricks_instance_pool](docs/resources/instance_pool.md)
1724
| [databricks_instance_profile](docs/resources/instance_profile.md)
1825
| [databricks_job](docs/resources/job.md)
1926
| [databricks_mws_credentials](docs/resources/mws_credentials.md)
27+
| [databricks_mws_customer_managed_keys](docs/resources/mws_customer_managed_keys.md)
2028
| [databricks_mws_networks](docs/resources/mws_networks.md)
2129
| [databricks_mws_storage_configurations](docs/resources/mws_storage_configurations.md)
22-
| [databricks_mws_customer_managed_keys](docs/resources/mws_customer_managed_keys.md)
2330
| [databricks_mws_workspaces](docs/resources/mws_workspaces.md)
2431
| [databricks_notebook](docs/resources/notebook.md)
32+
| [databricks_notebook](docs/data-sources/notebook.md) data
33+
| [databricks_notebook_paths](docs/data-sources/notebook_paths.md) data
2534
| [databricks_permissions](docs/resources/permissions.md)
26-
| [databricks_scim_user](docs/resources/scim_user.md)
2735
| [databricks_secret](docs/resources/secret.md)
2836
| [databricks_secret_acl](docs/resources/secret_acl.md)
2937
| [databricks_secret_scope](docs/resources/secret_scope.md)
3038
| [databricks_token](docs/resources/token.md)
39+
| [databricks_user](docs/resources/user.md)
40+
| [databricks_user_instance_profile](docs/resources/user_instance_profile.md)
3141
| [Contributing and Development Guidelines](CONTRIBUTING.md)
32-
33-
To quickly install the binary please execute the following curl command in your shell or [install provider from source](CONTRIBUTING.md#installing-from-source).
34-
35-
If you use Terraform 0.12, please execute the following curl command in your shell:
36-
37-
```bash
38-
curl https://raw.githubusercontent.com/databrickslabs/databricks-terraform/master/godownloader-databricks-provider.sh | bash -s -- -b $HOME/.terraform.d/plugins
39-
```
42+
| [Changelog](CHANGELOG.md)
4043

4144
If you use Terraform 0.13, please refer to instructions specified at [registry page](https://registry.terraform.io/providers/databrickslabs/databricks/latest):
4245

@@ -45,12 +48,18 @@ terraform {
4548
required_providers {
4649
databricks = {
4750
source = "databrickslabs/databricks"
48-
version = "0.2.5"
51+
version = ">= 0.2.6"
4952
}
5053
}
5154
}
5255
```
5356

57+
If you use Terraform 0.12, please execute the following curl command in your shell:
58+
59+
```bash
60+
curl https://raw.githubusercontent.com/databrickslabs/databricks-terraform/master/godownloader-databricks-provider.sh | bash -s -- -b $HOME/.terraform.d/plugins
61+
```
62+
5463
Then create a small sample file, named `main.tf` with approximately following contents. Replace `<your PAT token>` with newly created [PAT Token](https://docs.databricks.com/dev-tools/api/latest/authentication.html). It will create [a simple cluster](https://databrickslabs.github.io/terraform-provider-databricks/resources/cluster/).
5564

5665
```terraform
Lines changed: 55 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package acceptance
22

33
import (
4-
"errors"
5-
"fmt"
64
"os"
75
"testing"
86

@@ -11,198 +9,85 @@ import (
119

1210
"github.com/databrickslabs/databricks-terraform/common"
1311
"github.com/databrickslabs/databricks-terraform/internal/acceptance"
14-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
12+
"github.com/databrickslabs/databricks-terraform/internal/qa"
1513
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1614
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1715
"github.com/stretchr/testify/assert"
16+
"github.com/stretchr/testify/require"
1817
)
1918

2019
func TestAccSecretAclResource(t *testing.T) {
21-
// TODO: refactor for common instance pool & AZ CLI
2220
if _, ok := os.LookupEnv("CLOUD_ENV"); !ok {
2321
t.Skip("Acceptance tests skipped unless env 'CLOUD_ENV' is set")
2422
}
25-
//var secretScope Secre
26-
var secretACL ACLItem
27-
scope := fmt.Sprintf("tf-scope-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
28-
principal := "users"
29-
permission := "READ"
30-
client := common.CommonEnvironmentClient()
31-
me, _ := identity.NewUsersAPI(client).Me()
32-
userName := me.UserName
33-
3423
acceptance.AccTest(t, resource.TestCase{
35-
CheckDestroy: testSecretACLResourceDestroy,
3624
Steps: []resource.TestStep{
3725
{
38-
// use a dynamic configuration with the random name from above
39-
Config: testSecretACLResource(scope, principal, permission),
40-
// compose a basic test, checking both remote and local values
41-
Check: resource.ComposeTestCheckFunc(
42-
// test scope permissions - it should be current user
43-
testSecretScopeHasPrincipal(t, scope, userName, "MANAGE"),
44-
// query the API to retrieve the tokenInfo object
45-
testSecretACLResourceExists("databricks_secret_acl.my_secret_acl", &secretACL, t),
46-
// verify remote values
47-
testSecretACLValues(t, &secretACL, permission, principal),
48-
// verify local values
49-
resource.TestCheckResourceAttr("databricks_secret_acl.my_secret_acl", "scope", scope),
50-
resource.TestCheckResourceAttr("databricks_secret_acl.my_secret_acl", "principal", principal),
51-
resource.TestCheckResourceAttr("databricks_secret_acl.my_secret_acl", "permission", permission),
52-
),
53-
},
54-
{
55-
PreConfig: func() {
26+
Config: qa.EnvironmentTemplate(t, `
27+
resource "databricks_group" "ds" {
28+
display_name = "data-scientists-{var.RANDOM}"
29+
}
30+
resource "databricks_secret_scope" "app" {
31+
name = "app-{var.RANDOM}"
32+
}
33+
resource "databricks_secret_acl" "ds_can_read_app" {
34+
principal = databricks_group.ds.display_name
35+
permission = "READ"
36+
scope = databricks_secret_scope.app.name
37+
}`),
38+
Check: func(s *terraform.State) error {
5639
client := common.CommonEnvironmentClient()
57-
err := NewSecretAclsAPI(client).Delete(scope, principal)
58-
assert.NoError(t, err, err)
40+
41+
usersAPI := identity.NewUsersAPI(client)
42+
me, err := usersAPI.Me()
43+
require.NoError(t, err)
44+
45+
secretACLAPI := NewSecretAclsAPI(client)
46+
scope := s.RootModule().Resources["databricks_secret_scope.app"].Primary.ID
47+
acls, err := secretACLAPI.List(scope)
48+
require.NoError(t, err)
49+
assert.Equal(t, 2, len(acls))
50+
m := map[string]string{}
51+
for _, acl := range acls {
52+
m[acl.Principal] = string(acl.Permission)
53+
}
54+
55+
group := s.RootModule().Resources["databricks_group.ds"].Primary.Attributes["display_name"]
56+
require.Contains(t, m, group)
57+
assert.Equal(t, "READ", m[group])
58+
assert.Equal(t, "MANAGE", m[me.UserName])
59+
return nil
5960
},
60-
// use a dynamic configuration with the random name from above
61-
Config: testSecretACLResource(scope, principal, permission),
62-
// compose a basic test, checking both remote and local values
63-
Check: resource.ComposeTestCheckFunc(
64-
// query the API to retrieve the tokenInfo object
65-
testSecretACLResourceExists("databricks_secret_acl.my_secret_acl", &secretACL, t),
66-
// verify remote values
67-
testSecretACLValues(t, &secretACL, permission, principal),
68-
// verify local values
69-
resource.TestCheckResourceAttr("databricks_secret_acl.my_secret_acl", "scope", scope),
70-
resource.TestCheckResourceAttr("databricks_secret_acl.my_secret_acl", "principal", principal),
71-
resource.TestCheckResourceAttr("databricks_secret_acl.my_secret_acl", "permission", permission),
72-
),
7361
},
7462
},
7563
})
7664
}
7765

78-
// this test checks that any user has access when initial principal is set to 'users'
7966
func TestAccSecretAclResourceDefaultPrincipal(t *testing.T) {
80-
// TODO: refactor for common instance pool & AZ CLI
81-
if _, ok := os.LookupEnv("CLOUD_ENV"); !ok {
82-
t.Skip("Acceptance tests skipped unless env 'CLOUD_ENV' is set")
83-
}
84-
scope := fmt.Sprintf("tf-scope-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
85-
client := common.CommonEnvironmentClient()
86-
me, _ := identity.NewUsersAPI(client).Me()
87-
userName := me.UserName
88-
userPermission := "READ"
89-
initialPrincipal := "users"
90-
initialPermission := "MANAGE"
91-
var secretACL ACLItem
92-
9367
acceptance.AccTest(t, resource.TestCase{
94-
CheckDestroy: testSecretACLResourceDestroy,
9568
Steps: []resource.TestStep{
9669
{
97-
// use a dynamic configuration with the random name from above
98-
Config: testSecretACLResourceWithDefaultPrincipal(scope, initialPrincipal, userName, userPermission),
99-
// compose a basic test, checking both remote and local values
100-
Check: resource.ComposeTestCheckFunc(
101-
// test scope permissions - it should be users
102-
testSecretScopeHasPrincipal(t, scope, initialPrincipal, initialPermission),
103-
// query the API to retrieve the tokenInfo object
104-
testSecretACLResourceExists("databricks_secret_acl.my_secret_acl", &secretACL, t),
105-
// verify remote values
106-
testSecretACLValues(t, &secretACL, userPermission, userName),
107-
// verify local values
108-
resource.TestCheckResourceAttr("databricks_secret_acl.my_secret_acl", "scope", scope),
109-
resource.TestCheckResourceAttr("databricks_secret_acl.my_secret_acl", "principal", userName),
110-
resource.TestCheckResourceAttr("databricks_secret_acl.my_secret_acl", "permission", userPermission),
111-
),
70+
Config: qa.EnvironmentTemplate(t, `
71+
resource "databricks_secret_scope" "app" {
72+
name = "app-{var.RANDOM}"
73+
initial_manage_principal = "users"
74+
}
75+
resource "databricks_secret_acl" "ds_can_read_app" {
76+
principal = "users"
77+
permission = "READ"
78+
scope = databricks_secret_scope.app.name
79+
}`),
80+
Check: acceptance.ResourceCheck("databricks_secret_scope.app",
81+
func(client *common.DatabricksClient, id string) error {
82+
secretACLAPI := NewSecretAclsAPI(client)
83+
acls, err := secretACLAPI.List(id)
84+
require.NoError(t, err)
85+
assert.Equal(t, 1, len(acls))
86+
assert.Equal(t, "users", acls[0].Principal)
87+
assert.Equal(t, "READ", string(acls[0].Permission))
88+
return nil
89+
}),
11290
},
11391
},
11492
})
11593
}
116-
117-
func testSecretACLResourceDestroy(s *terraform.State) error {
118-
client := common.CommonEnvironmentClient()
119-
for _, rs := range s.RootModule().Resources {
120-
if rs.Type != "databricks_secret" && rs.Type != "databricks_secret_scope" {
121-
continue
122-
}
123-
_, err := NewSecretAclsAPI(client).Read(rs.Primary.Attributes["scope"], rs.Primary.Attributes["principal"])
124-
if err == nil {
125-
return errors.New("resource secret acl is not cleaned up")
126-
}
127-
_, err = NewSecretScopesAPI(client).Read(rs.Primary.Attributes["scope"])
128-
if err == nil {
129-
return errors.New("resource secret is not cleaned up")
130-
}
131-
}
132-
return nil
133-
}
134-
135-
func testSecretACLValues(t *testing.T, acl *ACLItem, permission, principal string) resource.TestCheckFunc {
136-
return func(s *terraform.State) error {
137-
assert.EqualValues(t, permission, acl.Permission)
138-
assert.EqualValues(t, principal, acl.Principal)
139-
return nil
140-
}
141-
}
142-
143-
func testSecretScopeHasPrincipal(t *testing.T, scope, principal, permission string) resource.TestCheckFunc {
144-
return func(s *terraform.State) error {
145-
var acl ACLItem
146-
err := getSecretACLResourceExistsForScopeAndPrincipal(scope, principal, &acl)
147-
if err != nil {
148-
return err
149-
}
150-
assert.EqualValues(t, permission, acl.Permission)
151-
assert.EqualValues(t, principal, acl.Principal)
152-
return nil
153-
}
154-
}
155-
156-
func getSecretACLResourceExistsForScopeAndPrincipal(scope, principal string, aclItem *ACLItem) error {
157-
// retrieve the configured client from the test setup
158-
conn := common.CommonEnvironmentClient()
159-
resp, err := NewSecretAclsAPI(conn).Read(scope, principal)
160-
if err != nil {
161-
return err
162-
}
163-
// If no error, assign the response Widget attribute to the widget pointer
164-
*aclItem = resp
165-
return nil
166-
}
167-
168-
// testAccCheckTokenResourceExists queries the API and retrieves the matching Widget.
169-
func testSecretACLResourceExists(n string, aclItem *ACLItem, t *testing.T) resource.TestCheckFunc {
170-
return func(s *terraform.State) error {
171-
// find the corresponding state object
172-
rs, ok := s.RootModule().Resources[n]
173-
if !ok {
174-
return fmt.Errorf("Not found: %s", n)
175-
}
176-
return getSecretACLResourceExistsForScopeAndPrincipal(rs.Primary.Attributes["scope"],
177-
rs.Primary.Attributes["principal"], aclItem)
178-
}
179-
}
180-
181-
// testAccTokenResource returns an configuration for an Example Widget with the provided name
182-
func testSecretACLResource(scopeName, principal, permission string) string {
183-
return fmt.Sprintf(`
184-
resource "databricks_secret_scope" "my_scope" {
185-
name = "%s"
186-
}
187-
resource "databricks_secret_acl" "my_secret_acl" {
188-
principal = "%s"
189-
permission = "%s"
190-
scope = databricks_secret_scope.my_scope.name
191-
}
192-
`, scopeName, principal, permission)
193-
}
194-
195-
// testAccTokenResource returns an configuration for an Example Widget with the provided name
196-
func testSecretACLResourceWithDefaultPrincipal(scopeName, defaultPrincipal, principal, permission string) string {
197-
return fmt.Sprintf(`
198-
resource "databricks_secret_scope" "my_scope" {
199-
name = "%s"
200-
initial_manage_principal = "%s"
201-
}
202-
resource "databricks_secret_acl" "my_secret_acl" {
203-
principal = "%s"
204-
permission = "%s"
205-
scope = databricks_secret_scope.my_scope.name
206-
}
207-
`, scopeName, defaultPrincipal, principal, permission)
208-
}

0 commit comments

Comments
 (0)