Merge branch 'main' into kanterov/pydabs-explain-errors

This commit is contained in:
Gleb Kanterov 2024-09-02 11:30:46 +02:00 committed by GitHub
commit e8ee6e136d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 9 deletions

View File

@ -6,5 +6,5 @@ type Deployment struct {
FailOnActiveRuns bool `json:"fail_on_active_runs,omitempty"` FailOnActiveRuns bool `json:"fail_on_active_runs,omitempty"`
// Lock configures locking behavior on deployment. // Lock configures locking behavior on deployment.
Lock Lock `json:"lock"` Lock Lock `json:"lock,omitempty"`
} }

View File

@ -10,7 +10,6 @@ import (
"github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn"
"github.com/databricks/cli/libs/dyn/convert" "github.com/databricks/cli/libs/dyn/convert"
"github.com/databricks/cli/libs/dyn/dynvar" "github.com/databricks/cli/libs/dyn/dynvar"
"github.com/databricks/cli/libs/log"
) )
type resolveVariableReferences struct { type resolveVariableReferences struct {
@ -124,6 +123,7 @@ func (m *resolveVariableReferences) Apply(ctx context.Context, b *bundle.Bundle)
// We rewrite it here to make the resolution logic simpler. // We rewrite it here to make the resolution logic simpler.
varPath := dyn.NewPath(dyn.Key("var")) varPath := dyn.NewPath(dyn.Key("var"))
var diags diag.Diagnostics
err := b.Config.Mutate(func(root dyn.Value) (dyn.Value, error) { err := b.Config.Mutate(func(root dyn.Value) (dyn.Value, error) {
// Synthesize a copy of the root that has all fields that are present in the type // Synthesize a copy of the root that has all fields that are present in the type
// but not set in the dynamic value set to their corresponding empty value. // but not set in the dynamic value set to their corresponding empty value.
@ -180,14 +180,13 @@ func (m *resolveVariableReferences) Apply(ctx context.Context, b *bundle.Bundle)
// Normalize the result because variable resolution may have been applied to non-string fields. // Normalize the result because variable resolution may have been applied to non-string fields.
// For example, a variable reference may have been resolved to a integer. // For example, a variable reference may have been resolved to a integer.
root, diags := convert.Normalize(b.Config, root) root, normaliseDiags := convert.Normalize(b.Config, root)
for _, diag := range diags { diags = diags.Extend(normaliseDiags)
// This occurs when a variable's resolved value is incompatible with the field's type.
// Log a warning until we have a better way to surface these diagnostics to the user.
log.Warnf(ctx, "normalization diagnostic: %s", diag.Summary)
}
return root, nil return root, nil
}) })
return diag.FromErr(err) if err != nil {
diags = diags.Extend(diag.FromErr(err))
}
return diags
} }