MCPcopy
hub / github.com/moby/moby / readCredentialSpecFile

Function readCredentialSpecFile

daemon/oci_windows.go:518–532  ·  view source on GitHub ↗

readCredentialSpecFile is a helper function to read a credential spec from a file. If not found, we return an empty string and warn in the log. This allows for staging on machines which do not have the necessary components.

(id, root, location string)

Source from the content-addressed store, hash-verified

516// a file. If not found, we return an empty string and warn in the log.
517// This allows for staging on machines which do not have the necessary components.
518func readCredentialSpecFile(id, root, location string) (string, error) {
519 if filepath.IsAbs(location) {
520 return "", fmt.Errorf("invalid credential spec: file:// path cannot be absolute")
521 }
522 base := filepath.Join(root, credentialSpecFileLocation)
523 full := filepath.Join(base, location)
524 if !strings.HasPrefix(full, base) {
525 return "", fmt.Errorf("invalid credential spec: file:// path must be under %s", base)
526 }
527 bcontents, err := os.ReadFile(full)
528 if err != nil {
529 return "", errors.Wrapf(err, "failed to load credential spec for container %s", id)
530 }
531 return string(bcontents[:]), nil
532}
533
534func setupWindowsDevices(devices []containertypes.DeviceMapping) ([]specs.WindowsDevice, error) {
535 var specDevices []specs.WindowsDevice

Callers 1

Calls 2

ErrorfMethod · 0.80
JoinMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…