-
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
Conversation
@@ -7,19 +7,14 @@ Warning: Variable interpolation is not supported for fields that configure authe | |||
Interpolation is not supported for the field workspace.host. Please set | |||
the DATABRICKS_HOST environment variable if you wish to configure this field at runtime. | |||
|
|||
Error: failed during request visitor: parse "https://${var.host}": invalid character "{" in host name | |||
Error: cannot resolve bundle auth configuration: config host mismatch: DATABRICKS_HOST is defined as [DATABRICKS_URL], but CLI configured to use ${var.host} |
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
@@ -1,26 +0,0 @@ | |||
package databrickscfg |
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.
Moved to shared package
return u1.Host == u2.Host | ||
} | ||
|
||
func fixUrlIfNeeded(s string) string { |
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.
Apparently u := url.Parse('foo.com')
will put foo.com
in u.Path
instead of u.Host
so we're handling such cases explicitly
hostFromProfile := normalizeHost(match.Key("host").Value()) | ||
if hostFromProfile != "" && host != "" && hostFromProfile != host { | ||
hostFromProfile := workspace.NormalizeHost(match.Key("host").Value()) | ||
if hostFromProfile != "" && host != "" && !workspace.MatchHost(hostFromProfile, host) { |
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.
Added same ignore-scheme-behavior for config-defined hosts
cmd/root/bundle.go
Outdated
@@ -94,6 +95,8 @@ func configureBundle(cmd *cobra.Command, b *bundle.Bundle) (*bundle.Bundle, diag | |||
return b, diags | |||
} | |||
|
|||
diags = diags.Extend(bundle.Apply(ctx, b, validate.NoInterpolationInAuthConfig())) |
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.
You can actually convert the whole NoInterpolationInAuthConfig
mutator in a usual Go function and don't use bundle.Apply here at all because this mutator does not actually mutate anything
bundle/config/workspace_test.go
Outdated
@@ -149,3 +149,34 @@ func TestWorkspaceVerifyProfileForHost(t *testing.T) { | |||
assert.ErrorContains(t, err, "config host mismatch") | |||
}) | |||
} | |||
|
|||
func TestWorkspaceValidateConfigAndEnvHost(t *testing.T) { |
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.
Can you instead convert this to acceptance test?
## Release v0.245.0 ### Bundles * Processing 'artifacts' section is now done in "bundle validate" (adding defaults, inferring "build", asserting required fields) ([#2526])(#2526)) * When uploading artifacts, include relative path in log message ([#2539])(#2539)) * Added support for clusters in deployment bind/unbind commands ([#2536](#2536)) * Added support for volumes in deployment bind/unbind commands ([#2527](#2527)) * Added support for dashboards in deployment bind/unbind commands ([#2516](#2516)) * Added support for registered models in deployment bind/unbind commands ([#2556](#2556)) * Added a mismatch check when host is defined in config and as an env variable ([#2549](#2549)) * New attribute on artifacts entries: `dynamic_version`. When set to true, it patches the wheel with dynamic version suffix so it is always used by Databricks environments, even if original wheel version is the same. Intended for development loop on interactive clusters. ([#2520](#2520))
Changes
https://
prefix is ignored during validation on host mismatch, both in env and profilesWhy
If I defined both DATABRICKS_TOKEN and DATABRICKS_HOST I expect this token to be used only for requests to DATABRICKS_HOST, while now we have it added to
w.CurrentUser.Me
requests to the hosts defined in the configTests
Added acceptance tests