-
Notifications
You must be signed in to change notification settings - Fork 113
direct: Add support for secret scopes #3886
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
Open
shreyas-goenka
wants to merge
21
commits into
main
Choose a base branch
from
direct-secret-scope
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
bbd0a4b
[WIP] direct: secret scopes
shreyas-goenka bf86538
wip fix for the permissions issue. still needs some more work
shreyas-goenka df29329
test stableized
shreyas-goenka b16328a
merge
shreyas-goenka 0da6f68
Merge remote-tracking branch 'origin' into direct-secret-scope
shreyas-goenka a4ac665
update tests
shreyas-goenka b1e7a45
update tests
shreyas-goenka ba52db8
update-scope
shreyas-goenka 559ca0a
merge
shreyas-goenka df9c9f5
better acl implementation
shreyas-goenka 37e7e22
best tests
shreyas-goenka 7ad9d05
-
shreyas-goenka 0b8aca6
undo key sort';
shreyas-goenka cdec26a
-
shreyas-goenka 50af43a
more robust check
shreyas-goenka 1cc1283
cleanup todos
shreyas-goenka ae2be0f
cleanup
shreyas-goenka bf90ffd
lint
shreyas-goenka d8565d3
update ref schema
shreyas-goenka 9797954
make test all work
shreyas-goenka 07c9b0d
fix TestFieldTriggers
shreyas-goenka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
acceptance/bundle/resources/secret_scopes/backend-type/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| trace $CLI bundle deploy | ||
| trace jq -s '.[] | select(.path=="/api/2.0/secrets/scopes/create") | .body' out.requests.txt | ||
| rm out.requests.txt | ||
| trace print_requests.py //secrets |
8 changes: 3 additions & 5 deletions
8
...sources/secret_scopes/databricks.yml.tmpl → ...s/secret_scopes/basic/databricks.yml.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,11 @@ | ||
| bundle: | ||
| name: deploy-secret-scope-test-$UNIQUE_NAME | ||
| name: secret-scope-basic-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| secret_scopes: | ||
| secret_scope1: | ||
| my_scope: | ||
| name: $SECRET_SCOPE_NAME | ||
| backend_type: "DATABRICKS" | ||
| permissions: | ||
| - user_name: admins | ||
| - user_name: [email protected] | ||
| level: WRITE | ||
| - user_name: users | ||
| level: READ |
33 changes: 33 additions & 0 deletions
33
acceptance/bundle/resources/secret_scopes/basic/out.second-requests.direct.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/secrets/scopes/delete", | ||
| "body": { | ||
| "scope": "test-scope-[UNIQUE_NAME]-1" | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/secrets/scopes/create", | ||
| "body": { | ||
| "scope": "test-scope-[UNIQUE_NAME]-2", | ||
| "scope_backend_type": "DATABRICKS" | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/secrets/acls/put", | ||
| "body": { | ||
| "permission": "WRITE", | ||
| "principal": "[email protected]", | ||
| "scope": "test-scope-[UNIQUE_NAME]-2" | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/secrets/put", | ||
| "body": { | ||
| "key": "another-key", | ||
| "scope": "test-scope-[UNIQUE_NAME]-2", | ||
| "string_value": "another-secret-value" | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
acceptance/bundle/resources/secret_scopes/basic/out.second-requests.terraform.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/secrets/acls/delete", | ||
| "body": { | ||
| "principal": "[email protected]", | ||
| "scope": "test-scope-[UNIQUE_NAME]-1" | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/secrets/scopes/delete", | ||
| "body": { | ||
| "scope": "test-scope-[UNIQUE_NAME]-1" | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/secrets/scopes/create", | ||
| "body": { | ||
| "scope": "test-scope-[UNIQUE_NAME]-2", | ||
| "scope_backend_type": "DATABRICKS" | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/secrets/acls/put", | ||
| "body": { | ||
| "permission": "WRITE", | ||
| "principal": "[email protected]", | ||
| "scope": "test-scope-[UNIQUE_NAME]-2" | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/secrets/put", | ||
| "body": { | ||
| "key": "another-key", | ||
| "scope": "test-scope-[UNIQUE_NAME]-2", | ||
| "string_value": "another-secret-value" | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
acceptance/bundle/resources/secret_scopes/basic/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
acceptance/bundle/resources/secret_scopes/basic/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
|
|
||
| === create the secret scope | ||
| >>> [CLI] bundle plan | ||
| create secret_scopes.my_scope | ||
|
|
||
| Plan: 1 to add, 0 to change, 0 to delete, 0 unchanged | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/secret-scope-basic-[UNIQUE_NAME]/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] secrets list-scopes -o json | ||
| { | ||
| "backend_type": "DATABRICKS", | ||
| "name": "test-scope-[UNIQUE_NAME]-1" | ||
| } | ||
|
|
||
| === put and get secret in first scope | ||
| >>> [CLI] secrets put-secret test-scope-[UNIQUE_NAME]-1 my-key --string-value my-secret-value | ||
|
|
||
| >>> [CLI] secrets get-secret test-scope-[UNIQUE_NAME]-1 my-key | ||
| { | ||
| "key":"my-key", | ||
| "value":"bXktc2VjcmV0LXZhbHVl" | ||
| } | ||
|
|
||
| >>> print_requests.py //secrets | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/secrets/scopes/create", | ||
| "body": { | ||
| "scope": "test-scope-[UNIQUE_NAME]-1", | ||
| "scope_backend_type": "DATABRICKS" | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/secrets/acls/put", | ||
| "body": { | ||
| "permission": "WRITE", | ||
| "principal": "[email protected]", | ||
| "scope": "test-scope-[UNIQUE_NAME]-1" | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/secrets/put", | ||
| "body": { | ||
| "key": "my-key", | ||
| "scope": "test-scope-[UNIQUE_NAME]-1", | ||
| "string_value": "my-secret-value" | ||
| } | ||
| } | ||
|
|
||
| === update the name of the scope (should recreate) | ||
| >>> [CLI] bundle plan | ||
| recreate secret_scopes.my_scope | ||
|
|
||
| Plan: 1 to add, 0 to change, 1 to delete, 0 unchanged | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/secret-scope-basic-[UNIQUE_NAME]/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] secrets list-scopes -o json | ||
| { | ||
| "backend_type": "DATABRICKS", | ||
| "name": "test-scope-[UNIQUE_NAME]-2" | ||
| } | ||
|
|
||
| === put and get secret in recreated scope | ||
| >>> [CLI] secrets put-secret test-scope-[UNIQUE_NAME]-2 another-key --string-value another-secret-value | ||
|
|
||
| >>> [CLI] secrets get-secret test-scope-[UNIQUE_NAME]-2 another-key | ||
| { | ||
| "key":"another-key", | ||
| "value":"YW5vdGhlci1zZWNyZXQtdmFsdWU=" | ||
| } | ||
|
|
||
| >>> print_requests.py //secrets | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete secret_scope my_scope | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/secret-scope-basic-[UNIQUE_NAME]/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| export SECRET_SCOPE_NAME="test-scope-$UNIQUE_NAME-1" | ||
|
|
||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| rm out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| title "create the secret scope" | ||
| trace $CLI bundle plan | ||
| trace $CLI bundle deploy | ||
|
|
||
| scope_name=$($CLI bundle summary --output json | jq -r '.resources.secret_scopes.my_scope.name') | ||
| trace $CLI secrets list-scopes -o json | jq ".[] | select(.name == \"$scope_name\")" | ||
|
|
||
| title "put and get secret in first scope" | ||
| trace $CLI secrets put-secret $scope_name my-key --string-value "my-secret-value" | ||
| trace $CLI secrets get-secret $scope_name my-key | ||
|
|
||
| trace print_requests.py //secrets | ||
|
|
||
| title "update the name of the scope (should recreate)" | ||
| export SECRET_SCOPE_NAME="test-scope-$UNIQUE_NAME-2" | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| trace $CLI bundle plan | ||
| trace $CLI bundle deploy | ||
|
|
||
| scope_name=$($CLI bundle summary --output json | jq -r '.resources.secret_scopes.my_scope.name') | ||
| trace $CLI secrets list-scopes -o json | jq ".[] | select(.name == \"$scope_name\")" | ||
|
|
||
| title "put and get secret in recreated scope" | ||
| trace $CLI secrets put-secret $scope_name another-key --string-value "another-secret-value" | ||
| trace $CLI secrets get-secret $scope_name another-key | ||
|
|
||
| # Capture API requests for verification. Terraform cleans up ACLs before deleting the scope, but direct does not, hence the difference in requests. | ||
| trace print_requests.py //secrets > out.second-requests.$DATABRICKS_BUNDLE_ENGINE.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Cloud = true | ||
| Local = true | ||
| RecordRequests = true |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newly added tests give more than enough coverage for this. (see basic test)