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

Function dockerCertDir

docker/docker_client.go:149–184  ·  view source on GitHub ↗

dockerCertDir returns a path to a directory to be consumed by tlsclientconfig.SetupCertificates() depending on ctx and hostPort.

(sys *types.SystemContext, hostPort string)

Source from the content-addressed store, hash-verified

147
148// dockerCertDir returns a path to a directory to be consumed by tlsclientconfig.SetupCertificates() depending on ctx and hostPort.
149func dockerCertDir(sys *types.SystemContext, hostPort string) (string, error) {
150 if sys != nil && sys.DockerCertPath != "" {
151 return sys.DockerCertPath, nil
152 }
153 if sys != nil && sys.DockerPerHostCertDirPath != "" {
154 return filepath.Join(sys.DockerPerHostCertDirPath, hostPort), nil
155 }
156
157 var (
158 hostCertDir string
159 fullCertDirPath string
160 )
161
162 for _, perHostCertDir := range append([]certPath{{path: filepath.Join(homedir.Get(), homeCertDir), absolute: false}}, perHostCertDirs...) {
163 if sys != nil && sys.RootForImplicitAbsolutePaths != "" && perHostCertDir.absolute {
164 hostCertDir = filepath.Join(sys.RootForImplicitAbsolutePaths, perHostCertDir.path)
165 } else {
166 hostCertDir = perHostCertDir.path
167 }
168
169 fullCertDirPath = filepath.Join(hostCertDir, hostPort)
170 err := fileutils.Exists(fullCertDirPath)
171 if err == nil {
172 break
173 }
174 if os.IsNotExist(err) {
175 continue
176 }
177 if os.IsPermission(err) {
178 logrus.Debugf("error accessing certs directory due to permissions: %v", err)
179 continue
180 }
181 return "", err
182 }
183 return fullCertDirPath, nil
184}
185
186// newDockerClientFromRef returns a new dockerClient instance for refHostname (a host a specified in the Docker image reference, not canonicalized to dockerRegistry)
187// “write” specifies whether the client will be used for "write" access (in particular passed to lookaside.go:toplevelFromSection)

Callers 2

newDockerClientFunction · 0.85
TestDockerCertDirFunction · 0.85

Calls 1

GetMethod · 0.80

Tested by 1

TestDockerCertDirFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…