Skip to content

Commit

Permalink
Use hashicorp retryable http
Browse files Browse the repository at this point in the history
Signed-off-by: Appu Goundan <[email protected]>
  • Loading branch information
loosebazooka committed Aug 16, 2023
1 parent fcc38fc commit e229678
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 31 deletions.
6 changes: 5 additions & 1 deletion debian_package_manager/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ go 1.20

require (
github.com/google/go-cmp v0.5.6
github.com/hashicorp/go-retryablehttp v0.7.4
github.com/pkg/errors v0.9.1
github.com/ulikunitz/xz v0.5.11
golang.org/x/sync v0.2.0
gopkg.in/yaml.v3 v3.0.1
)

require golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
require (
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)
9 changes: 9 additions & 0 deletions debian_package_manager/go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA=
github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
Expand Down
4 changes: 2 additions & 2 deletions debian_package_manager/internal/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/GoogleContainerTools/distroless/debian_package_manager/internal/build/config"
"github.com/GoogleContainerTools/distroless/debian_package_manager/internal/deb"
"github.com/GoogleContainerTools/distroless/debian_package_manager/internal/rhttp"
"github.com/hashicorp/go-retryablehttp"
"github.com/pkg/errors"
"github.com/ulikunitz/xz"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -61,7 +61,7 @@ func extractPackageInfo(snapshots *config.Snapshots, arch config.Arch, distro co
}

func resolvePackages(pi *deb.PackageIndex, packages map[string]bool) (map[string]*deb.Package, error) {
resp, err := rhttp.Get(pi.URL)
resp, err := retryablehttp.Get(pi.URL)
if err != nil {
return nil, errors.Wrapf(err, "failed to fetch remote file: %s", pi.URL)
} else if resp.StatusCode != http.StatusOK {
Expand Down
4 changes: 2 additions & 2 deletions debian_package_manager/internal/deb/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"time"

"github.com/GoogleContainerTools/distroless/debian_package_manager/internal/build/config"
"github.com/GoogleContainerTools/distroless/debian_package_manager/internal/rhttp"
"github.com/hashicorp/go-retryablehttp"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -55,7 +55,7 @@ var (
func latest(urltemplate string) (string, error) {
year, month, _ := time.Now().Date()
snapshotURL := fmt.Sprintf(urltemplate, year, month)
resp, err := rhttp.Get(snapshotURL)
resp, err := retryablehttp.Get(snapshotURL)
if err != nil {
return "", err
}
Expand Down
26 changes: 0 additions & 26 deletions debian_package_manager/internal/rhttp/rhttp.go

This file was deleted.

0 comments on commit e229678

Please sign in to comment.