Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bundle:
name: test-bundle

resources:
secrets:
secret1:
catalog_name: main
schema_name: default
name: test_secret
value:
- hello
- world
comment: "This should fail validation"

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

=== Deploy should fail due to plain text secret value
>>> [CLI] bundle deploy
Warning: expected string, found sequence
at resources.secrets.secret1.value
in databricks.yml:11:9

Error: Secret value must be a string
at resources.secrets.secret1.value

The secret value for "secret1" must be a string.


Exit code: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title "Deploy should fail due to plain text secret value"
trace $CLI bundle deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Cloud = false
RecordRequests = false

Ignore = [".databricks"]

[EnvMatrix]
DATABRICKS_BUNDLE_ENGINE = ["direct"]
14 changes: 14 additions & 0 deletions bundle/config/mutator/validate_secret_value_is_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ func (v *validateSecretValueIsVariable) Apply(ctx context.Context, b *bundle.Bun
p := dyn.NewPath(dyn.Key("resources"), dyn.Key("secrets"), dyn.Key(key), dyn.Key("value"))
val, err := dyn.GetByPath(b.Config.Value(), p)
if dyn.IsNoSuchKeyError(err) {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Secret value must be a string",
Detail: fmt.Sprintf(`The secret value for "%s" must be a string.`, key),
Locations: val.Locations(),
Paths: []dyn.Path{p},
})
continue
}
if err != nil {
Expand All @@ -36,6 +43,13 @@ func (v *validateSecretValueIsVariable) Apply(ctx context.Context, b *bundle.Bun

valueStr, ok := val.AsString()
if !ok {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Secret value must be a string",
Detail: fmt.Sprintf(`The secret value for "%s" must be a string.`, key),
Locations: val.Locations(),
Paths: []dyn.Path{p},
})
continue
}

Expand Down
Loading