Skip to content

Commit

Permalink
url: update azure blob fetching to fallback on HTTP fetch on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
prestist committed Feb 5, 2025
1 parent af19b7d commit 6754f74
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/resource/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ func (f *Fetcher) FetchToBuffer(u url.URL, opts FetchOptions) ([]byte, error) {
case "http", "https":
if strings.HasSuffix(u.Host, ".blob.core.windows.net") {
err = f.fetchFromAzureBlob(u, dest, opts)
if err != nil {
f.Logger.Info("could not authenticate using azure default credentials: %v", err)
f.Logger.Debug("falling back to fetchFromHTTP")
err = f.fetchFromHTTP(u, dest, opts)
}
} else {
err = f.fetchFromHTTP(u, dest, opts)
}
Expand Down Expand Up @@ -217,7 +222,13 @@ func (f *Fetcher) Fetch(u url.URL, dest *os.File, opts FetchOptions) error {
switch u.Scheme {
case "http", "https":
if strings.HasSuffix(u.Host, ".blob.core.windows.net") {
return f.fetchFromAzureBlob(u, dest, opts)
err := f.fetchFromAzureBlob(u, dest, opts)
if err != nil {
f.Logger.Info("could not authenticate using azure default credentials: %v", err)
f.Logger.Debug("falling back to fetchFromHTTP")
err = f.fetchFromHTTP(u, dest, opts)
}
return err
}
return f.fetchFromHTTP(u, dest, opts)
case "tftp":
Expand Down

0 comments on commit 6754f74

Please sign in to comment.