-
Notifications
You must be signed in to change notification settings - Fork 147
Expand file tree
/
Copy pathdeploy.go
More file actions
74 lines (65 loc) · 2.47 KB
/
deploy.go
File metadata and controls
74 lines (65 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copied from cmd/bundle/deploy.go and adapted for pipelines use.
// Consider if changes made here should be made to the bundle counterpart as well.
package pipelines
import (
"fmt"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config/mutator"
"github.com/databricks/cli/cmd/bundle/utils"
"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/logdiag"
libsutils "github.com/databricks/cli/libs/utils"
"github.com/spf13/cobra"
)
func deployCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "deploy",
Short: "Deploy pipelines",
Long: `Deploy pipelines by uploading all files defined in the project to the target workspace, and creating or updating the pipelines defined in the workspace.`,
Args: root.NoArgs,
}
var forceLock bool
var failOnActiveRuns bool
var autoApprove bool
var verbose bool
cmd.Flags().BoolVar(&forceLock, "force-lock", false, "Force acquisition of deployment lock.")
cmd.Flags().BoolVar(&failOnActiveRuns, "fail-on-active-runs", false, "Fail if there are running pipelines in the deployment.")
cmd.Flags().BoolVar(&autoApprove, "auto-approve", false, "Skip interactive approvals that might be required for deployment.")
cmd.Flags().BoolVar(&verbose, "verbose", false, "Enable verbose output.")
// Verbose flag currently only affects file sync output, it's used by the vscode extension
cmd.Flags().MarkHidden("verbose")
cmd.RunE = func(cmd *cobra.Command, args []string) error {
b, err := utils.ProcessBundle(cmd, utils.ProcessOptions{
InitFunc: func(b *bundle.Bundle) {
b.Config.Bundle.Deployment.Lock.Force = forceLock
b.AutoApprove = autoApprove
if cmd.Flag("fail-on-active-runs").Changed {
b.Config.Bundle.Deployment.FailOnActiveRuns = failOnActiveRuns
}
},
Verbose: verbose,
AlwaysPull: true,
FastValidate: true,
Build: true,
Deploy: true,
IsPipelinesCLI: true,
})
if err != nil {
return err
}
ctx := cmd.Context()
bundle.ApplyContext(ctx, b, mutator.InitializeURLs())
if logdiag.HasError(ctx) {
return root.ErrAlreadyPrinted
}
for _, group := range b.Config.Resources.AllResources() {
for _, resourceKey := range libsutils.SortedKeys(group.Resources) {
resource := group.Resources[resourceKey]
cmdio.LogString(ctx, fmt.Sprintf("View your %s %s here: %s", resource.ResourceDescription().SingularName, resourceKey, resource.GetURL()))
}
}
return nil
}
return cmd
}