This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 660
/
types.go
executable file
·212 lines (191 loc) · 8.9 KB
/
types.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
package config
import (
"fmt"
"runtime"
"github.com/docker/engine-api/types"
composeConfig "github.com/docker/libcompose/config"
"github.com/rancher/os/config/cloudinit/config"
"github.com/rancher/os/config/yaml"
"github.com/rancher/os/netconf"
)
const (
OEM = "/usr/share/ros/oem"
DockerBin = "/usr/bin/docker"
DockerDistBin = "/usr/bin/docker.dist"
RosBin = "/usr/bin/ros"
SysInitBin = "/usr/bin/ros-sysinit"
SystemDockerHome = "/var/lib/system-docker"
SystemDockerHost = "unix:///var/run/system-docker.sock"
DockerHost = "unix:///var/run/docker.sock"
ImagesPath = "/usr/share/ros"
ImagesPattern = "images*.tar"
ModulesArchive = "/modules.tar"
Debug = false
SystemDockerLog = "/var/log/system-docker.log"
SystemDockerBin = "/usr/bin/system-docker"
HashLabel = "io.rancher.os.hash"
IDLabel = "io.rancher.os.id"
DetachLabel = "io.rancher.os.detach"
CreateOnlyLabel = "io.rancher.os.createonly"
ReloadConfigLabel = "io.rancher.os.reloadconfig"
ConsoleLabel = "io.rancher.os.console"
ScopeLabel = "io.rancher.os.scope"
RebuildLabel = "io.docker.compose.rebuild"
System = "system"
OsConfigFile = "/usr/share/ros/os-config.yml"
VarRancherDir = "/var/lib/rancher"
CloudConfigDir = "/var/lib/rancher/conf/cloud-config.d"
CloudConfigInitFile = "/var/lib/rancher/conf/cloud-config.d/init.yml"
CloudConfigBootFile = "/var/lib/rancher/conf/cloud-config.d/boot.yml"
CloudConfigNetworkFile = "/var/lib/rancher/conf/cloud-config.d/network.yml"
CloudConfigScriptFile = "/var/lib/rancher/conf/cloud-config-script"
MetaDataFile = "/var/lib/rancher/conf/metadata"
CloudConfigFile = "/var/lib/rancher/conf/cloud-config.yml"
)
var (
OemConfigFile = OEM + "/oem-config.yml"
Version string
Arch string
Suffix string
OsRepo string
OsBase string
PrivateKeys = []string{
"rancher.ssh",
"rancher.docker.ca_key",
"rancher.docker.ca_cert",
"rancher.docker.server_key",
"rancher.docker.server_cert",
}
)
func init() {
if Version == "" {
Version = "v0.0.0-dev"
}
if Arch == "" {
Arch = runtime.GOARCH
}
if Suffix == "" && Arch != "amd64" {
Suffix = "_" + Arch
}
if OsBase == "" {
OsBase = fmt.Sprintf("%s/os-base:%s%s", OsRepo, Version, Suffix)
}
}
type Repository struct {
URL string `yaml:"url,omitempty"`
}
type Repositories map[string]Repository
type CloudConfig struct {
SSHAuthorizedKeys []string `yaml:"ssh_authorized_keys,omitempty"`
WriteFiles []File `yaml:"write_files,omitempty"`
Hostname string `yaml:"hostname,omitempty"`
Mounts [][]string `yaml:"mounts,omitempty"`
Rancher RancherConfig `yaml:"rancher,omitempty"`
Runcmd []yaml.StringandSlice `yaml:"runcmd,omitempty"`
Bootcmd []yaml.StringandSlice `yaml:"bootcmd,omitempty"`
}
type File struct {
config.File
Container string `yaml:"container,omitempty"`
}
type RancherConfig struct {
Console string `yaml:"console,omitempty"`
Environment map[string]string `yaml:"environment,omitempty"`
Services map[string]*composeConfig.ServiceConfigV1 `yaml:"services,omitempty"`
BootstrapContainers map[string]*composeConfig.ServiceConfigV1 `yaml:"bootstrap,omitempty"`
CloudInitServices map[string]*composeConfig.ServiceConfigV1 `yaml:"cloud_init_services,omitempty"`
BootstrapDocker DockerConfig `yaml:"bootstrap_docker,omitempty"`
CloudInit CloudInit `yaml:"cloud_init,omitempty"`
Debug bool `yaml:"debug,omitempty"`
RmUsr bool `yaml:"rm_usr,omitempty"`
NoSharedRoot bool `yaml:"no_sharedroot,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"`
RegistryAuths map[string]types.AuthConfig `yaml:"registry_auths,omitempty"`
Defaults Defaults `yaml:"defaults,omitempty"`
ResizeDevice string `yaml:"resize_device,omitempty"`
Sysctl map[string]string `yaml:"sysctl,omitempty"`
RestartServices []string `yaml:"restart_services,omitempty"`
}
type UpgradeConfig struct {
URL string `yaml:"url,omitempty"`
Image string `yaml:"image,omitempty"`
Rollback string `yaml:"rollback,omitempty"`
}
type EngineOpts struct {
Bridge string `yaml:"bridge,omitempty" opt:"bridge"`
ConfigFile string `yaml:"config_file,omitempty" opt:"config-file"`
Containerd string `yaml:"containerd,omitempty" opt:"containerd"`
Debug *bool `yaml:"debug,omitempty" opt:"debug"`
ExecRoot string `yaml:"exec_root,omitempty" opt:"exec-root"`
Group string `yaml:"group,omitempty" opt:"group"`
Graph string `yaml:"graph,omitempty" opt:"graph"`
Host []string `yaml:"host,omitempty" opt:"host"`
InsecureRegistry []string `yaml:"insecure_registry" opt:"insecure-registry"`
LiveRestore *bool `yaml:"live_restore,omitempty" opt:"live-restore"`
LogDriver string `yaml:"log_driver,omitempty" opt:"log-driver"`
LogOpts map[string]string `yaml:"log_opts,omitempty" opt:"log-opt"`
PidFile string `yaml:"pid_file,omitempty" opt:"pidfile"`
RegistryMirror string `yaml:"registry_mirror,omitempty" opt:"registry-mirror"`
Restart *bool `yaml:"restart,omitempty" opt:"restart"`
SelinuxEnabled *bool `yaml:"selinux_enabled,omitempty" opt:"selinux-enabled"`
StorageDriver string `yaml:"storage_driver,omitempty" opt:"storage-driver"`
UserlandProxy *bool `yaml:"userland_proxy,omitempty" opt:"userland-proxy"`
}
type DockerConfig struct {
EngineOpts
Engine string `yaml:"engine,omitempty"`
TLS bool `yaml:"tls,omitempty"`
TLSArgs []string `yaml:"tls_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"`
Exec bool `yaml:"exec,omitempty"`
}
type SSHConfig struct {
Keys map[string]string `yaml:"keys,omitempty"`
}
type StateConfig struct {
Directory string `yaml:"directory,omitempty"`
FsType string `yaml:"fstype,omitempty"`
Dev string `yaml:"dev,omitempty"`
Wait bool `yaml:"wait,omitempty"`
Required bool `yaml:"required,omitempty"`
Autoformat []string `yaml:"autoformat,omitempty"`
MdadmScan bool `yaml:"mdadm_scan,omitempty"`
Script string `yaml:"script,omitempty"`
OemFsType string `yaml:"oem_fstype,omitempty"`
OemDev string `yaml:"oem_dev,omitempty"`
}
type CloudInit struct {
Datasources []string `yaml:"datasources,omitempty"`
}
type Defaults struct {
Hostname string `yaml:"hostname,omitempty"`
Docker DockerConfig `yaml:"docker,omitempty"`
Network netconf.NetworkConfig `yaml:"network,omitempty"`
}
func (r Repositories) ToArray() []string {
result := make([]string, 0, len(r))
for _, repo := range r {
if repo.URL != "" {
result = append(result, repo.URL)
}
}
return result
}