Skip to content

Commit

Permalink
re-enable jenkins autoprovisioning
Browse files Browse the repository at this point in the history
  • Loading branch information
bparees committed Oct 23, 2016
1 parent b3871bb commit 1cbf66e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/build/admission/jenkinsbootstrapper/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewJenkinsBootstrapper(serviceClient coreclient.ServicesGetter) admission.I
}

func (a *jenkinsBootstrapper) Admit(attributes admission.Attributes) error {
if a.jenkinsConfig.AutoProvisionEnabled == nil || !*a.jenkinsConfig.AutoProvisionEnabled {
if a.jenkinsConfig.AutoProvisionEnabled != nil && !*a.jenkinsConfig.AutoProvisionEnabled {
return nil
}
if len(attributes.GetSubresource()) != 0 {
Expand Down
18 changes: 13 additions & 5 deletions pkg/build/admission/jenkinsbootstrapper/admission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ func TestAdmission(t *testing.T) {
jenkinsEnabled: boolptr(false),
validateClients: noAction,
},
{
name: "disabled default",
attributes: admission.NewAttributesRecord(enableBuild, nil, unversioned.GroupVersionKind{}, "namespace", "name", buildapi.SchemeGroupVersion.WithResource("builds"), "", admission.Create, &user.DefaultInfo{}),
validateClients: noAction,
},
{
name: "not a jenkins build",
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{}),
Expand Down Expand Up @@ -92,6 +87,19 @@ func TestAdmission(t *testing.T) {
return fmt.Sprintf("missing get service in: %v", kubeClient.Actions())
},
},
{
name: "enabled default",
attributes: admission.NewAttributesRecord(enableBuild, nil, unversioned.GroupVersionKind{}, "namespace", "name", buildapi.SchemeGroupVersion.WithResource("builds"), "", admission.Create, &user.DefaultInfo{}),
objects: []runtime.Object{
&kapi.Service{ObjectMeta: kapi.ObjectMeta{Namespace: "namespace", Name: "jenkins"}},
},
validateClients: func(kubeClient *fake.Clientset, originClient *testclient.Fake) string {
if len(kubeClient.Actions()) == 1 && kubeClient.Actions()[0].Matches("get", "services") {
return ""
}
return fmt.Sprintf("missing get service in: %v", kubeClient.Actions())
},
},
{
name: "service missing",
attributes: admission.NewAttributesRecord(enableBuild, nil, unversioned.GroupVersionKind{}, "namespace", "name", buildapi.SchemeGroupVersion.WithResource("builds"), "", admission.Create, &user.DefaultInfo{}),
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ type AuditConfig struct {
type JenkinsPipelineConfig struct {
// 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.
// is created. When not specified this option defaults to true.
AutoProvisionEnabled *bool
// TemplateNamespace contains the namespace name where the Jenkins template is stored
TemplateNamespace string
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/api/v1/swagger_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (ImagePolicyConfig) SwaggerDoc() map[string]string {

var map_JenkinsPipelineConfig = map[string]string{
"": "JenkinsPipelineConfig holds configuration for the Jenkins pipeline strategy",
"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.",
"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.",
"templateNamespace": "TemplateNamespace contains the namespace name where the Jenkins template is stored",
"templateName": "TemplateName is the name of the default Jenkins template",
"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.",
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ type AuditConfig struct {
type JenkinsPipelineConfig struct {
// 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.
// is created. When not specified this option defaults to true.
AutoProvisionEnabled *bool `json:"autoProvisionEnabled"`
// TemplateNamespace contains the namespace name where the Jenkins template is stored
TemplateNamespace string `json:"templateNamespace"`
Expand Down

0 comments on commit 1cbf66e

Please sign in to comment.