-
Notifications
You must be signed in to change notification settings - Fork 77
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
Detect mismatch between host defined in config and env variable #2549
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
eec36ef
Move `normaliseHost` helper to lib/
ilyakuz-db 32e4600
Added validation
ilyakuz-db 7296a7f
Moved NoInterpolationInAuthConfig before Workspace client is initialised
ilyakuz-db d74786d
Merge branch 'main' of github.com:databricks/cli into env-vs-config-h…
ilyakuz-db 80c6d9f
Updates changelog
ilyakuz-db 8678ebf
Ignore scheme in host match
ilyakuz-db c7ddaab
Merge branch 'main' into env-vs-config-host-mismatch
ilyakuz-db 3bd5782
Moved variable check in simple function
ilyakuz-db 01192f7
Replaced unit test with acceptance test
ilyakuz-db d404bc6
Merge branch 'env-vs-config-host-mismatch' of github.com:databricks/c…
ilyakuz-db d2eab7d
Move tests to separate directory
ilyakuz-db 3e1dfce
Merge branch 'main' into env-vs-config-host-mismatch
ilyakuz-db 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 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 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,5 @@ | ||
[DEFAULT] | ||
host = https://bar.com | ||
|
||
[profile_with_matching_host] | ||
host = $DATABRICKS_HOST |
This file contains 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,11 @@ | ||
bundle: | ||
name: test-auth | ||
|
||
targets: | ||
match: | ||
default: true | ||
workspace: | ||
host: $DATABRICKS_HOST | ||
not_match: | ||
workspace: | ||
host: https://foo.com |
This file contains 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,35 @@ | ||
|
||
=== Bundle commands load bundle configuration with DATABRICKS_HOST defined, validation not OK (env-defined host doesn't match bundle host) | ||
>>> errcode [CLI] bundle validate -t not_match | ||
Error: cannot resolve bundle auth configuration: config host mismatch: DATABRICKS_HOST is defined as [DATABRICKS_HOST], but CLI configured to use https://foo.com | ||
|
||
Name: test-auth | ||
Target: not_match | ||
Workspace: | ||
Host: https://foo.com | ||
|
||
Found 1 error | ||
|
||
Exit code: 1 | ||
|
||
=== Bundle commands load bundle configuration with DATABRICKS_HOST defined, validation OK (env-defined host matches bundle host) | ||
>>> errcode [CLI] bundle validate -t match | ||
Name: test-auth | ||
Target: match | ||
Workspace: | ||
Host: [DATABRICKS_HOST] | ||
User: [USERNAME] | ||
Path: /Workspace/Users/[USERNAME]/.bundle/test-auth/match | ||
|
||
Validation OK! | ||
|
||
=== Bundle commands load bundle configuration with -p flag with DATABRICKS_HOST defined, host in profile matches bundle host but env-defined host doesn't | ||
>>> errcode [CLI] bundle validate -t match -p profile_with_matching_host | ||
Name: test-auth | ||
Target: match | ||
Workspace: | ||
Host: [DATABRICKS_HOST] | ||
User: [USERNAME] | ||
Path: /Workspace/Users/[USERNAME]/.bundle/test-auth/match | ||
|
||
Validation OK! |
This file contains 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,15 @@ | ||
# Replace placeholder with an actual host URL | ||
envsubst < databricks.yml > out.yml && mv out.yml databricks.yml | ||
envsubst < .databrickscfg > out && mv out .databrickscfg | ||
|
||
export DATABRICKS_CONFIG_FILE=.databrickscfg | ||
|
||
title "Bundle commands load bundle configuration with DATABRICKS_HOST defined, validation not OK (env-defined host doesn't match bundle host)" | ||
trace errcode $CLI bundle validate -t not_match | ||
|
||
title "Bundle commands load bundle configuration with DATABRICKS_HOST defined, validation OK (env-defined host matches bundle host)" | ||
trace errcode $CLI bundle validate -t match | ||
|
||
export DATABRICKS_HOST="https://baz.com" | ||
title "Bundle commands load bundle configuration with -p flag with DATABRICKS_HOST defined, host in profile matches bundle host but env-defined host doesn't" | ||
trace errcode $CLI bundle validate -t match -p profile_with_matching_host |
This file contains 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,5 @@ | ||
# Some of the clouds have DATABRICKS_HOST variable setup without https:// prefix | ||
# In the result, output is replaced with DATABRICKS_URL variable instead of DATABRICKS_HOST | ||
[[Repls]] | ||
Old='DATABRICKS_URL' | ||
New='DATABRICKS_HOST' |
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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 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 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.
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.
Just in case - we have a warning displayed above that explains incorrect usage of variables in auth-related fields