MCPcopy Create free account
hub / github.com/cloudfoundry/bosh-agent / GetFilesContents

Method GetFilesContents

platform/cdrom/cdutil.go:36–79  ·  view source on GitHub ↗
(fileNames []string)

Source from the content-addressed store, hash-verified

34}
35
36func (util cdUtil) GetFilesContents(fileNames []string) ([][]byte, error) {
37 err := util.cdrom.WaitForMedia()
38 if err != nil {
39 return [][]byte{}, bosherr.WrapError(err, "Waiting for CDROM to be ready")
40 }
41
42 util.logger.Debug(util.logTag, "Mkdiring %s", util.settingsMountPath)
43 err = util.fs.MkdirAll(util.settingsMountPath, os.FileMode(0700))
44 if err != nil {
45 return [][]byte{}, bosherr.WrapError(err, "Creating CDROM mount point")
46 }
47
48 util.logger.Debug(util.logTag, "Mounting %s", util.settingsMountPath)
49 err = util.cdrom.Mount(util.settingsMountPath)
50 if err != nil {
51 return [][]byte{}, bosherr.WrapError(err, "Mounting CDROM")
52 }
53
54 contents := [][]byte{}
55 for _, fileName := range fileNames {
56 settingsPath := filepath.Join(util.settingsMountPath, fileName)
57 util.logger.Debug(util.logTag, "Reading %s", settingsPath)
58 stringContents, err := util.fs.ReadFile(settingsPath)
59 if err != nil {
60 return [][]byte{}, bosherr.WrapError(err, "Reading from CDROM")
61 }
62
63 contents = append(contents, stringContents)
64 }
65
66 util.logger.Debug(util.logTag, "Umounting CDROM")
67 err = util.cdrom.Unmount()
68 if err != nil {
69 return [][]byte{}, bosherr.WrapError(err, "Unmounting CDROM")
70 }
71
72 util.logger.Debug(util.logTag, "Ejecting CDROM")
73 err = util.cdrom.Eject()
74 if err != nil {
75 return [][]byte{}, bosherr.WrapError(err, "Ejecting CDROM")
76 }
77
78 return contents, nil
79}
80
81func (util cdUtil) GetBlockDeviceSize() (size uint64, err error) {
82 return 0, errors.New("not supported")

Callers

nothing calls this directly

Calls 6

MkdirAllMethod · 0.80
WaitForMediaMethod · 0.65
DebugMethod · 0.65
MountMethod · 0.65
UnmountMethod · 0.65
EjectMethod · 0.65

Tested by

no test coverage detected