2015-03-15 04:27:04 +00:00
|
|
|
package config
|
|
|
|
|
2015-07-29 06:52:15 +00:00
|
|
|
import (
|
2016-05-24 00:21:28 +00:00
|
|
|
"runtime"
|
|
|
|
|
2015-07-29 06:52:15 +00:00
|
|
|
"github.com/coreos/coreos-cloudinit/config"
|
2016-05-27 23:09:03 +00:00
|
|
|
"github.com/docker/engine-api/types"
|
2016-05-24 00:21:28 +00:00
|
|
|
composeConfig "github.com/docker/libcompose/config"
|
2015-07-29 07:45:06 +00:00
|
|
|
"github.com/rancher/netconf"
|
2015-07-29 06:52:15 +00:00
|
|
|
)
|
2015-03-29 09:57:15 +00:00
|
|
|
|
2015-03-15 04:27:04 +00:00
|
|
|
const (
|
2015-12-20 05:26:09 +00:00
|
|
|
OEM = "/usr/share/ros/oem"
|
2015-07-13 14:14:24 +00:00
|
|
|
DOCKER_BIN = "/usr/bin/docker"
|
2015-11-05 08:51:05 +00:00
|
|
|
DOCKER_DIST_BIN = "/usr/bin/docker.dist"
|
2015-07-29 07:51:49 +00:00
|
|
|
ROS_BIN = "/usr/bin/ros"
|
|
|
|
SYSINIT_BIN = "/usr/bin/ros-sysinit"
|
2015-07-13 14:14:24 +00:00
|
|
|
DOCKER_SYSTEM_HOME = "/var/lib/system-docker"
|
|
|
|
DOCKER_SYSTEM_HOST = "unix:///var/run/system-docker.sock"
|
|
|
|
DOCKER_HOST = "unix:///var/run/docker.sock"
|
2015-07-29 07:51:49 +00:00
|
|
|
IMAGES_PATH = "/usr/share/ros"
|
2015-07-13 14:14:24 +00:00
|
|
|
IMAGES_PATTERN = "images*.tar"
|
|
|
|
MODULES_ARCHIVE = "/modules.tar"
|
|
|
|
DEBUG = false
|
2015-07-29 07:51:49 +00:00
|
|
|
SYSTEM_DOCKER_LOG = "/var/log/system-docker.log"
|
2016-06-01 04:38:10 +00:00
|
|
|
SYSTEM_DOCKER_BIN = "/usr/bin/system-docker"
|
2015-03-29 09:57:15 +00:00
|
|
|
|
|
|
|
LABEL = "label"
|
|
|
|
HASH = "io.rancher.os.hash"
|
|
|
|
ID = "io.rancher.os.id"
|
|
|
|
DETACH = "io.rancher.os.detach"
|
|
|
|
CREATE_ONLY = "io.rancher.os.createonly"
|
|
|
|
RELOAD_CONFIG = "io.rancher.os.reloadconfig"
|
2015-04-16 05:57:59 +00:00
|
|
|
SCOPE = "io.rancher.os.scope"
|
2015-11-26 12:41:42 +00:00
|
|
|
REBUILD = "io.docker.compose.rebuild"
|
2015-04-16 05:57:59 +00:00
|
|
|
SYSTEM = "system"
|
2015-07-29 06:52:15 +00:00
|
|
|
|
2015-09-23 11:36:28 +00:00
|
|
|
OsConfigFile = "/usr/share/ros/os-config.yml"
|
|
|
|
CloudConfigDir = "/var/lib/rancher/conf/cloud-config.d"
|
|
|
|
CloudConfigBootFile = "/var/lib/rancher/conf/cloud-config.d/boot.yml"
|
2015-12-20 05:37:57 +00:00
|
|
|
CloudConfigNetworkFile = "/var/lib/rancher/conf/cloud-config.d/network.yml"
|
2015-09-23 11:36:28 +00:00
|
|
|
CloudConfigScriptFile = "/var/lib/rancher/conf/cloud-config-script"
|
|
|
|
MetaDataFile = "/var/lib/rancher/conf/metadata"
|
|
|
|
CloudConfigFile = "/var/lib/rancher/conf/cloud-config.yml"
|
2015-03-15 04:27:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2015-12-20 05:26:09 +00:00
|
|
|
OemConfigFile = OEM + "/oem-config.yml"
|
|
|
|
VERSION string
|
2016-03-28 20:50:29 +00:00
|
|
|
ARCH string
|
|
|
|
SUFFIX string
|
2016-05-31 21:34:04 +00:00
|
|
|
PrivateKeys = []string{
|
|
|
|
"rancher.ssh",
|
|
|
|
"rancher.docker.ca_key",
|
|
|
|
"rancher.docker.ca_cert",
|
|
|
|
"rancher.docker.server_key",
|
|
|
|
"rancher.docker.server_cert",
|
|
|
|
}
|
2015-03-15 04:27:04 +00:00
|
|
|
)
|
|
|
|
|
2015-09-23 11:36:28 +00:00
|
|
|
func init() {
|
|
|
|
if VERSION == "" {
|
|
|
|
VERSION = "v0.0.0-dev"
|
|
|
|
}
|
2016-03-28 20:50:29 +00:00
|
|
|
if ARCH == "" {
|
|
|
|
ARCH = runtime.GOARCH
|
|
|
|
}
|
|
|
|
if SUFFIX == "" && ARCH != "amd64" {
|
|
|
|
SUFFIX = "_" + ARCH
|
|
|
|
}
|
2015-09-23 11:36:28 +00:00
|
|
|
}
|
|
|
|
|
2015-04-16 05:57:59 +00:00
|
|
|
type Repository struct {
|
2015-10-31 15:54:56 +00:00
|
|
|
Url string `yaml:"url,omitempty"`
|
2015-04-16 05:57:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Repositories map[string]Repository
|
|
|
|
|
2015-07-29 06:52:15 +00:00
|
|
|
type CloudConfig struct {
|
|
|
|
SSHAuthorizedKeys []string `yaml:"ssh_authorized_keys"`
|
|
|
|
WriteFiles []config.File `yaml:"write_files"`
|
|
|
|
Hostname string `yaml:"hostname"`
|
|
|
|
|
|
|
|
Rancher RancherConfig `yaml:"rancher,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type RancherConfig struct {
|
2016-06-06 22:13:15 +00:00
|
|
|
Console string `yaml:"console,omitempty"`
|
2016-05-24 00:21:28 +00:00
|
|
|
Environment map[string]string `yaml:"environment,omitempty"`
|
|
|
|
Services map[string]*composeConfig.ServiceConfigV1 `yaml:"services,omitempty"`
|
|
|
|
BootstrapContainers map[string]*composeConfig.ServiceConfigV1 `yaml:"bootstrap,omitempty"`
|
|
|
|
Autoformat map[string]*composeConfig.ServiceConfigV1 `yaml:"autoformat,omitempty"`
|
|
|
|
BootstrapDocker DockerConfig `yaml:"bootstrap_docker,omitempty"`
|
|
|
|
CloudInit CloudInit `yaml:"cloud_init,omitempty"`
|
|
|
|
Debug bool `yaml:"debug,omitempty"`
|
|
|
|
RmUsr bool `yaml:"rm_usr,omitempty"`
|
|
|
|
Log bool `yaml:"log,omitempty"`
|
|
|
|
ForceConsoleRebuild bool `yaml:"force_console_rebuild,omitempty"`
|
|
|
|
Disable []string `yaml:"disable,omitempty"`
|
|
|
|
ServicesInclude map[string]bool `yaml:"services_include,omitempty"`
|
|
|
|
Modules []string `yaml:"modules,omitempty"`
|
|
|
|
Network netconf.NetworkConfig `yaml:"network,omitempty"`
|
|
|
|
DefaultNetwork netconf.NetworkConfig `yaml:"default_network,omitempty"`
|
|
|
|
Repositories Repositories `yaml:"repositories,omitempty"`
|
|
|
|
Ssh SshConfig `yaml:"ssh,omitempty"`
|
|
|
|
State StateConfig `yaml:"state,omitempty"`
|
|
|
|
SystemDocker DockerConfig `yaml:"system_docker,omitempty"`
|
|
|
|
Upgrade UpgradeConfig `yaml:"upgrade,omitempty"`
|
|
|
|
Docker DockerConfig `yaml:"docker,omitempty"`
|
2016-05-27 23:09:03 +00:00
|
|
|
RegistryAuths map[string]types.AuthConfig `yaml:"registry_auths,omitempty"`
|
2016-05-03 15:55:15 +00:00
|
|
|
Defaults Defaults `yaml:"defaults,omitempty"`
|
2015-03-15 05:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-03-15 04:27:04 +00:00
|
|
|
type UpgradeConfig struct {
|
2015-03-19 21:57:53 +00:00
|
|
|
Url string `yaml:"url,omitempty"`
|
|
|
|
Image string `yaml:"image,omitempty"`
|
|
|
|
Rollback string `yaml:"rollback,omitempty"`
|
2015-03-15 04:27:04 +00:00
|
|
|
}
|
|
|
|
|
2015-03-18 13:23:27 +00:00
|
|
|
type DockerConfig struct {
|
2015-08-27 19:24:26 +00:00
|
|
|
TLS bool `yaml:"tls,omitempty"`
|
|
|
|
TLSArgs []string `yaml:"tls_args,flow,omitempty"`
|
|
|
|
Args []string `yaml:"args,flow,omitempty"`
|
|
|
|
ExtraArgs []string `yaml:"extra_args,flow,omitempty"`
|
|
|
|
ServerCert string `yaml:"server_cert,omitempty"`
|
|
|
|
ServerKey string `yaml:"server_key,omitempty"`
|
|
|
|
CACert string `yaml:"ca_cert,omitempty"`
|
|
|
|
CAKey string `yaml:"ca_key,omitempty"`
|
|
|
|
Environment []string `yaml:"environment,omitempty"`
|
|
|
|
StorageContext string `yaml:"storage_context,omitempty"`
|
2015-12-22 22:14:51 +00:00
|
|
|
Exec bool `yaml:"exec,omitempty"`
|
2015-03-15 04:27:04 +00:00
|
|
|
}
|
|
|
|
|
2016-01-28 15:27:17 +00:00
|
|
|
type SshConfig struct {
|
|
|
|
Keys map[string]string `yaml:"keys,omitempty"`
|
|
|
|
}
|
|
|
|
|
2015-03-18 13:23:27 +00:00
|
|
|
type StateConfig struct {
|
2015-12-20 05:34:07 +00:00
|
|
|
Directory string `yaml:"directory,omitempty"`
|
2015-03-18 13:23:27 +00:00
|
|
|
FsType string `yaml:"fstype,omitempty"`
|
|
|
|
Dev string `yaml:"dev,omitempty"`
|
|
|
|
Required bool `yaml:"required,omitempty"`
|
|
|
|
Autoformat []string `yaml:"autoformat,omitempty"`
|
2015-07-21 15:43:20 +00:00
|
|
|
FormatZero bool `yaml:"formatzero,omitempty"`
|
2015-12-21 06:26:34 +00:00
|
|
|
MdadmScan bool `yaml:"mdadm_scan,omitempty"`
|
|
|
|
Script string `yaml:"script,omitempty"`
|
2015-12-20 05:26:09 +00:00
|
|
|
OemFsType string `yaml:"oem_fstype,omitempty"`
|
|
|
|
OemDev string `yaml:"oem_dev,omitempty"`
|
2015-03-15 04:27:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type CloudInit struct {
|
|
|
|
Datasources []string `yaml:"datasources,omitempty"`
|
|
|
|
}
|
2015-03-20 18:35:21 +00:00
|
|
|
|
2016-05-03 15:55:15 +00:00
|
|
|
type Defaults struct {
|
|
|
|
Hostname string `yaml:"hostname,omitempty"`
|
|
|
|
Network netconf.NetworkConfig `yaml:"network,omitempty"`
|
|
|
|
}
|
|
|
|
|
2015-09-23 11:36:28 +00:00
|
|
|
func (r Repositories) ToArray() []string {
|
|
|
|
result := make([]string, 0, len(r))
|
|
|
|
for _, repo := range r {
|
|
|
|
if repo.Url != "" {
|
|
|
|
result = append(result, repo.Url)
|
|
|
|
}
|
2015-03-20 18:35:21 +00:00
|
|
|
}
|
2015-09-23 11:36:28 +00:00
|
|
|
|
|
|
|
return result
|
2015-03-20 18:35:21 +00:00
|
|
|
}
|