-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
46 lines (40 loc) · 1.38 KB
/
config.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
40
41
42
43
44
45
46
package linux_installer
import (
"log"
"gopkg.in/yaml.v2"
)
const configFilename = "config.yml"
// Config holds a list of variables to be expanded in message strings, as well other
// settings for the installer.
//
// Setting MustAcceptLicenseOnCli to true (the default) enables & requires the -accept
// flag.
//
// DefaultInstallDirName is a string or template for the default application directory,
// into which to install.
//
// NoLauncher is a flag from the command line that suppresses launcher shortcut
// creation.
//
// RunInstalled is a flag from the command line that runs the installed application
// after installation completes successfully.
type Config struct {
Variables VariableMap `yaml:"variables,omitempty"`
MustAcceptLicense bool `yaml:"must_accept_license"`
DefaultInstallDirName string `yaml:"default_install_dir_name"`
GuiCss string `yaml:"gui_css,omitempty"`
// commandline config options
NoLauncher bool
RunInstalled bool
}
// NewConfig returns a Config object containing the settings from resources/config.yml.
func NewConfig() (*Config, error) {
configFile := MustGetResource(configFilename)
config := &Config{Variables: make(VariableMap)}
err := yaml.Unmarshal([]byte(configFile), config)
if err != nil {
log.Printf("Unable to parse config file %s\n", configFilename)
return config, err
}
return config, err
}