1
0
mirror of https://github.com/rancher/os.git synced 2025-09-03 15:54:24 +00:00

rename rancher.user_docker to rancher.docker in cloud-config

This commit is contained in:
Ivan Mikushin
2015-09-11 14:10:50 +05:00
parent f19de93e09
commit 5934852e80
8 changed files with 30 additions and 30 deletions

View File

@@ -69,8 +69,8 @@ func TestSubstituteUserDataVars(t *testing.T) {
interfaces: interfaces:
eth1: eth1:
address: $private_ipv4/16 address: $private_ipv4/16
user_docker: docker:
tls_args: ['-H=$public_ipv4:2376']`, tls_args: ['-H=$public_ipv4:2376']`,
`write_files: `write_files:
- path: /etc/environment - path: /etc/environment
content: | content: |
@@ -81,8 +81,8 @@ func TestSubstituteUserDataVars(t *testing.T) {
interfaces: interfaces:
eth1: eth1:
address: 192.0.2.203/16 address: 192.0.2.203/16
user_docker: docker:
tls_args: ['-H=192.0.2.3:2376']`, tls_args: ['-H=192.0.2.3:2376']`,
}, },
{ {
// no metadata // no metadata

View File

@@ -49,7 +49,7 @@ func writeCerts(generateServer bool, hostname []string, cfg *config.CloudConfig,
return machineUtil.GenerateCert([]string{""}, certPath, keyPath, caCertPath, caKeyPath, NAME, BITS) return machineUtil.GenerateCert([]string{""}, certPath, keyPath, caCertPath, caKeyPath, NAME, BITS)
} }
if cfg.Rancher.UserDocker.ServerKey == "" || cfg.Rancher.UserDocker.ServerCert == "" { if cfg.Rancher.Docker.ServerKey == "" || cfg.Rancher.Docker.ServerCert == "" {
err := machineUtil.GenerateCert(hostname, certPath, keyPath, caCertPath, caKeyPath, NAME, BITS) err := machineUtil.GenerateCert(hostname, certPath, keyPath, caCertPath, caKeyPath, NAME, BITS)
if err != nil { if err != nil {
return err return err
@@ -67,9 +67,9 @@ func writeCerts(generateServer bool, hostname []string, cfg *config.CloudConfig,
return cfg.SetConfig(&config.CloudConfig{ return cfg.SetConfig(&config.CloudConfig{
Rancher: config.RancherConfig{ Rancher: config.RancherConfig{
UserDocker: config.DockerConfig{ Docker: config.DockerConfig{
CAKey: cfg.Rancher.UserDocker.CAKey, CAKey: cfg.Rancher.Docker.CAKey,
CACert: cfg.Rancher.UserDocker.CACert, CACert: cfg.Rancher.Docker.CACert,
ServerCert: string(cert), ServerCert: string(cert),
ServerKey: string(key), ServerKey: string(key),
}, },
@@ -77,16 +77,16 @@ func writeCerts(generateServer bool, hostname []string, cfg *config.CloudConfig,
}) })
} }
if err := ioutil.WriteFile(certPath, []byte(cfg.Rancher.UserDocker.ServerCert), 0400); err != nil { if err := ioutil.WriteFile(certPath, []byte(cfg.Rancher.Docker.ServerCert), 0400); err != nil {
return err return err
} }
return ioutil.WriteFile(keyPath, []byte(cfg.Rancher.UserDocker.ServerKey), 0400) return ioutil.WriteFile(keyPath, []byte(cfg.Rancher.Docker.ServerKey), 0400)
} }
func writeCaCerts(cfg *config.CloudConfig, caCertPath, caKeyPath string) error { func writeCaCerts(cfg *config.CloudConfig, caCertPath, caKeyPath string) error {
if cfg.Rancher.UserDocker.CACert == "" { if cfg.Rancher.Docker.CACert == "" {
if err := machineUtil.GenerateCACertificate(caCertPath, caKeyPath, NAME, BITS); err != nil { if err := machineUtil.GenerateCACertificate(caCertPath, caKeyPath, NAME, BITS); err != nil {
return err return err
} }
@@ -103,7 +103,7 @@ func writeCaCerts(cfg *config.CloudConfig, caCertPath, caKeyPath string) error {
err = cfg.SetConfig(&config.CloudConfig{ err = cfg.SetConfig(&config.CloudConfig{
Rancher: config.RancherConfig{ Rancher: config.RancherConfig{
UserDocker: config.DockerConfig{ Docker: config.DockerConfig{
CAKey: string(caKey), CAKey: string(caKey),
CACert: string(caCert), CACert: string(caCert),
}, },
@@ -116,11 +116,11 @@ func writeCaCerts(cfg *config.CloudConfig, caCertPath, caKeyPath string) error {
return nil return nil
} }
if err := ioutil.WriteFile(caCertPath, []byte(cfg.Rancher.UserDocker.CACert), 0400); err != nil { if err := ioutil.WriteFile(caCertPath, []byte(cfg.Rancher.Docker.CACert), 0400); err != nil {
return err return err
} }
return ioutil.WriteFile(caKeyPath, []byte(cfg.Rancher.UserDocker.CAKey), 0400) return ioutil.WriteFile(caKeyPath, []byte(cfg.Rancher.Docker.CAKey), 0400)
} }
func tlsConfCreate(c *cli.Context) { func tlsConfCreate(c *cli.Context) {

View File

@@ -46,7 +46,7 @@ func Main() {
} }
func enter(cfg *config.CloudConfig) error { func enter(cfg *config.CloudConfig) error {
context := cfg.Rancher.UserDocker.StorageContext context := cfg.Rancher.Docker.StorageContext
if context == "" { if context == "" {
context = DEFAULT_STORAGE_CONTEXT context = DEFAULT_STORAGE_CONTEXT
} }
@@ -211,7 +211,7 @@ func main(cfg *config.CloudConfig) error {
return err return err
} }
dockerCfg := cfg.Rancher.UserDocker dockerCfg := cfg.Rancher.Docker
args := dockerCfg.FullArgs() args := dockerCfg.FullArgs()

View File

@@ -55,8 +55,8 @@ func LoadConfig() (*CloudConfig, error) {
if cfg.Rancher.Debug { if cfg.Rancher.Debug {
log.SetLevel(log.DebugLevel) log.SetLevel(log.DebugLevel)
if !util.Contains(cfg.Rancher.UserDocker.Args, "-D") { if !util.Contains(cfg.Rancher.Docker.Args, "-D") {
cfg.Rancher.UserDocker.Args = append(cfg.Rancher.UserDocker.Args, "-D") cfg.Rancher.Docker.Args = append(cfg.Rancher.Docker.Args, "-D")
} }
if !util.Contains(cfg.Rancher.SystemDocker.Args, "-D") { if !util.Contains(cfg.Rancher.SystemDocker.Args, "-D") {
cfg.Rancher.SystemDocker.Args = append(cfg.Rancher.SystemDocker.Args, "-D") cfg.Rancher.SystemDocker.Args = append(cfg.Rancher.SystemDocker.Args, "-D")

View File

@@ -22,7 +22,7 @@ func TestFilterKey(t *testing.T) {
"dsa-pub": "dsa-test2", "dsa-pub": "dsa-test2",
}, },
}, },
"user_docker": map[interface{}]interface{}{ "docker": map[interface{}]interface{}{
"ca_key": "ca_key-test3", "ca_key": "ca_key-test3",
"ca_cert": "ca_cert-test4", "ca_cert": "ca_cert-test4",
"args": []string{"args_test5"}, "args": []string{"args_test5"},
@@ -43,7 +43,7 @@ func TestFilterKey(t *testing.T) {
"ssh_authorized_keys": []string{"pubk1", "pubk2"}, "ssh_authorized_keys": []string{"pubk1", "pubk2"},
"hostname": "ros-test", "hostname": "ros-test",
"rancher": map[interface{}]interface{}{ "rancher": map[interface{}]interface{}{
"user_docker": map[interface{}]interface{}{ "docker": map[interface{}]interface{}{
"ca_key": "ca_key-test3", "ca_key": "ca_key-test3",
"ca_cert": "ca_cert-test4", "ca_cert": "ca_cert-test4",
"args": []string{"args_test5"}, "args": []string{"args_test5"},
@@ -68,7 +68,7 @@ func TestFilterDottedKeys(t *testing.T) {
"dsa-pub": "dsa-test2", "dsa-pub": "dsa-test2",
}, },
}, },
"user_docker": map[interface{}]interface{}{ "docker": map[interface{}]interface{}{
"ca_key": "ca_key-test3", "ca_key": "ca_key-test3",
"ca_cert": "ca_cert-test4", "ca_cert": "ca_cert-test4",
"args": []string{"args_test5"}, "args": []string{"args_test5"},
@@ -89,7 +89,7 @@ func TestFilterDottedKeys(t *testing.T) {
expectedRest := map[interface{}]interface{}{ expectedRest := map[interface{}]interface{}{
"hostname": "ros-test", "hostname": "ros-test",
"rancher": map[interface{}]interface{}{ "rancher": map[interface{}]interface{}{
"user_docker": map[interface{}]interface{}{ "docker": map[interface{}]interface{}{
"ca_key": "ca_key-test3", "ca_key": "ca_key-test3",
"ca_cert": "ca_cert-test4", "ca_cert": "ca_cert-test4",
"args": []string{"args_test5"}, "args": []string{"args_test5"},
@@ -254,7 +254,7 @@ func TestUserDocker(t *testing.T) {
config := &CloudConfig{ config := &CloudConfig{
Rancher: RancherConfig{ Rancher: RancherConfig{
UserDocker: DockerConfig{ Docker: DockerConfig{
TLS: true, TLS: true,
}, },
}, },
@@ -272,7 +272,7 @@ func TestUserDocker(t *testing.T) {
fmt.Println(data) fmt.Println(data)
val, ok := data["rancher"]["user_docker"] val, ok := data["rancher"]["docker"]
assert.True(ok) assert.True(ok)
m, ok := val.(map[interface{}]interface{}) m, ok := val.(map[interface{}]interface{})

View File

@@ -20,10 +20,10 @@ func writeToFile(data interface{}, filename string) error {
func saveToDisk(data map[interface{}]interface{}) error { func saveToDisk(data map[interface{}]interface{}) error {
private, config := filterDottedKeys(data, []string{ private, config := filterDottedKeys(data, []string{
"rancher.ssh", "rancher.ssh",
"rancher.user_docker.ca_key", "rancher.docker.ca_key",
"rancher.user_docker.ca_cert", "rancher.docker.ca_cert",
"rancher.user_docker.server_key", "rancher.docker.server_key",
"rancher.user_docker.server_cert", "rancher.docker.server_cert",
}) })
err := writeToFile(config, LocalConfigFile) err := writeToFile(config, LocalConfigFile)

View File

@@ -81,7 +81,7 @@ type RancherConfig struct {
State StateConfig `yaml:"state,omitempty"` State StateConfig `yaml:"state,omitempty"`
SystemDocker DockerConfig `yaml:"system_docker,omitempty"` SystemDocker DockerConfig `yaml:"system_docker,omitempty"`
Upgrade UpgradeConfig `yaml:"upgrade,omitempty"` Upgrade UpgradeConfig `yaml:"upgrade,omitempty"`
UserDocker DockerConfig `yaml:"user_docker,omitempty"` Docker DockerConfig `yaml:"docker,omitempty"`
} }
type UpgradeConfig struct { type UpgradeConfig struct {

View File

@@ -298,7 +298,7 @@ rancher:
upgrade: upgrade:
url: https://releases.rancher.com/os/releases.yml url: https://releases.rancher.com/os/releases.yml
image: rancher/os image: rancher/os
user_docker: docker:
tls_args: [--tlsverify, --tlscacert=ca.pem, --tlscert=server-cert.pem, --tlskey=server-key.pem, tls_args: [--tlsverify, --tlscacert=ca.pem, --tlscert=server-cert.pem, --tlskey=server-key.pem,
'-H=0.0.0.0:2376'] '-H=0.0.0.0:2376']
args: [daemon, --log-opt, max-size=25m, --log-opt, max-file=2, -s, overlay, -G, docker, -H, 'unix:///var/run/docker.sock', --userland-proxy=false] args: [daemon, --log-opt, max-size=25m, --log-opt, max-file=2, -s, overlay, -G, docker, -H, 'unix:///var/run/docker.sock', --userland-proxy=false]