MCPcopy Index your code
hub / github.com/devspace-sh/devspace / startWithWait

Method startWithWait

pkg/devspace/services/sync/controller.go:84–232  ·  view source on GitHub ↗
(ctx devspacecontext.Context, options *Options, parent *tomb.Tomb)

Source from the content-addressed store, hash-verified

82}
83
84func (c *controller) startWithWait(ctx devspacecontext.Context, options *Options, parent *tomb.Tomb) error {
85 if ctx.IsDone() {
86 return nil
87 }
88
89 var (
90 onInitUploadDone chan struct{}
91 onInitDownloadDone chan struct{}
92 onError = make(chan error, 1)
93 onDone = make(chan struct{})
94 )
95
96 // should wait for initial sync?
97 if options.SyncConfig.WaitInitialSync == nil || *options.SyncConfig.WaitInitialSync {
98 onInitUploadDone = make(chan struct{})
99 onInitDownloadDone = make(chan struct{})
100 pluginErr := hook.ExecuteHooks(ctx, map[string]interface{}{
101 "sync_config": options.SyncConfig,
102 }, hook.EventsForSingle("before:initialSync", options.Name).With("sync.beforeInitialSync")...)
103 if pluginErr != nil {
104 return pluginErr
105 }
106 }
107
108 // start the sync
109 client, pod, err := c.startSync(ctx, options, onInitUploadDone, onInitDownloadDone, onDone, onError)
110 if err != nil {
111 pluginErr := hook.ExecuteHooks(ctx, map[string]interface{}{
112 "sync_config": options.SyncConfig,
113 "ERROR": err,
114 }, hook.EventsForSingle("error:initialSync", options.Name).With("sync.errorInitialSync")...)
115 if pluginErr != nil {
116 return pluginErr
117 }
118
119 return err
120 }
121
122 // should wait for initial sync?
123 if options.SyncConfig.WaitInitialSync == nil || *options.SyncConfig.WaitInitialSync {
124 ctx.Log().Info("Waiting for initial sync to complete")
125 defer ctx.Log().Info("Initial sync completed")
126 var (
127 uploadDone = false
128 downloadDone = false
129 )
130 started := time.Now()
131 for {
132 select {
133 case err := <-onError:
134 pluginErr := hook.ExecuteHooks(ctx, map[string]interface{}{
135 "sync_config": options.SyncConfig,
136 "ERROR": err,
137 }, hook.EventsForSingle("error:initialSync", options.Name).With("sync.errorInitialSync")...)
138 if pluginErr != nil {
139 return pluginErr
140 }
141 if ctx.IsDone() {

Callers 1

StartMethod · 0.95

Calls 15

startSyncMethod · 0.95
ExecuteHooksFunction · 0.92
EventsForSingleFunction · 0.92
LogExecuteHooksFunction · 0.92
syncStopFunction · 0.85
PrintPodErrorFunction · 0.85
syncDoneFunction · 0.85
WithMethod · 0.80
KillMethod · 0.80
GoMethod · 0.80
IsDoneMethod · 0.65
LogMethod · 0.65

Tested by

no test coverage detected