Skip to content

Commit c25262b

Browse files
author
k8s-merge-robot
authored
Merge pull request kubernetes#26298 from nikhiljindal/createFedService
Automatic merge from submit-queue federation: Adding namespaces API Adding namespaces API to federation-apiserver and updating the federation client to include namespaces -------------------------- Original description: This adds the namespaces API to federation-apiserver. The first commit is kubernetes#26142.
2 parents d9fbb9f + 48658ad commit c25262b

File tree

29 files changed

+722
-17
lines changed

29 files changed

+722
-17
lines changed

federation/apis/core/register.go

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ func AddToScheme(scheme *runtime.Scheme) {
5959
scheme.AddKnownTypes(SchemeGroupVersion,
6060
&api.ServiceList{},
6161
&api.Service{},
62+
&api.Namespace{},
63+
&api.NamespaceList{},
6264
&api.ListOptions{},
6365
&api.DeleteOptions{},
6466
)

federation/apis/core/v1/defaults.go

+1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ import (
2424
func addDefaultingFuncs(scheme *runtime.Scheme) {
2525
scheme.AddDefaultingFuncs(
2626
v1.SetDefaults_ServiceSpec,
27+
v1.SetDefaults_NamespaceStatus,
2728
)
2829
}

federation/apis/core/v1/register.go

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ func AddToScheme(scheme *runtime.Scheme) {
4040
func addKnownTypes(scheme *runtime.Scheme) {
4141
scheme.AddKnownTypes(SchemeGroupVersion,
4242
&v1.Service{},
43+
&v1.Namespace{},
44+
&v1.NamespaceList{},
4345
&v1.ServiceList{},
4446
&v1.ListOptions{},
4547
&v1.DeleteOptions{},

federation/client/clientset_generated/federation_internalclientset/doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// This package is generated by client-gen with arguments: --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --included-types-overrides=[api/Service] --input=[../../federation/apis/federation/,api/]
17+
// This package is generated by client-gen with arguments: --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --included-types-overrides=[api/Service,api/Namespace] --input=[../../federation/apis/federation/,api/]
1818

1919
// This package has the automatically generated clientset.
2020
package federation_internalclientset

federation/client/clientset_generated/federation_internalclientset/fake/doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// This package is generated by client-gen with arguments: --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --included-types-overrides=[api/Service] --input=[../../federation/apis/federation/,api/]
17+
// This package is generated by client-gen with arguments: --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --included-types-overrides=[api/Service,api/Namespace] --input=[../../federation/apis/federation/,api/]
1818

1919
// This package has the automatically generated fake clientset.
2020
package fake

federation/client/clientset_generated/federation_internalclientset/typed/core/unversioned/core_client.go

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
type CoreInterface interface {
2626
GetRESTClient() *restclient.RESTClient
27+
NamespacesGetter
2728
ServicesGetter
2829
}
2930

@@ -32,6 +33,10 @@ type CoreClient struct {
3233
*restclient.RESTClient
3334
}
3435

36+
func (c *CoreClient) Namespaces() NamespaceInterface {
37+
return newNamespaces(c)
38+
}
39+
3540
func (c *CoreClient) Services(namespace string) ServiceInterface {
3641
return newServices(c, namespace)
3742
}

federation/client/clientset_generated/federation_internalclientset/typed/core/unversioned/doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// This package is generated by client-gen with arguments: --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --included-types-overrides=[api/Service] --input=[../../federation/apis/federation/,api/]
17+
// This package is generated by client-gen with arguments: --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --included-types-overrides=[api/Service,api/Namespace] --input=[../../federation/apis/federation/,api/]
1818

1919
// This package has the automatically generated typed clients.
2020
package unversioned

federation/client/clientset_generated/federation_internalclientset/typed/core/unversioned/fake/doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// This package is generated by client-gen with arguments: --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --included-types-overrides=[api/Service] --input=[../../federation/apis/federation/,api/]
17+
// This package is generated by client-gen with arguments: --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --included-types-overrides=[api/Service,api/Namespace] --input=[../../federation/apis/federation/,api/]
1818

1919
// Package fake has the automatically generated clients.
2020
package fake

federation/client/clientset_generated/federation_internalclientset/typed/core/unversioned/fake/fake_core_client.go

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ type FakeCore struct {
2626
*core.Fake
2727
}
2828

29+
func (c *FakeCore) Namespaces() unversioned.NamespaceInterface {
30+
return &FakeNamespaces{c}
31+
}
32+
2933
func (c *FakeCore) Services(namespace string) unversioned.ServiceInterface {
3034
return &FakeServices{c, namespace}
3135
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
Copyright 2016 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package fake
18+
19+
import (
20+
api "k8s.io/kubernetes/pkg/api"
21+
unversioned "k8s.io/kubernetes/pkg/api/unversioned"
22+
core "k8s.io/kubernetes/pkg/client/testing/core"
23+
labels "k8s.io/kubernetes/pkg/labels"
24+
watch "k8s.io/kubernetes/pkg/watch"
25+
)
26+
27+
// FakeNamespaces implements NamespaceInterface
28+
type FakeNamespaces struct {
29+
Fake *FakeCore
30+
}
31+
32+
var namespacesResource = unversioned.GroupVersionResource{Group: "", Version: "", Resource: "namespaces"}
33+
34+
func (c *FakeNamespaces) Create(namespace *api.Namespace) (result *api.Namespace, err error) {
35+
obj, err := c.Fake.
36+
Invokes(core.NewRootCreateAction(namespacesResource, namespace), &api.Namespace{})
37+
if obj == nil {
38+
return nil, err
39+
}
40+
return obj.(*api.Namespace), err
41+
}
42+
43+
func (c *FakeNamespaces) Update(namespace *api.Namespace) (result *api.Namespace, err error) {
44+
obj, err := c.Fake.
45+
Invokes(core.NewRootUpdateAction(namespacesResource, namespace), &api.Namespace{})
46+
if obj == nil {
47+
return nil, err
48+
}
49+
return obj.(*api.Namespace), err
50+
}
51+
52+
func (c *FakeNamespaces) UpdateStatus(namespace *api.Namespace) (*api.Namespace, error) {
53+
obj, err := c.Fake.
54+
Invokes(core.NewRootUpdateSubresourceAction(namespacesResource, "status", namespace), &api.Namespace{})
55+
if obj == nil {
56+
return nil, err
57+
}
58+
return obj.(*api.Namespace), err
59+
}
60+
61+
func (c *FakeNamespaces) Delete(name string, options *api.DeleteOptions) error {
62+
_, err := c.Fake.
63+
Invokes(core.NewRootDeleteAction(namespacesResource, name), &api.Namespace{})
64+
return err
65+
}
66+
67+
func (c *FakeNamespaces) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
68+
action := core.NewRootDeleteCollectionAction(namespacesResource, listOptions)
69+
70+
_, err := c.Fake.Invokes(action, &api.NamespaceList{})
71+
return err
72+
}
73+
74+
func (c *FakeNamespaces) Get(name string) (result *api.Namespace, err error) {
75+
obj, err := c.Fake.
76+
Invokes(core.NewRootGetAction(namespacesResource, name), &api.Namespace{})
77+
if obj == nil {
78+
return nil, err
79+
}
80+
return obj.(*api.Namespace), err
81+
}
82+
83+
func (c *FakeNamespaces) List(opts api.ListOptions) (result *api.NamespaceList, err error) {
84+
obj, err := c.Fake.
85+
Invokes(core.NewRootListAction(namespacesResource, opts), &api.NamespaceList{})
86+
if obj == nil {
87+
return nil, err
88+
}
89+
90+
label := opts.LabelSelector
91+
if label == nil {
92+
label = labels.Everything()
93+
}
94+
list := &api.NamespaceList{}
95+
for _, item := range obj.(*api.NamespaceList).Items {
96+
if label.Matches(labels.Set(item.Labels)) {
97+
list.Items = append(list.Items, item)
98+
}
99+
}
100+
return list, err
101+
}
102+
103+
// Watch returns a watch.Interface that watches the requested namespaces.
104+
func (c *FakeNamespaces) Watch(opts api.ListOptions) (watch.Interface, error) {
105+
return c.Fake.
106+
InvokesWatch(core.NewRootWatchAction(namespacesResource, opts))
107+
}
108+
109+
// Patch applies the patch and returns the patched namespace.
110+
func (c *FakeNamespaces) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *api.Namespace, err error) {
111+
obj, err := c.Fake.
112+
Invokes(core.NewRootPatchSubresourceAction(namespacesResource, name, data, subresources...), &api.Namespace{})
113+
if obj == nil {
114+
return nil, err
115+
}
116+
return obj.(*api.Namespace), err
117+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright 2016 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package fake
18+
19+
import (
20+
"k8s.io/kubernetes/pkg/api"
21+
"k8s.io/kubernetes/pkg/client/testing/core"
22+
)
23+
24+
func (c *FakeNamespaces) Finalize(namespace *api.Namespace) (*api.Namespace, error) {
25+
action := core.CreateActionImpl{}
26+
action.Verb = "create"
27+
action.Resource = namespacesResource
28+
action.Subresource = "finalize"
29+
action.Object = namespace
30+
31+
obj, err := c.Fake.Invokes(action, namespace)
32+
if obj == nil {
33+
return nil, err
34+
}
35+
36+
return obj.(*api.Namespace), err
37+
}

0 commit comments

Comments
 (0)