2016-12-21 14:35:34 +02:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
yaml "gopkg.in/yaml.v1"
|
|
|
|
)
|
|
|
|
|
2016-12-30 16:41:59 +02:00
|
|
|
// Homebrew contains the brew section
|
|
|
|
type Homebrew struct {
|
2016-12-29 17:14:52 +02:00
|
|
|
Repo string
|
2017-01-14 15:18:48 +02:00
|
|
|
Folder string
|
2016-12-29 17:14:52 +02:00
|
|
|
Caveats string
|
2016-12-21 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2016-12-30 16:41:59 +02:00
|
|
|
// BuildConfig contains the build configuration section
|
2016-12-21 15:37:31 +02:00
|
|
|
type BuildConfig struct {
|
2017-01-12 00:25:52 +02:00
|
|
|
Oses []string
|
|
|
|
Arches []string
|
|
|
|
Main string
|
|
|
|
Ldflags string
|
2016-12-21 15:37:31 +02:00
|
|
|
}
|
|
|
|
|
2017-01-14 18:06:57 +02:00
|
|
|
// ArchiveConfig config used for the archive
|
|
|
|
type ArchiveConfig struct {
|
|
|
|
Format string
|
|
|
|
NameTemplate string `yaml:"name_template"`
|
|
|
|
Replacements map[string]string
|
|
|
|
}
|
|
|
|
|
2016-12-30 16:41:59 +02:00
|
|
|
// ProjectConfig includes all project configuration
|
2016-12-21 14:35:34 +02:00
|
|
|
type ProjectConfig struct {
|
2017-01-11 18:47:56 +02:00
|
|
|
Repo string
|
|
|
|
BinaryName string `yaml:"binary_name"`
|
|
|
|
Files []string
|
|
|
|
Brew Homebrew
|
|
|
|
Build BuildConfig
|
|
|
|
Archive ArchiveConfig
|
2016-12-21 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2016-12-30 16:41:59 +02:00
|
|
|
// Load config file
|
2016-12-21 14: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 16:34:22 +02:00
|
|
|
err = yaml.Unmarshal(data, &config)
|
2016-12-31 12:53:48 +02:00
|
|
|
return
|
|
|
|
}
|