Skip to content

Commit 75dce5e

Browse files
added swagger docs and verified the gofmt
1 parent 27e40e6 commit 75dce5e

File tree

7 files changed

+63
-52
lines changed

7 files changed

+63
-52
lines changed

pkg/cmd/server/origin/master_config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import (
6969
imageadmission "github.com/openshift/origin/pkg/image/admission"
7070
imagepolicy "github.com/openshift/origin/pkg/image/admission/imagepolicy/api"
7171
imageapi "github.com/openshift/origin/pkg/image/api"
72+
ingressadmit "github.com/openshift/origin/pkg/ingress/admission"
7273
accesstokenregistry "github.com/openshift/origin/pkg/oauth/registry/oauthaccesstoken"
7374
accesstokenetcd "github.com/openshift/origin/pkg/oauth/registry/oauthaccesstoken/etcd"
7475
projectauth "github.com/openshift/origin/pkg/project/auth"
@@ -79,7 +80,6 @@ import (
7980
"github.com/openshift/origin/pkg/quota/controller/clusterquotamapping"
8081
"github.com/openshift/origin/pkg/service"
8182
serviceadmit "github.com/openshift/origin/pkg/service/admission"
82-
ingressadmit "github.com/openshift/origin/pkg/ingress/admission"
8383
"github.com/openshift/origin/pkg/serviceaccounts"
8484
usercache "github.com/openshift/origin/pkg/user/cache"
8585
groupregistry "github.com/openshift/origin/pkg/user/registry/group"

pkg/ingress/admission/api/types.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import (
55
)
66

77
// IngressAdmissionConfig is the configuration for the the ingress
8-
// controller limiter plugin. It changes the behavior of ingress
8+
// controller limiter plugin. It changes the behavior of ingress
99
//objects to behave better with openshift routes and routers.
10-
//*NOTE* Disabling this plugin causes ingress objects to behave
10+
//*NOTE* Disabling this plugin causes ingress objects to behave
1111
//the same as in upstream kubernetes
1212
type IngressAdmissionConfig struct {
1313
unversioned.TypeMeta
1414

15-
//UpstreamHostnameUpdate when true causes updates that attempt
16-
//to add or modify hostnames to succeed. Otherwise those updates
17-
//fail in order to ensure hostname behavior
15+
//UpstreamHostnameUpdate when true causes updates that attempt
16+
//to add or modify hostnames to succeed. Otherwise those updates
17+
//fail in order to ensure hostname behavior
1818
UpstreamHostnameUpdate bool
1919
}

pkg/ingress/admission/api/v1/defaults_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ import (
1212
_ "github.com/openshift/origin/pkg/ingress/admission/api/install"
1313

1414
ingressv1 "github.com/openshift/origin/pkg/ingress/admission/api/v1"
15-
1615
)
1716

1817
func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
1918
data, err := runtime.Encode(configapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), obj)
20-
if err != nil {
19+
if err != nil {
2120
t.Errorf("%v\n %#v", err, obj)
2221
return nil
2322
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package v1
2+
3+
// This file contains methods that can be used by the go-restful package to generate Swagger
4+
// documentation for the object types found in 'types.go' This file is automatically generated
5+
// by hack/update-generated-swagger-descriptions.sh and should be run after a full build of OpenShift.
6+
// ==== DO NOT EDIT THIS FILE MANUALLY ====
7+
8+
var map_IngressAdmissionConfig = map[string]string{
9+
"": "IngressAdmissionConfig is the configuration for the the ingress controller limiter plugin. It changes the behavior of ingress objects to behave better with openshift routes and routers. *NOTE* Disabling this plugin causes ingress objects to behave the same as in upstream kubernetes",
10+
"upstreamHostnameUpdate": "UpstreamHostnameUpdate when true causes updates that attempt to add or modify hostnames to succeed. Otherwise those updates fail in order to ensure hostname behavior",
11+
}
12+
13+
func (IngressAdmissionConfig) SwaggerDoc() map[string]string {
14+
return map_IngressAdmissionConfig
15+
}

pkg/ingress/admission/api/v1/types.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ import (
55
)
66

77
// IngressAdmissionConfig is the configuration for the the ingress
8-
// controller limiter plugin. It changes the behavior of ingress
8+
// controller limiter plugin. It changes the behavior of ingress
99
//objects to behave better with openshift routes and routers.
10-
//*NOTE* Disabling this plugin causes ingress objects to behave
10+
//*NOTE* Disabling this plugin causes ingress objects to behave
1111
//the same as in upstream kubernetes
1212
type IngressAdmissionConfig struct {
1313
unversioned.TypeMeta `json:",inline"`
1414

1515
//UpstreamHostnameUpdate when true causes updates that attempt
16-
//to add or modify hostnames to succeed. Otherwise those updates
17-
//fail in order to ensure hostname behavior
16+
//to add or modify hostnames to succeed. Otherwise those updates
17+
//fail in order to ensure hostname behavior
1818
UpstreamHostnameUpdate bool `json:"upstreamHostnameUpdate", description:"set to true to disable openshift protections and enable kubernetes style ingress objects"`
19-
2019
}

pkg/ingress/admission/ingress_admission.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"io"
88
"reflect"
99

10-
1110
kadmission "k8s.io/kubernetes/pkg/admission"
1211
kextensions "k8s.io/kubernetes/pkg/apis/extensions"
1312
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
@@ -35,11 +34,10 @@ type ingressAdmission struct {
3534
config *api.IngressAdmissionConfig
3635
}
3736

38-
3937
func NewIngressAdmission(config *api.IngressAdmissionConfig) *ingressAdmission {
4038
return &ingressAdmission{
41-
Handler: kadmission.NewHandler(kadmission.Create, kadmission.Update),
42-
config: config,
39+
Handler: kadmission.NewHandler(kadmission.Create, kadmission.Update),
40+
config: config,
4341
}
4442
}
4543

@@ -62,9 +60,9 @@ func readConfig(reader io.Reader) (*api.IngressAdmissionConfig, error) {
6260
return config, nil
6361
}
6462

65-
func (r *ingressAdmission) Admit( a kadmission.Attributes) error {
63+
func (r *ingressAdmission) Admit(a kadmission.Attributes) error {
6664
if a.GetResource().GroupResource() == kextensions.Resource("ingresses") && a.GetOperation() == kadmission.Update {
67-
if (r.config == nil || r.config.UpstreamHostnameUpdate == false) {
65+
if r.config == nil || r.config.UpstreamHostnameUpdate == false {
6866
oldIngress, ok := a.GetOldObject().(*kextensions.Ingress)
6967
if !ok {
7068
return nil

pkg/ingress/admission/ingress_admission_test.go

+33-33
Original file line numberDiff line numberDiff line change
@@ -10,61 +10,61 @@ import (
1010
"github.com/openshift/origin/pkg/ingress/admission/api"
1111
)
1212

13-
func TestAdmission( t *testing.T) {
13+
func TestAdmission(t *testing.T) {
1414

1515
var newIngress *kextensions.Ingress
1616
var oldIngress *kextensions.Ingress
1717

1818
tests := []struct {
19-
config *api.IngressAdmissionConfig
20-
testName string
19+
config *api.IngressAdmissionConfig
20+
testName string
2121
oldHost, newHost string
22-
op admission.Operation
23-
admit bool
22+
op admission.Operation
23+
admit bool
2424
}{
2525
{
26-
admit: true,
27-
config: emptyConfig(),
28-
op: admission.Create,
26+
admit: true,
27+
config: emptyConfig(),
28+
op: admission.Create,
2929
testName: "No errors on create",
3030
},
3131
{
32-
admit: true,
33-
config: emptyConfig(),
34-
op: admission.Update,
35-
newHost: "foo.com",
36-
oldHost: "foo.com",
32+
admit: true,
33+
config: emptyConfig(),
34+
op: admission.Update,
35+
newHost: "foo.com",
36+
oldHost: "foo.com",
3737
testName: "keeping the host the same should pass",
3838
},
3939
{
40-
admit: true,
41-
config: emptyConfig(),
42-
op: admission.Update,
43-
oldHost: "foo.com",
40+
admit: true,
41+
config: emptyConfig(),
42+
op: admission.Update,
43+
oldHost: "foo.com",
4444
testName: "deleting a hostname should pass",
4545
},
4646
{
47-
admit: false,
48-
config: emptyConfig(),
49-
op: admission.Update,
50-
newHost: "foo.com",
51-
oldHost: "bar.com",
47+
admit: false,
48+
config: emptyConfig(),
49+
op: admission.Update,
50+
newHost: "foo.com",
51+
oldHost: "bar.com",
5252
testName: "changing hostname should fail",
5353
},
5454
{
55-
admit: false,
56-
config: nil,
57-
op: admission.Update,
58-
newHost: "foo.com",
59-
oldHost: "bar.com",
55+
admit: false,
56+
config: nil,
57+
op: admission.Update,
58+
newHost: "foo.com",
59+
oldHost: "bar.com",
6060
testName: "unconfigured plugin should still fail",
6161
},
6262
{
63-
admit: true,
64-
config: testConfigUpdateAllow(),
65-
op: admission.Update,
66-
newHost: "foo.com",
67-
oldHost: "bar.com",
63+
admit: true,
64+
config: testConfigUpdateAllow(),
65+
op: admission.Update,
66+
newHost: "foo.com",
67+
oldHost: "bar.com",
6868
testName: "Upstream Hostname updates enabled",
6969
},
7070
}
@@ -84,7 +84,7 @@ func TestAdmission( t *testing.T) {
8484
//Used to test deleteing a hostname
8585
newIngress = &kextensions.Ingress{
8686
ObjectMeta: kapi.ObjectMeta{Name: "test"},
87-
}
87+
}
8888
}
8989
handler := NewIngressAdmission(test.config)
9090

0 commit comments

Comments
 (0)