... | ... |
@@ -53,7 +53,7 @@ func NewJenkinsBootstrapper(serviceClient coreclient.ServicesGetter) admission.I |
53 | 53 |
} |
54 | 54 |
|
55 | 55 |
func (a *jenkinsBootstrapper) Admit(attributes admission.Attributes) error { |
56 |
- if a.jenkinsConfig.AutoProvisionEnabled == nil || !*a.jenkinsConfig.AutoProvisionEnabled { |
|
56 |
+ if a.jenkinsConfig.AutoProvisionEnabled != nil && !*a.jenkinsConfig.AutoProvisionEnabled { |
|
57 | 57 |
return nil |
58 | 58 |
} |
59 | 59 |
if len(attributes.GetSubresource()) != 0 { |
... | ... |
@@ -36,11 +36,6 @@ func TestAdmission(t *testing.T) { |
36 | 36 |
validateClients: noAction, |
37 | 37 |
}, |
38 | 38 |
{ |
39 |
- name: "disabled default", |
|
40 |
- attributes: admission.NewAttributesRecord(enableBuild, nil, unversioned.GroupVersionKind{}, "namespace", "name", buildapi.SchemeGroupVersion.WithResource("builds"), "", admission.Create, &user.DefaultInfo{}), |
|
41 |
- validateClients: noAction, |
|
42 |
- }, |
|
43 |
- { |
|
44 | 39 |
name: "not a jenkins build", |
45 | 40 |
attributes: admission.NewAttributesRecord(&buildapi.Build{Spec: buildapi.BuildSpec{CommonSpec: buildapi.CommonSpec{Strategy: buildapi.BuildStrategy{}}}}, nil, unversioned.GroupVersionKind{}, "namespace", "name", buildapi.SchemeGroupVersion.WithResource("builds"), "", admission.Create, &user.DefaultInfo{}), |
46 | 41 |
jenkinsEnabled: boolptr(true), |
... | ... |
@@ -93,6 +88,19 @@ func TestAdmission(t *testing.T) { |
93 | 93 |
}, |
94 | 94 |
}, |
95 | 95 |
{ |
96 |
+ name: "enabled default", |
|
97 |
+ attributes: admission.NewAttributesRecord(enableBuild, nil, unversioned.GroupVersionKind{}, "namespace", "name", buildapi.SchemeGroupVersion.WithResource("builds"), "", admission.Create, &user.DefaultInfo{}), |
|
98 |
+ objects: []runtime.Object{ |
|
99 |
+ &kapi.Service{ObjectMeta: kapi.ObjectMeta{Namespace: "namespace", Name: "jenkins"}}, |
|
100 |
+ }, |
|
101 |
+ validateClients: func(kubeClient *fake.Clientset, originClient *testclient.Fake) string { |
|
102 |
+ if len(kubeClient.Actions()) == 1 && kubeClient.Actions()[0].Matches("get", "services") { |
|
103 |
+ return "" |
|
104 |
+ } |
|
105 |
+ return fmt.Sprintf("missing get service in: %v", kubeClient.Actions()) |
|
106 |
+ }, |
|
107 |
+ }, |
|
108 |
+ { |
|
96 | 109 |
name: "service missing", |
97 | 110 |
attributes: admission.NewAttributesRecord(enableBuild, nil, unversioned.GroupVersionKind{}, "namespace", "name", buildapi.SchemeGroupVersion.WithResource("builds"), "", admission.Create, &user.DefaultInfo{}), |
98 | 111 |
jenkinsEnabled: boolptr(true), |
... | ... |
@@ -331,7 +331,7 @@ type AuditConfig struct { |
331 | 331 |
type JenkinsPipelineConfig struct { |
332 | 332 |
// AutoProvisionEnabled determines whether a Jenkins server will be spawned from the provided |
333 | 333 |
// template when the first build config in the project with type JenkinsPipeline |
334 |
- // is created. When not specified this option defaults to false. |
|
334 |
+ // is created. When not specified this option defaults to true. |
|
335 | 335 |
AutoProvisionEnabled *bool |
336 | 336 |
// TemplateNamespace contains the namespace name where the Jenkins template is stored |
337 | 337 |
TemplateNamespace string |
... | ... |
@@ -308,7 +308,7 @@ func (ImagePolicyConfig) SwaggerDoc() map[string]string { |
308 | 308 |
|
309 | 309 |
var map_JenkinsPipelineConfig = map[string]string{ |
310 | 310 |
"": "JenkinsPipelineConfig holds configuration for the Jenkins pipeline strategy", |
311 |
- "autoProvisionEnabled": "AutoProvisionEnabled determines whether a Jenkins server will be spawned from the provided template when the first build config in the project with type JenkinsPipeline is created. When not specified this option defaults to false.", |
|
311 |
+ "autoProvisionEnabled": "AutoProvisionEnabled determines whether a Jenkins server will be spawned from the provided template when the first build config in the project with type JenkinsPipeline is created. When not specified this option defaults to true.", |
|
312 | 312 |
"templateNamespace": "TemplateNamespace contains the namespace name where the Jenkins template is stored", |
313 | 313 |
"templateName": "TemplateName is the name of the default Jenkins template", |
314 | 314 |
"serviceName": "ServiceName is the name of the Jenkins service OpenShift uses to detect whether a Jenkins pipeline handler has already been installed in a project. This value *must* match a service name in the provided template.", |
... | ... |
@@ -257,7 +257,7 @@ type AuditConfig struct { |
257 | 257 |
type JenkinsPipelineConfig struct { |
258 | 258 |
// AutoProvisionEnabled determines whether a Jenkins server will be spawned from the provided |
259 | 259 |
// template when the first build config in the project with type JenkinsPipeline |
260 |
- // is created. When not specified this option defaults to false. |
|
260 |
+ // is created. When not specified this option defaults to true. |
|
261 | 261 |
AutoProvisionEnabled *bool `json:"autoProvisionEnabled"` |
262 | 262 |
// TemplateNamespace contains the namespace name where the Jenkins template is stored |
263 | 263 |
TemplateNamespace string `json:"templateNamespace"` |