Do not use `.MustString()` in auth interpolation warning (#2412)

## Why
Addresses post merge feedback from
https://github.com/databricks/cli/pull/2399#discussion_r1975091730

## Tests
N/A
This commit is contained in:
shreyas-goenka 2025-03-03 17:33:46 +05:30 committed by GitHub
parent 8f8f24c3a9
commit 25a7e0a72b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 6 deletions

View File

@ -24,7 +24,10 @@ func (f *noInterpolationInAuthConfig) Name() string {
func (f *noInterpolationInAuthConfig) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
authFields := []string{
// Generic attributes.
"host", "profile", "auth_type", "metadata_service_url",
"host",
"profile",
"auth_type",
"metadata_service_url",
// OAuth specific attributes.
"client_id",
@ -33,8 +36,12 @@ func (f *noInterpolationInAuthConfig) Apply(ctx context.Context, b *bundle.Bundl
"google_service_account",
// Azure specific attributes.
"azure_resource_id", "azure_use_msi", "azure_client_id", "azure_tenant_id",
"azure_environment", "azure_login_app_id",
"azure_resource_id",
"azure_use_msi",
"azure_client_id",
"azure_tenant_id",
"azure_environment",
"azure_login_app_id",
}
diags := diag.Diagnostics{}
@ -49,12 +56,11 @@ func (f *noInterpolationInAuthConfig) Apply(ctx context.Context, b *bundle.Bundl
return diag.FromErr(err)
}
if v.Kind() == dyn.KindInvalid || v.Kind() == dyn.KindNil {
vv, ok := v.AsString()
if !ok {
continue
}
vv := v.MustString()
// Check if the field contains interpolation.
if dynvar.ContainsVariableReference(vv) {
envVar, ok := auth.GetEnvFor(fieldName)