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

Method DownloadSupportBundle

internal/cli/client.go:1697–1726  ·  view source on GitHub ↗
(
	ctx context.Context,
	operationID string,
	dst io.Writer,
)

Source from the content-addressed store, hash-verified

1695}
1696
1697func (c *unixSocketClient) DownloadSupportBundle(
1698 ctx context.Context,
1699 operationID string,
1700 dst io.Writer,
1701) (err error) {
1702 if dst == nil {
1703 return errors.New("cli: support bundle download writer is required")
1704 }
1705 response, err := c.doRequest(ctx, http.MethodGet, supportBundleOperationPath(operationID)+"/download", nil, nil)
1706 if err != nil {
1707 return err
1708 }
1709 defer func() {
1710 if closeErr := response.Body.Close(); closeErr != nil {
1711 closeErr = fmt.Errorf("cli: close support bundle download response: %w", closeErr)
1712 if err == nil {
1713 err = closeErr
1714 return
1715 }
1716 err = errors.Join(err, closeErr)
1717 }
1718 }()
1719 if response.StatusCode < 200 || response.StatusCode >= 300 {
1720 return readAPIError(response)
1721 }
1722 if _, err := io.Copy(dst, response.Body); err != nil {
1723 return fmt.Errorf("cli: download support bundle: %w", err)
1724 }
1725 return nil
1726}
1727
1728func supportBundleOperationPath(operationID string) string {
1729 return "/api/support/bundles/" + url.PathEscape(strings.TrimSpace(operationID))

Callers

nothing calls this directly

Calls 4

doRequestMethod · 0.95
readAPIErrorFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected