MCPcopy Create free account
hub / github.com/containers/image / newDockerClientFromRef

Function newDockerClientFromRef

docker/docker_client.go:190–216  ·  view source on GitHub ↗

newDockerClientFromRef returns a new dockerClient instance for refHostname (a host a specified in the Docker image reference, not canonicalized to dockerRegistry) “write” specifies whether the client will be used for "write" access (in particular passed to lookaside.go:toplevelFromSection) signature

(sys *types.SystemContext, ref dockerReference, registryConfig *registryConfiguration, write bool, actions string)

Source from the content-addressed store, hash-verified

188// signatureBase is always set in the return value
189// The caller must call .Close() on the returned client when done.
190func newDockerClientFromRef(sys *types.SystemContext, ref dockerReference, registryConfig *registryConfiguration, write bool, actions string) (*dockerClient, error) {
191 auth, err := config.GetCredentialsForRef(sys, ref.ref)
192 if err != nil {
193 return nil, fmt.Errorf("getting username and password: %w", err)
194 }
195
196 sigBase, err := registryConfig.lookasideStorageBaseURL(ref, write)
197 if err != nil {
198 return nil, err
199 }
200
201 registry := reference.Domain(ref.ref)
202 client, err := newDockerClient(sys, registry, ref.ref.Name())
203 if err != nil {
204 return nil, err
205 }
206 client.auth = auth
207 if sys != nil {
208 client.registryToken = sys.DockerBearerRegistryToken
209 }
210 client.signatureBase = sigBase
211 client.useSigstoreAttachments = registryConfig.useSigstoreAttachments(ref)
212 client.scope.resourceType = "repository"
213 client.scope.actions = actions
214 client.scope.remoteName = reference.Path(ref.ref)
215 return client, nil
216}
217
218// newDockerClient returns a new dockerClient instance for the given registry
219// and reference. The reference is used to query the registry configuration

Callers 5

newImageDestinationFunction · 0.85
newImageSourceAttemptFunction · 0.85
deleteImageFunction · 0.85
GetRepositoryTagsFunction · 0.85
GetDigestFunction · 0.85

Calls 7

GetCredentialsForRefFunction · 0.92
DomainFunction · 0.92
PathFunction · 0.92
newDockerClientFunction · 0.70
NameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…