示例#1
0
func TestEnvironmentResolve(t *testing.T) {
	factory := &TestServiceFactory{
		Counts: map[string]int{},
	}

	p := NewProject(nil, &Context{
		ServiceFactory:    factory,
		EnvironmentLookup: &TestEnvironmentLookup{},
	}, nil)
	p.ServiceConfigs = config.NewServiceConfigs()
	p.ServiceConfigs.Add("foo", &config.ServiceConfig{
		Environment: yaml.MaporEqualSlice([]string{
			"A",
			"A=",
			"A=B",
		}),
	})

	service, err := p.CreateService("foo")
	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(service.Config().Environment, yaml.MaporEqualSlice{"A=X", "A=X", "A=B"}) {
		t.Fatal("Invalid environment", service.Config().Environment)
	}
}
示例#2
0
func newTestConfig() TestConfig {
	return TestConfig{
		SystemContainers: map[string]*ServiceConfig{
			"udev": {
				Image:       "udev",
				Restart:     "always",
				NetworkMode: "host",
				Privileged:  true,
				DNS:         []string{"8.8.8.8", "8.8.4.4"},
				Environment: yamlTypes.MaporEqualSlice([]string{
					"DAEMON=true",
				}),
				Labels: yamlTypes.SliceorMap{
					"io.rancher.os.detach": "true",
					"io.rancher.os.scope":  "system",
				},
				VolumesFrom: []string{
					"system-volumes",
				},
				Ulimits: yamlTypes.Ulimits{
					Elements: []yamlTypes.Ulimit{
						yamlTypes.NewUlimit("nproc", 65557, 65557),
					},
				},
			},
			"system-volumes": {
				Image:       "state",
				NetworkMode: "none",
				ReadOnly:    true,
				Privileged:  true,
				Labels: yamlTypes.SliceorMap{
					"io.rancher.os.createonly": "true",
					"io.rancher.os.scope":      "system",
				},
				Volumes: []string{
					"/dev:/host/dev",
					"/var/lib/rancher/conf:/var/lib/rancher/conf",
					"/etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt.rancher",
					"/lib/modules:/lib/modules",
					"/lib/firmware:/lib/firmware",
					"/var/run:/var/run",
					"/var/log:/var/log",
				},
				Logging: Log{
					Driver: "json-file",
				},
			},
		},
	}
}