40 lines
897 B
Go
40 lines
897 B
Go
package app
|
|
|
|
import (
|
|
"forge.cadoles.com/arcad/edge/pkg/bundle"
|
|
"github.com/pkg/errors"
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type ID string
|
|
|
|
type Manifest struct {
|
|
ID ID `yaml:"id" json:"id"`
|
|
Version string `yaml:"version" json:"version"`
|
|
Title string `yaml:"title" json:"title"`
|
|
Description string `yaml:"description" json:"description"`
|
|
Tags []string `yaml:"tags" json:"tags"`
|
|
}
|
|
|
|
func LoadManifest(b bundle.Bundle) (*Manifest, error) {
|
|
reader, _, err := b.File("manifest.yml")
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "could not read manifest.yml")
|
|
}
|
|
|
|
defer func() {
|
|
if err := reader.Close(); err != nil {
|
|
panic(errors.WithStack(err))
|
|
}
|
|
}()
|
|
|
|
manifest := &Manifest{}
|
|
|
|
decoder := yaml.NewDecoder(reader)
|
|
if err := decoder.Decode(manifest); err != nil {
|
|
return nil, errors.Wrap(err, "could not decode manifest.yml")
|
|
}
|
|
|
|
return manifest, nil
|
|
}
|