-
Notifications
You must be signed in to change notification settings - Fork 3
/
buildspec.go
39 lines (34 loc) · 1.47 KB
/
buildspec.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
package main
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
// BuildSpec holds the configuration for the current build.
type BuildSpec struct {
BaseImg string `yaml:"baseimg"`
ImgAliases []string `yaml:"image_aliases,omitempty"`
ImgProperties map[string]string `yaml:"image_properties,omitempty"`
Public bool `yaml:"public,omitempty"`
BuildProfiles []string `yaml:"build_profiles,omitempty"`
BuildNetworks []string `yaml:"build_networks,omitempty"`
BuildConfig map[string]string `yaml:"build_config,omitempty"`
CompressionAlgo string `yaml:"compression,omitempty"`
Devices map[string]map[string]string `yaml:"devices,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Cmd []string `yaml:"cmd,omitempty"`
Files []string `yaml:"files,omitempty"`
Templates []string `yaml:"templates,omitempty"`
}
// LoadBuildSpec takes a string argument that is either a path to a YML file
// or the raw YML itself and returns a BuildSpec
func LoadBuildSpec(yml string) *BuildSpec {
b := new(BuildSpec)
contents := []byte(yml)
if fileExists(yml) {
contents = asrt(ioutil.ReadFile(yml)).([]byte)
}
if err := yaml.Unmarshal(contents, b); err != nil {
panic("Failed to parse LXfile")
}
return b
}