Skip to content

Commit 04c6d11

Browse files
authored
Merge branch 'scaleway:master' into master
2 parents dffee9c + 9908267 commit 04c6d11

File tree

5 files changed

+66
-52
lines changed

5 files changed

+66
-52
lines changed

core/custom_transport.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package core
2+
3+
import (
4+
"context"
5+
"crypto/tls"
6+
"net"
7+
"net/http"
8+
"time"
9+
10+
"github.com/scaleway/scaleway-sdk-go/logger"
11+
)
12+
13+
const defaultRetryInterval = 1 * time.Second
14+
15+
var socketTransport = &http.Transport{}
16+
17+
func init() {
18+
socketTransport.DisableCompression = true
19+
socketTransport.DialContext = func(_ context.Context, _, _ string) (net.Conn, error) {
20+
return net.DialTimeout("unix", "/var/run/docker.sock", 32000000000)
21+
}
22+
}
23+
24+
type SocketPassthroughTransport struct{}
25+
26+
func (r *SocketPassthroughTransport) RoundTrip(request *http.Request) (*http.Response, error) {
27+
if request.URL.Host == "/var/run/docker.sock" {
28+
return socketTransport.RoundTrip(request)
29+
}
30+
31+
return http.DefaultTransport.RoundTrip(request)
32+
}
33+
34+
type retryableHTTPTransport struct {
35+
transport http.RoundTripper
36+
}
37+
38+
func (r *retryableHTTPTransport) RoundTrip(request *http.Request) (*http.Response, error) {
39+
res, err := r.transport.RoundTrip(request)
40+
if err == nil && res.StatusCode == http.StatusTooManyRequests {
41+
time.Sleep(defaultRetryInterval)
42+
43+
return r.RoundTrip(request)
44+
}
45+
46+
return res, err
47+
}
48+
49+
func (r *retryableHTTPTransport) SetInsecureTransport() {
50+
transportClient, ok := http.DefaultTransport.(*http.Transport)
51+
if !ok {
52+
logger.Warningf(
53+
"cli: cannot use insecure mode with DefaultTransport of type %T",
54+
http.DefaultTransport,
55+
)
56+
57+
return
58+
}
59+
if transportClient.TLSClientConfig == nil {
60+
transportClient.TLSClientConfig = &tls.Config{}
61+
}
62+
transportClient.TLSClientConfig.InsecureSkipVerify = true
63+
}

core/http_retry.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

core/socket_passthrough_transport.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
github.com/mattn/go-isatty v0.0.20
2424
github.com/moby/buildkit v0.13.2
2525
github.com/opencontainers/go-digest v1.0.0
26-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34.0.20250716080040-6038c5316f66
26+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34.0.20250725144419-de749e386a06
2727
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
2828
github.com/spf13/cobra v1.9.1
2929
github.com/spf13/pflag v1.0.7

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
466466
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
467467
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
468468
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
469-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34.0.20250716080040-6038c5316f66 h1:cdds9CiMBdb9rLJ9xlbTkCtCXfux41nxx3j6+qtCf0Q=
470-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34.0.20250716080040-6038c5316f66/go.mod h1:fw6BmcfYRs2BEHYW0c3/rR0JgZHvdx6uMYqpeUJx3Bc=
469+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34.0.20250725144419-de749e386a06 h1:HLJAN1hyivE7jP5/0TRh4cNVWiVKJFjihBWGajSLLOk=
470+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34.0.20250725144419-de749e386a06/go.mod h1:fw6BmcfYRs2BEHYW0c3/rR0JgZHvdx6uMYqpeUJx3Bc=
471471
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
472472
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
473473
github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA=

0 commit comments

Comments
 (0)