package Package
|
|
|
|
import (
|
|
yaml "gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type Manifest struct {
|
|
Name string `yaml:"name"`
|
|
Version string `yaml:"version"`
|
|
Symlinks map[string]string `yaml:"symlinks,flow"`
|
|
Dependancies map[string]string `yaml:"dependancies,flow"`
|
|
PreInstallCmds []string `yaml:"pre_install_cmds"`
|
|
PostInstallCmds []string `yaml:"post_install_cmds"`
|
|
}
|
|
|
|
func ParseManifestFile(manifest string) (Manifest, error) {
|
|
var (
|
|
m Manifest = Manifest{}
|
|
e error
|
|
)
|
|
|
|
e = yaml.Unmarshal([]byte(manifest), &m)
|
|
return m, e
|
|
}
|
|
|
|
func (m Manifest) CreateManifestString() (string, error) {
|
|
var (
|
|
mByte []byte
|
|
e error
|
|
)
|
|
mByte, e = yaml.Marshal(&m)
|
|
if e != nil {
|
|
return "", e
|
|
}
|
|
return string(mByte), e
|
|
}
|