(ctx context.Context, ref reference.Named, repoEndpoint repositoryEndpoint)
| 120 | } |
| 121 | |
| 122 | func (c *client) getRepositoryForReference(ctx context.Context, ref reference.Named, repoEndpoint repositoryEndpoint) (distribution.Repository, error) { |
| 123 | repoName, err := reference.WithName(repoEndpoint.repoName) |
| 124 | if err != nil { |
| 125 | return nil, fmt.Errorf("failed to parse repo name from %s: %w", ref, err) |
| 126 | } |
| 127 | httpTransport, err := c.getHTTPTransportForRepoEndpoint(ctx, repoEndpoint) |
| 128 | if err != nil { |
| 129 | if !strings.Contains(err.Error(), "server gave HTTP response to HTTPS client") { |
| 130 | return nil, err |
| 131 | } |
| 132 | if !repoEndpoint.endpoint.TLSConfig.InsecureSkipVerify { |
| 133 | return nil, httpProtoError{cause: err} |
| 134 | } |
| 135 | // --insecure was set; fall back to plain HTTP |
| 136 | if url := repoEndpoint.endpoint.URL; url != nil && url.Scheme == "https" { |
| 137 | url.Scheme = "http" |
| 138 | httpTransport, err = c.getHTTPTransportForRepoEndpoint(ctx, repoEndpoint) |
| 139 | if err != nil { |
| 140 | return nil, err |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | return distributionclient.NewRepository(repoName, repoEndpoint.BaseURL(), httpTransport) |
| 145 | } |
| 146 | |
| 147 | func (c *client) getHTTPTransportForRepoEndpoint(ctx context.Context, repoEndpoint repositoryEndpoint) (http.RoundTripper, error) { |
| 148 | httpTransport, err := getHTTPTransport( |
no test coverage detected