Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-enable jenkins autoprovisioning #11065

Merged
merged 1 commit into from
Oct 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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