forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cdrom_settings_source.go
55 lines (42 loc) · 1.24 KB
/
cdrom_settings_source.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package infrastructure
import (
"encoding/json"
boshplatform "github.com/cloudfoundry/bosh-agent/platform"
boshsettings "github.com/cloudfoundry/bosh-agent/settings"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
)
type CDROMSettingsSource struct {
settingsFileName string
platform boshplatform.Platform
logTag string
logger boshlog.Logger
}
func NewCDROMSettingsSource(
settingsFileName string,
platform boshplatform.Platform,
logger boshlog.Logger,
) *CDROMSettingsSource {
return &CDROMSettingsSource{
settingsFileName: settingsFileName,
platform: platform,
logTag: "CDROMSettingsSource",
logger: logger,
}
}
func (s CDROMSettingsSource) PublicSSHKeyForUsername(string) (string, error) {
return "", nil
}
func (s *CDROMSettingsSource) Settings() (boshsettings.Settings, error) {
var settings boshsettings.Settings
contents, err := s.platform.GetFileContentsFromCDROM(s.settingsFileName)
if err != nil {
return settings, bosherr.WrapError(err, "Reading files from CDROM")
}
err = json.Unmarshal(contents, &settings)
if err != nil {
return settings, bosherr.WrapErrorf(
err, "Parsing CDROM settings from '%s'", s.settingsFileName)
}
return settings, nil
}