2016-12-21 10:35:34 -02:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
yaml "gopkg.in/yaml.v1"
|
|
|
|
)
|
|
|
|
|
2016-12-30 12:41:59 -02:00
|
|
|
// Homebrew contains the brew section
|
|
|
|
type Homebrew struct {
|
2016-12-29 13:14:52 -02:00
|
|
|
Repo string
|
2017-01-14 11:18:48 -02:00
|
|
|
Folder string
|
2016-12-29 13:14:52 -02:00
|
|
|
Caveats string
|
2016-12-21 10:35:34 -02:00
|
|
|
}
|
|
|
|
|
2016-12-30 12:41:59 -02:00
|
|
|
// BuildConfig contains the build configuration section
|
2016-12-21 11:37:31 -02:00
|
|
|
type BuildConfig struct {
|
2017-01-11 20:25:52 -02:00
|
|
|
Oses []string
|
|
|
|
Arches []string
|
|
|
|
Main string
|
|
|
|
Ldflags string
|
2016-12-21 11:37:31 -02:00
|
|
|
}
|
|
|
|
|
2016-12-30 12:41:59 -02:00
|
|
|
// ProjectConfig includes all project configuration
|
2016-12-21 10:35:34 -02:00
|
|
|
type ProjectConfig struct {
|
2017-01-11 14:47:56 -02:00
|
|
|
Repo string
|
|
|
|
BinaryName string `yaml:"binary_name"`
|
|
|
|
Files []string
|
|
|
|
Brew Homebrew
|
|
|
|
Build BuildConfig
|
|
|
|
Archive ArchiveConfig
|
2016-12-21 10:35:34 -02:00
|
|
|
}
|
|
|
|
|
2016-12-30 12:41:59 -02:00
|
|
|
// Load config file
|
2016-12-21 10:35:34 -02:00
|
|
|
func Load(file string) (config ProjectConfig, err error) {
|
|
|
|
data, err := ioutil.ReadFile(file)
|
|
|
|
if err != nil {
|
|
|
|
return config, err
|
|
|
|
}
|
2017-01-14 12:34:22 -02:00
|
|
|
err = yaml.Unmarshal(data, &config)
|
2016-12-31 10:53:48 +00:00
|
|
|
return
|
|
|
|
}
|