Skip to content

Commit

Permalink
Remove embed_credentials default from tfdyn
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Oct 1, 2024
1 parent b63e943 commit b54c10b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
9 changes: 0 additions & 9 deletions bundle/deploy/terraform/tfdyn/convert_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ func convertDashboardResource(ctx context.Context, vin dyn.Value) (dyn.Value, er
}
}

// Default the "embed_credentials" field to "false", if not already set.
// This is different from the behavior in the Terraform provider, so we make it explicit.
if _, ok := vout.Get("embed_credentials").AsBool(); !ok {
vout, err = dyn.Set(vout, "embed_credentials", dyn.V(false))
if err != nil {
return dyn.InvalidValue, fmt.Errorf("failed to set embed_credentials: %w", err)
}
}

return vout, nil
}

Expand Down
35 changes: 0 additions & 35 deletions bundle/deploy/terraform/tfdyn/convert_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tfdyn

import (
"context"
"fmt"
"testing"

"github.com/databricks/cli/bundle/config/resources"
Expand Down Expand Up @@ -79,37 +78,3 @@ func TestConvertDashboardFilePath(t *testing.T) {
"file_path": "some/path",
})
}

func TestConvertDashboardEmbedCredentialsPassthrough(t *testing.T) {
for _, v := range []bool{true, false} {
t.Run(fmt.Sprintf("set to %v", v), func(t *testing.T) {
vin := dyn.V(map[string]dyn.Value{
"embed_credentials": dyn.V(v),
})

ctx := context.Background()
out := schema.NewResources()
err := dashboardConverter{}.Convert(ctx, "my_dashboard", vin, out)
require.NoError(t, err)

// Assert that the "embed_credentials" is set as configured.
assert.Subset(t, out.Dashboard["my_dashboard"], map[string]any{
"embed_credentials": v,
})
})
}
}

func TestConvertDashboardEmbedCredentialsDefault(t *testing.T) {
vin := dyn.V(map[string]dyn.Value{})

ctx := context.Background()
out := schema.NewResources()
err := dashboardConverter{}.Convert(ctx, "my_dashboard", vin, out)
require.NoError(t, err)

// Assert that the "embed_credentials" is set to false (by default).
assert.Subset(t, out.Dashboard["my_dashboard"], map[string]any{
"embed_credentials": false,
})
}

0 comments on commit b54c10b

Please sign in to comment.