Recently added stages org.osbuild.sysconfig and org.osbuild.kernel-cmdline were missing from the Manifest unmarshal method causing it to fail when trying to unmarshal manifests that contained them.
43 lines
990 B
Go
43 lines
990 B
Go
package osbuild1
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
)
|
|
|
|
// A Sources map contains all the sources made available to an osbuild run
|
|
type Sources map[string]Source
|
|
|
|
// Source specifies the operations of a given source-type.
|
|
type Source interface {
|
|
isSource()
|
|
}
|
|
|
|
type rawSources map[string]json.RawMessage
|
|
|
|
// UnmarshalJSON unmarshals JSON into a Source object. Each type of source has
|
|
// a custom unmarshaller for its options, selected based on the source name.
|
|
func (sources *Sources) UnmarshalJSON(data []byte) error {
|
|
var rawSources rawSources
|
|
err := json.Unmarshal(data, &rawSources)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
*sources = make(map[string]Source)
|
|
for name, rawSource := range rawSources {
|
|
var source Source
|
|
switch name {
|
|
case "org.osbuild.files":
|
|
source = new(FilesSource)
|
|
default:
|
|
return errors.New("unexpected source name: " + name)
|
|
}
|
|
err = json.Unmarshal(rawSource, source)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
(*sources)[name] = source
|
|
}
|
|
|
|
return nil
|
|
}
|