mirror of https://github.com/databricks/cli.git
Change flag name, fix output waiting
This commit is contained in:
parent
843f377271
commit
75b2bcbea9
|
@ -37,6 +37,8 @@ func (m *upload) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
|||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
sync.Close()
|
||||
|
||||
log.Infof(ctx, "Uploaded bundle files")
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -26,14 +26,15 @@ func newDeployCommand() *cobra.Command {
|
|||
var failOnActiveRuns bool
|
||||
var computeID string
|
||||
var autoApprove bool
|
||||
var showSyncProgress bool
|
||||
var verbose bool
|
||||
cmd.Flags().BoolVar(&force, "force", false, "Force-override Git branch validation.")
|
||||
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 jobs or pipelines in the deployment.")
|
||||
cmd.Flags().StringVarP(&computeID, "compute-id", "c", "", "Override compute in the deployment with the given compute ID.")
|
||||
cmd.Flags().BoolVar(&autoApprove, "auto-approve", false, "Skip interactive approvals that might be required for deployment.")
|
||||
cmd.Flags().BoolVar(&showSyncProgress, "sync-progress", false, "Show file synchronisation progress.")
|
||||
cmd.Flags().MarkHidden("sync-progress")
|
||||
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 {
|
||||
ctx := cmd.Context()
|
||||
|
@ -56,7 +57,7 @@ func newDeployCommand() *cobra.Command {
|
|||
})
|
||||
|
||||
var outputHandler sync.OutputHandler
|
||||
if showSyncProgress {
|
||||
if verbose {
|
||||
outputHandler = func(ctx context.Context, c <-chan sync.Event) {
|
||||
sync.TextOutput(ctx, c, cmd.OutOrStdout())
|
||||
}
|
||||
|
|
|
@ -52,9 +52,9 @@ type Sync struct {
|
|||
filer filer.Filer
|
||||
|
||||
// Synchronization progress events are sent to this event notifier.
|
||||
notifier EventNotifier
|
||||
notifierWg *stdsync.WaitGroup
|
||||
seq int
|
||||
notifier EventNotifier
|
||||
outputWaitGroup *stdsync.WaitGroup
|
||||
seq int
|
||||
}
|
||||
|
||||
// New initializes and returns a new [Sync] instance.
|
||||
|
@ -113,13 +113,13 @@ func New(ctx context.Context, opts SyncOptions) (*Sync, error) {
|
|||
}
|
||||
|
||||
var notifier EventNotifier
|
||||
var notifierWg = &stdsync.WaitGroup{}
|
||||
var outputWaitGroup = &stdsync.WaitGroup{}
|
||||
if opts.OutputHandler != nil {
|
||||
ch := make(chan Event, MaxRequestsInFlight)
|
||||
notifier = &ChannelNotifier{ch}
|
||||
notifierWg.Add(1)
|
||||
outputWaitGroup.Add(1)
|
||||
go func() {
|
||||
defer notifierWg.Done()
|
||||
defer outputWaitGroup.Done()
|
||||
opts.OutputHandler(ctx, ch)
|
||||
}()
|
||||
} else {
|
||||
|
@ -129,14 +129,14 @@ func New(ctx context.Context, opts SyncOptions) (*Sync, error) {
|
|||
return &Sync{
|
||||
SyncOptions: &opts,
|
||||
|
||||
fileSet: fileSet,
|
||||
includeFileSet: includeFileSet,
|
||||
excludeFileSet: excludeFileSet,
|
||||
snapshot: snapshot,
|
||||
filer: filer,
|
||||
notifier: notifier,
|
||||
notifierWg: notifierWg,
|
||||
seq: 0,
|
||||
fileSet: fileSet,
|
||||
includeFileSet: includeFileSet,
|
||||
excludeFileSet: excludeFileSet,
|
||||
snapshot: snapshot,
|
||||
filer: filer,
|
||||
notifier: notifier,
|
||||
outputWaitGroup: outputWaitGroup,
|
||||
seq: 0,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -147,12 +147,12 @@ func (s *Sync) Events() <-chan Event {
|
|||
}
|
||||
|
||||
func (s *Sync) Close() {
|
||||
s.notifierWg.Wait()
|
||||
if s.notifier == nil {
|
||||
return
|
||||
}
|
||||
s.notifier.Close()
|
||||
s.notifier = nil
|
||||
s.outputWaitGroup.Wait()
|
||||
}
|
||||
|
||||
func (s *Sync) notifyStart(ctx context.Context, d diff) {
|
||||
|
|
Loading…
Reference in New Issue