Support setting env vars in kubectl run

This commit is contained in:
feihujiang
2015-09-01 11:03:29 +08:00
parent bb3e20e361
commit 84e94e39cd
8 changed files with 198 additions and 5 deletions

View File

@@ -60,6 +60,50 @@ func TestGenerate(t *testing.T) {
},
},
},
{
params: map[string]interface{}{
"name": "foo",
"image": "someimage",
"replicas": "1",
"port": "-1",
"env": []string{"a=b", "c=d"},
},
expected: &api.ReplicationController{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{"run": "foo"},
},
Spec: api.ReplicationControllerSpec{
Replicas: 1,
Selector: map[string]string{"run": "foo"},
Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: map[string]string{"run": "foo"},
},
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: "foo",
Image: "someimage",
Env: []api.EnvVar{
{
Name: "a",
Value: "b",
},
{
Name: "c",
Value: "d",
},
},
},
},
},
},
},
},
},
{
params: map[string]interface{}{
"name": "foo",
@@ -287,6 +331,49 @@ func TestGeneratePod(t *testing.T) {
},
},
},
{
params: map[string]interface{}{
"name": "foo",
"image": "someimage",
"env": []string{"a", "c"},
},
expected: nil,
expectErr: true,
},
{
params: map[string]interface{}{
"name": "foo",
"image": "someimage",
"env": []string{"a=b", "c=d"},
},
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: "foo",
Image: "someimage",
ImagePullPolicy: api.PullIfNotPresent,
Env: []api.EnvVar{
{
Name: "a",
Value: "b",
},
{
Name: "c",
Value: "d",
},
},
},
},
DNSPolicy: api.DNSClusterFirst,
RestartPolicy: api.RestartPolicyAlways,
},
},
},
{
params: map[string]interface{}{
"name": "foo",