Skip to content

Commit

Permalink
Add retry for 404 status code (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
godrei authored Feb 16, 2024
1 parent 2184d65 commit 6eb0125
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package main

import (
"context"
"fmt"
"net/http"
"os"
"strings"
"unicode/utf8"
Expand All @@ -17,6 +19,7 @@ import (
"github.com/bitrise-io/go-xcode/v2/autocodesign/codesignasset"
"github.com/bitrise-io/go-xcode/v2/autocodesign/keychain"
"github.com/bitrise-io/go-xcode/v2/autocodesign/profiledownloader"
"github.com/hashicorp/go-retryablehttp"
)

// Config ...
Expand Down Expand Up @@ -269,7 +272,16 @@ func main() {
failE(fmt.Errorf("Failed to open Keychain: %w", err))
}

httpClient := retry.NewHTTPClient().StandardClient()
retryHTTPClient := retry.NewHTTPClient()
retryHTTPClient.CheckRetry = func(ctx context.Context, resp *http.Response, err error) (bool, error) {
if resp != nil && resp.StatusCode == http.StatusNotFound {
log.Debugf("Received HTTP 404, retrying request...")
return true, nil
}

return retryablehttp.DefaultRetryPolicy(ctx, resp, err)
}
httpClient := retryHTTPClient.StandardClient()
certDownloader := certdownloader.NewDownloader(certificateURLPassphraseMap, httpClient)
profileDownloader := profiledownloader.New(provisioningProfileURLs, httpClient)
assetInstaller := codesignasset.NewWriter(*keychainWriter)
Expand Down

0 comments on commit 6eb0125

Please sign in to comment.