Skip to content

Commit

Permalink
Merge pull request ciao-project#216 from 01org/sameo/topic/configuration
Browse files Browse the repository at this point in the history
configuration: Consistency fixes
  • Loading branch information
Samuel Ortiz committed Jun 7, 2016
2 parents 5139cfe + 5412772 commit 3fe9832
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
21 changes: 10 additions & 11 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ func discoverDriver(uriStr string) (storageType payloads.StorageType, err error)

// Payload fills the payloads.Configure struct passed in 'conf'
// with the values from the bytes given
func Payload(yamlConf []byte, conf *payloads.Configure) (err error) {
if yamlConf == nil {
return fmt.Errorf("Unable to retrieve configuration from empty definition")
func Payload(blob []byte) (conf payloads.Configure, err error) {
if blob == nil {
return conf, fmt.Errorf("Unable to retrieve configuration from empty definition")
}
err = yaml.Unmarshal(yamlConf, &conf)
if err != nil {
return err
}
return nil
fillDefaults(&conf)
err = yaml.Unmarshal(blob, &conf)

return conf, err
}

// Blob returns an array of bytes containing
Expand All @@ -100,7 +99,7 @@ func Blob(conf *payloads.Configure) (blob []byte, err error) {

// ExtractBlob returns a configuration payload.
// It could be used by the SSNTP server or some other entity.
func ExtractBlob(uri string) (payload []byte, err error) {
func ExtractBlob(uri string) (blob []byte, err error) {
var d driver
driverType, err := discoverDriver(uri)
if err != nil {
Expand All @@ -116,9 +115,9 @@ func ExtractBlob(uri string) (payload []byte, err error) {
if err != nil {
return nil, err
}
payload, err = Blob(&conf)
blob, err = Blob(&conf)
if err != nil {
return nil, err
}
return payload, nil
return blob, nil
}
3 changes: 1 addition & 2 deletions configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ func fillPayload(conf *payloads.Configure) {
}

func testPayload(t *testing.T, blob []byte, expectedConf payloads.Configure, positive bool) {
var conf payloads.Configure
err := Payload(blob, &conf)
conf, err := Payload(blob)

// expected FAIL
if positive == false && err == nil {
Expand Down
4 changes: 2 additions & 2 deletions configuration/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func (f *file) fetchConfiguration(uriStr string) (conf payloads.Configure, err e
if err != nil {
return conf, err
}
fillDefaults(&conf)
err = Payload(yamlConf, &conf)

conf, err = Payload(yamlConf)
if err != nil {
return conf, err
}
Expand Down

0 comments on commit 3fe9832

Please sign in to comment.