forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ok.go
133 lines (120 loc) · 3.16 KB
/
ok.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
package test
import (
kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
deployapi "github.com/openshift/origin/pkg/deploy/api"
imageapi "github.com/openshift/origin/pkg/image/api"
)
func OkStrategy() deployapi.DeploymentStrategy {
return deployapi.DeploymentStrategy{
Type: deployapi.DeploymentStrategyTypeRecreate,
}
}
func OkCustomStrategy() deployapi.DeploymentStrategy {
return deployapi.DeploymentStrategy{
Type: deployapi.DeploymentStrategyTypeCustom,
CustomParams: OkCustomParams(),
}
}
func OkCustomParams() *deployapi.CustomDeploymentStrategyParams {
return &deployapi.CustomDeploymentStrategyParams{
Image: "openshift/origin-deployer",
Environment: []kapi.EnvVar{
{
Name: "ENV1",
Value: "VAL1",
},
},
Command: []string{"/bin/echo", "hello", "world"},
}
}
func OkControllerTemplate() kapi.ReplicationControllerSpec {
return kapi.ReplicationControllerSpec{
Replicas: 1,
Selector: OkSelector(),
Template: OkPodTemplate(),
}
}
func OkDeploymentTemplate() deployapi.DeploymentTemplate {
return deployapi.DeploymentTemplate{
Strategy: OkStrategy(),
ControllerTemplate: OkControllerTemplate(),
}
}
func OkSelector() map[string]string {
return map[string]string{"a": "b"}
}
func OkPodTemplate() *kapi.PodTemplateSpec {
return &kapi.PodTemplateSpec{
Spec: kapi.PodSpec{
Containers: []kapi.Container{
{
Name: "container1",
Image: "registry:8080/repo1:ref1",
Env: []kapi.EnvVar{
{
Name: "ENV1",
Value: "VAL1",
},
},
ImagePullPolicy: kapi.PullIfNotPresent,
},
{
Name: "container2",
Image: "registry:8080/repo1:ref2",
ImagePullPolicy: kapi.PullIfNotPresent,
},
},
RestartPolicy: kapi.RestartPolicyAlways,
DNSPolicy: kapi.DNSClusterFirst,
},
ObjectMeta: kapi.ObjectMeta{
Labels: OkSelector(),
},
}
}
func OkConfigChangeTrigger() deployapi.DeploymentTriggerPolicy {
return deployapi.DeploymentTriggerPolicy{
Type: deployapi.DeploymentTriggerOnConfigChange,
}
}
func OkImageChangeTrigger() deployapi.DeploymentTriggerPolicy {
return deployapi.DeploymentTriggerPolicy{
Type: deployapi.DeploymentTriggerOnImageChange,
ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{
Automatic: true,
ContainerNames: []string{
"container1",
},
From: kapi.ObjectReference{
Kind: "ImageRepository",
Name: "test-image-repo",
},
Tag: imageapi.DefaultImageTag,
},
}
}
func OkImageChangeTriggerDeprecated() deployapi.DeploymentTriggerPolicy {
return deployapi.DeploymentTriggerPolicy{
Type: deployapi.DeploymentTriggerOnImageChange,
ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{
Automatic: true,
ContainerNames: []string{
"container1",
},
RepositoryName: "registry:8080/repo1:ref1",
Tag: imageapi.DefaultImageTag,
},
}
}
func OkDeploymentConfig(version int) *deployapi.DeploymentConfig {
return &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{
Name: "config",
},
LatestVersion: version,
Triggers: []deployapi.DeploymentTriggerPolicy{
OkImageChangeTrigger(),
},
Template: OkDeploymentTemplate(),
}
}