mirror of https://github.com/databricks/cli.git
Address feedback
This commit is contained in:
parent
75b2bcbea9
commit
5c850df92c
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type upload struct {
|
type upload struct {
|
||||||
outpuHandler sync.OutputHandler
|
outputHandler sync.OutputHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *upload) Name() string {
|
func (m *upload) Name() string {
|
||||||
|
@ -26,19 +26,18 @@ func (m *upload) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.OutputHandler = m.outpuHandler
|
opts.OutputHandler = m.outputHandler
|
||||||
sync, err := sync.New(ctx, *opts)
|
sync, err := sync.New(ctx, *opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
defer sync.Close()
|
||||||
|
|
||||||
b.Files, err = sync.RunOnce(ctx)
|
b.Files, err = sync.RunOnce(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sync.Close()
|
|
||||||
|
|
||||||
log.Infof(ctx, "Uploaded bundle files")
|
log.Infof(ctx, "Uploaded bundle files")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,7 @@ func New() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer s.Close()
|
||||||
|
|
||||||
if f.watch {
|
if f.watch {
|
||||||
err = s.RunContinuous(ctx)
|
err = s.RunContinuous(ctx)
|
||||||
|
@ -141,7 +142,6 @@ func New() *cobra.Command {
|
||||||
_, err = s.RunOnce(ctx)
|
_, err = s.RunOnce(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Close()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,12 @@ type Sync struct {
|
||||||
filer filer.Filer
|
filer filer.Filer
|
||||||
|
|
||||||
// Synchronization progress events are sent to this event notifier.
|
// Synchronization progress events are sent to this event notifier.
|
||||||
notifier EventNotifier
|
notifier EventNotifier
|
||||||
|
seq int
|
||||||
|
|
||||||
|
// WaitGroup is automatically created when an output handler is provided in the SyncOptions.
|
||||||
|
// Close call is required to ensure the output handler goroutine handles all events in time.
|
||||||
outputWaitGroup *stdsync.WaitGroup
|
outputWaitGroup *stdsync.WaitGroup
|
||||||
seq int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New initializes and returns a new [Sync] instance.
|
// New initializes and returns a new [Sync] instance.
|
||||||
|
@ -140,12 +143,6 @@ func New(ctx context.Context, opts SyncOptions) (*Sync, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sync) Events() <-chan Event {
|
|
||||||
ch := make(chan Event, MaxRequestsInFlight)
|
|
||||||
s.notifier = &ChannelNotifier{ch}
|
|
||||||
return ch
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Sync) Close() {
|
func (s *Sync) Close() {
|
||||||
if s.notifier == nil {
|
if s.notifier == nil {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue