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
19 changes: 0 additions & 19 deletions acceptance/bundle/summary/show-full-config/databricks.yml

This file was deleted.

3 changes: 0 additions & 3 deletions acceptance/bundle/summary/show-full-config/out.test.toml

This file was deleted.

135 changes: 0 additions & 135 deletions acceptance/bundle/summary/show-full-config/output.txt

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion acceptance/bundle/summary/show-full-config/script

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions acceptance/bundle/summary/show-full-config/test.toml

This file was deleted.

72 changes: 12 additions & 60 deletions cmd/bundle/summary.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package bundle

import (
"context"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config/mutator"
"github.com/databricks/cli/bundle/render"
"github.com/databricks/cli/cmd/bundle/utils"
"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/flags"
"github.com/databricks/cli/libs/logdiag"
"github.com/spf13/cobra"
Expand All @@ -25,38 +21,23 @@ Useful after deployment to see what was created and where to find it.`,

var forcePull bool
var includeLocations bool
var shouldShowFullConfig bool
cmd.Flags().BoolVar(&forcePull, "force-pull", false, "Skip local cache and load the state from the remote workspace")
cmd.Flags().BoolVar(&includeLocations, "include-locations", false, "Include location information in the output")
cmd.Flags().MarkHidden("include-locations")
cmd.Flags().BoolVar(&shouldShowFullConfig, "show-full-config", false, "Load and output the full bundle config")
cmd.Flags().MarkHidden("show-full-config")

cmd.RunE = func(cmd *cobra.Command, args []string) error {
var err error
if shouldShowFullConfig {
ctx := logdiag.InitContext(cmd.Context())
cmd.SetContext(ctx)
logdiag.SetSeverity(ctx, diag.Warning)

err = showFullConfig(ctx, cmd, includeLocations)
if err != nil {
return err
}
} else {
b, err := utils.ProcessBundle(cmd, utils.ProcessOptions{
ReadState: true,
AlwaysPull: forcePull,
IncludeLocations: includeLocations,
InitIDs: true,
})
if err != nil {
return err
}
err = showSummary(cmd, b)
if err != nil {
return err
}
b, err := utils.ProcessBundle(cmd, utils.ProcessOptions{
ReadState: true,
AlwaysPull: forcePull,
IncludeLocations: includeLocations,
InitIDs: true,
})
if err != nil {
return err
}
err = showSummary(cmd, b)
if err != nil {
return err
}

if logdiag.HasError(cmd.Context()) {
Expand All @@ -69,35 +50,6 @@ Useful after deployment to see what was created and where to find it.`,
return cmd
}

func showFullConfig(ctx context.Context, cmd *cobra.Command, includeLocations bool) error {
// call `MustLoad` directly instead of `MustConfigureBundle` because the latter does
// validation that we're not interested in here
b := bundle.MustLoad(ctx)
if b == nil || logdiag.HasError(ctx) {
return nil
}

mutator.DefaultMutators(ctx, b)
if logdiag.HasError(ctx) {
return nil
}

if includeLocations {
// Include location information in the output
bundle.ApplyContext(ctx, b, mutator.PopulateLocations())
if logdiag.HasError(ctx) {
return nil
}
}

err := renderJsonOutput(cmd, b)
if err != nil {
return err
}

return nil
}

func showSummary(cmd *cobra.Command, b *bundle.Bundle) error {
if root.OutputType(cmd) == flags.OutputText {
return render.RenderSummary(cmd.Context(), cmd.OutOrStdout(), b)
Expand Down
Loading