mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Remove Docker from some functions
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
d85f5e7320
commit
de5c80b4f3
10 changed files with 16 additions and 16 deletions
|
@ -50,7 +50,7 @@ func (p *v1Puller) Pull(ctx context.Context, ref reference.Named, platform strin
|
|||
tr := transport.NewTransport(
|
||||
// TODO(tiborvass): was ReceiveTimeout
|
||||
registry.NewTransport(tlsConfig),
|
||||
registry.DockerHeaders(dockerversion.DockerUserAgent(ctx), p.config.MetaHeaders)...,
|
||||
registry.Headers(dockerversion.DockerUserAgent(ctx), p.config.MetaHeaders)...,
|
||||
)
|
||||
client := registry.HTTPClient(tr)
|
||||
v1Endpoint := p.endpoint.ToV1Endpoint(dockerversion.DockerUserAgent(ctx), p.config.MetaHeaders)
|
||||
|
|
|
@ -38,7 +38,7 @@ func (p *v1Pusher) Push(ctx context.Context) error {
|
|||
tr := transport.NewTransport(
|
||||
// TODO(tiborvass): was NoTimeout
|
||||
registry.NewTransport(tlsConfig),
|
||||
registry.DockerHeaders(dockerversion.DockerUserAgent(ctx), p.config.MetaHeaders)...,
|
||||
registry.Headers(dockerversion.DockerUserAgent(ctx), p.config.MetaHeaders)...,
|
||||
)
|
||||
client := registry.HTTPClient(tr)
|
||||
v1Endpoint := p.endpoint.ToV1Endpoint(dockerversion.DockerUserAgent(ctx), p.config.MetaHeaders)
|
||||
|
|
|
@ -82,7 +82,7 @@ func NewV2Repository(ctx context.Context, repoInfo *registry.RepositoryInfo, end
|
|||
base.Dial = proxyDialer.Dial
|
||||
}
|
||||
|
||||
modifiers := registry.DockerHeaders(dockerversion.DockerUserAgent(ctx), metaHeaders)
|
||||
modifiers := registry.Headers(dockerversion.DockerUserAgent(ctx), metaHeaders)
|
||||
authTransport := transport.NewTransport(base, modifiers...)
|
||||
|
||||
challengeManager, foundVersion, err := registry.PingV2Registry(endpoint.URL, authTransport)
|
||||
|
|
|
@ -29,9 +29,9 @@ var (
|
|||
// ValidateHost validates that the specified string is a valid host and returns it.
|
||||
func ValidateHost(val string) (string, error) {
|
||||
host := strings.TrimSpace(val)
|
||||
// The empty string means default and is not handled by parseDockerDaemonHost
|
||||
// The empty string means default and is not handled by parseDaemonHost
|
||||
if host != "" {
|
||||
_, err := parseDockerDaemonHost(host)
|
||||
_, err := parseDaemonHost(host)
|
||||
if err != nil {
|
||||
return val, err
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ func ParseHost(defaultToTLS bool, val string) (string, error) {
|
|||
}
|
||||
} else {
|
||||
var err error
|
||||
host, err = parseDockerDaemonHost(host)
|
||||
host, err = parseDaemonHost(host)
|
||||
if err != nil {
|
||||
return val, err
|
||||
}
|
||||
|
@ -60,9 +60,9 @@ func ParseHost(defaultToTLS bool, val string) (string, error) {
|
|||
return host, nil
|
||||
}
|
||||
|
||||
// parseDockerDaemonHost parses the specified address and returns an address that will be used as the host.
|
||||
// parseDaemonHost parses the specified address and returns an address that will be used as the host.
|
||||
// Depending of the address specified, this may return one of the global Default* strings defined in hosts.go.
|
||||
func parseDockerDaemonHost(addr string) (string, error) {
|
||||
func parseDaemonHost(addr string) (string, error) {
|
||||
addrParts := strings.SplitN(addr, "://", 2)
|
||||
if len(addrParts) == 1 && addrParts[0] != "" {
|
||||
addrParts = []string{"tcp", addrParts[0]}
|
||||
|
|
|
@ -83,12 +83,12 @@ func TestParseDockerDaemonHost(t *testing.T) {
|
|||
"localhost:5555/path": "tcp://localhost:5555/path",
|
||||
}
|
||||
for invalidAddr, expectedError := range invalids {
|
||||
if addr, err := parseDockerDaemonHost(invalidAddr); err == nil || err.Error() != expectedError {
|
||||
if addr, err := parseDaemonHost(invalidAddr); err == nil || err.Error() != expectedError {
|
||||
t.Errorf("tcp %v address expected error %q return, got %q and addr %v", invalidAddr, expectedError, err, addr)
|
||||
}
|
||||
}
|
||||
for validAddr, expectedAddr := range valids {
|
||||
if addr, err := parseDockerDaemonHost(validAddr); err != nil || addr != expectedAddr {
|
||||
if addr, err := parseDaemonHost(validAddr); err != nil || addr != expectedAddr {
|
||||
t.Errorf("%v -> expected %v, got (%v) addr (%v)", validAddr, expectedAddr, err, addr)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ func (err fallbackError) Error() string {
|
|||
func loginV2(authConfig *types.AuthConfig, endpoint APIEndpoint, userAgent string) (string, string, error) {
|
||||
logrus.Debugf("attempting v2 login to registry endpoint %s", strings.TrimRight(endpoint.URL.String(), "/")+"/v2/")
|
||||
|
||||
modifiers := DockerHeaders(userAgent, nil)
|
||||
modifiers := Headers(userAgent, nil)
|
||||
authTransport := transport.NewTransport(NewTransport(endpoint.TLSConfig), modifiers...)
|
||||
|
||||
credentialAuthConfig := *authConfig
|
||||
|
|
|
@ -77,7 +77,7 @@ func newV1Endpoint(address url.URL, tlsConfig *tls.Config, userAgent string, met
|
|||
|
||||
// TODO(tiborvass): make sure a ConnectTimeout transport is used
|
||||
tr := NewTransport(tlsConfig)
|
||||
endpoint.client = HTTPClient(transport.NewTransport(tr, DockerHeaders(userAgent, metaHeaders)...))
|
||||
endpoint.client = HTTPClient(transport.NewTransport(tr, Headers(userAgent, metaHeaders)...))
|
||||
return endpoint
|
||||
}
|
||||
|
||||
|
|
|
@ -102,8 +102,8 @@ func ReadCertsDirectory(tlsConfig *tls.Config, directory string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// DockerHeaders returns request modifiers with a User-Agent and metaHeaders
|
||||
func DockerHeaders(userAgent string, metaHeaders http.Header) []transport.RequestModifier {
|
||||
// Headers returns request modifiers with a User-Agent and metaHeaders
|
||||
func Headers(userAgent string, metaHeaders http.Header) []transport.RequestModifier {
|
||||
modifiers := []transport.RequestModifier{}
|
||||
if userAgent != "" {
|
||||
modifiers = append(modifiers, transport.NewHeaderRequestModifier(http.Header{
|
||||
|
|
|
@ -34,7 +34,7 @@ func spawnTestRegistrySession(t *testing.T) *Session {
|
|||
}
|
||||
userAgent := "docker test client"
|
||||
var tr http.RoundTripper = debugTransport{NewTransport(nil), t.Log}
|
||||
tr = transport.NewTransport(AuthTransport(tr, authConfig, false), DockerHeaders(userAgent, nil)...)
|
||||
tr = transport.NewTransport(AuthTransport(tr, authConfig, false), Headers(userAgent, nil)...)
|
||||
client := HTTPClient(tr)
|
||||
r, err := NewSession(client, authConfig, endpoint)
|
||||
if err != nil {
|
||||
|
|
|
@ -199,7 +199,7 @@ func (s *DefaultService) Search(ctx context.Context, term string, limit int, aut
|
|||
},
|
||||
}
|
||||
|
||||
modifiers := DockerHeaders(userAgent, nil)
|
||||
modifiers := Headers(userAgent, nil)
|
||||
v2Client, foundV2, err := v2AuthHTTPClient(endpoint.URL, endpoint.client.Transport, modifiers, creds, scopes)
|
||||
if err != nil {
|
||||
if fErr, ok := err.(fallbackError); ok {
|
||||
|
|
Loading…
Reference in a new issue