MCPcopy Create free account
hub / github.com/compozy/agh / waitForSupportBundle

Function waitForSupportBundle

internal/cli/support.go:186–233  ·  view source on GitHub ↗
(
	ctx context.Context,
	deps commandDeps,
	client DaemonClient,
	operationID string,
)

Source from the content-addressed store, hash-verified

184}
185
186func waitForSupportBundle(
187 ctx context.Context,
188 deps commandDeps,
189 client DaemonClient,
190 operationID string,
191) (SupportBundleOperationRecord, error) {
192 operationID = strings.TrimSpace(operationID)
193 if operationID == "" {
194 return SupportBundleOperationRecord{}, errors.New("cli: support bundle operation id is required")
195 }
196 waitCtx := ctx
197 if waitCtx == nil {
198 waitCtx = context.Background()
199 }
200 if _, hasDeadline := waitCtx.Deadline(); !hasDeadline {
201 var cancel context.CancelFunc
202 waitCtx, cancel = context.WithTimeout(waitCtx, defaultSupportBundleTimeout)
203 defer cancel()
204 }
205
206 ticker := time.NewTicker(deps.pollInterval)
207 defer ticker.Stop()
208
209 for {
210 select {
211 case <-waitCtx.Done():
212 return SupportBundleOperationRecord{}, fmt.Errorf(
213 "cli: support bundle did not complete before timeout: %w",
214 waitCtx.Err(),
215 )
216 case <-ticker.C:
217 operation, err := client.GetSupportBundle(waitCtx, operationID)
218 if err != nil {
219 continue
220 }
221 switch strings.TrimSpace(operation.Status) {
222 case supportStatusCompleted:
223 return operation, nil
224 case supportStatusFailed:
225 reason := strings.TrimSpace(operation.FailureReason)
226 if reason == "" {
227 reason = "support bundle creation failed"
228 }
229 return operation, errors.New("cli: " + reason)
230 }
231 }
232 }
233}
234
235func resolveSupportBundleOutputPath(
236 deps commandDeps,

Callers 1

runSupportBundleCommandFunction · 0.70

Calls 4

StopMethod · 0.65
DoneMethod · 0.65
GetSupportBundleMethod · 0.65
ErrMethod · 0.45

Tested by

no test coverage detected