add federatednamespaces tenant API

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2020-07-20 17:12:48 +08:00
parent 8241a0f9c5
commit 3525fc5507
30 changed files with 1374 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ import (
storagev1alpha1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/storage/v1alpha1"
tenantv1alpha1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/tenant/v1alpha1"
tenantv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/tenant/v1alpha2"
typesv1beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/types/v1beta1"
)
type Interface interface {
@@ -48,6 +49,7 @@ type Interface interface {
StorageV1alpha1() storagev1alpha1.StorageV1alpha1Interface
TenantV1alpha1() tenantv1alpha1.TenantV1alpha1Interface
TenantV1alpha2() tenantv1alpha2.TenantV1alpha2Interface
TypesV1beta1() typesv1beta1.TypesV1beta1Interface
}
// Clientset contains the clients for groups. Each group has exactly one
@@ -64,6 +66,7 @@ type Clientset struct {
storageV1alpha1 *storagev1alpha1.StorageV1alpha1Client
tenantV1alpha1 *tenantv1alpha1.TenantV1alpha1Client
tenantV1alpha2 *tenantv1alpha2.TenantV1alpha2Client
typesV1beta1 *typesv1beta1.TypesV1beta1Client
}
// AuditingV1alpha1 retrieves the AuditingV1alpha1Client
@@ -116,6 +119,11 @@ func (c *Clientset) TenantV1alpha2() tenantv1alpha2.TenantV1alpha2Interface {
return c.tenantV1alpha2
}
// TypesV1beta1 retrieves the TypesV1beta1Client
func (c *Clientset) TypesV1beta1() typesv1beta1.TypesV1beta1Interface {
return c.typesV1beta1
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {
@@ -177,6 +185,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
if err != nil {
return nil, err
}
cs.typesV1beta1, err = typesv1beta1.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
@@ -199,6 +211,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
cs.storageV1alpha1 = storagev1alpha1.NewForConfigOrDie(c)
cs.tenantV1alpha1 = tenantv1alpha1.NewForConfigOrDie(c)
cs.tenantV1alpha2 = tenantv1alpha2.NewForConfigOrDie(c)
cs.typesV1beta1 = typesv1beta1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
@@ -217,6 +230,7 @@ func New(c rest.Interface) *Clientset {
cs.storageV1alpha1 = storagev1alpha1.New(c)
cs.tenantV1alpha1 = tenantv1alpha1.New(c)
cs.tenantV1alpha2 = tenantv1alpha2.New(c)
cs.typesV1beta1 = typesv1beta1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs

View File

@@ -45,6 +45,8 @@ import (
faketenantv1alpha1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/tenant/v1alpha1/fake"
tenantv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/tenant/v1alpha2"
faketenantv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/tenant/v1alpha2/fake"
typesv1beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/types/v1beta1"
faketypesv1beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/types/v1beta1/fake"
)
// NewSimpleClientset returns a clientset that will respond with the provided objects.
@@ -143,3 +145,8 @@ func (c *Clientset) TenantV1alpha1() tenantv1alpha1.TenantV1alpha1Interface {
func (c *Clientset) TenantV1alpha2() tenantv1alpha2.TenantV1alpha2Interface {
return &faketenantv1alpha2.FakeTenantV1alpha2{Fake: &c.Fake}
}
// TypesV1beta1 retrieves the TypesV1beta1Client
func (c *Clientset) TypesV1beta1() typesv1beta1.TypesV1beta1Interface {
return &faketypesv1beta1.FakeTypesV1beta1{Fake: &c.Fake}
}

View File

@@ -34,6 +34,7 @@ import (
storagev1alpha1 "kubesphere.io/kubesphere/pkg/apis/storage/v1alpha1"
tenantv1alpha1 "kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha1"
tenantv1alpha2 "kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha2"
typesv1beta1 "kubesphere.io/kubesphere/pkg/apis/types/v1beta1"
)
var scheme = runtime.NewScheme()
@@ -50,6 +51,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
storagev1alpha1.AddToScheme,
tenantv1alpha1.AddToScheme,
tenantv1alpha2.AddToScheme,
typesv1beta1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition

View File

@@ -34,6 +34,7 @@ import (
storagev1alpha1 "kubesphere.io/kubesphere/pkg/apis/storage/v1alpha1"
tenantv1alpha1 "kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha1"
tenantv1alpha2 "kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha2"
typesv1beta1 "kubesphere.io/kubesphere/pkg/apis/types/v1beta1"
)
var Scheme = runtime.NewScheme()
@@ -50,6 +51,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
storagev1alpha1.AddToScheme,
tenantv1alpha1.AddToScheme,
tenantv1alpha2.AddToScheme,
typesv1beta1.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition

View File

@@ -0,0 +1,20 @@
/*
Copyright 2020 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated typed clients.
package v1beta1

View File

@@ -0,0 +1,20 @@
/*
Copyright 2020 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// Package fake has the automatically generated clients.
package fake

View File

@@ -0,0 +1,120 @@
/*
Copyright 2020 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
v1beta1 "kubesphere.io/kubesphere/pkg/apis/types/v1beta1"
)
// FakeFederatedNamespaces implements FederatedNamespaceInterface
type FakeFederatedNamespaces struct {
Fake *FakeTypesV1beta1
}
var federatednamespacesResource = schema.GroupVersionResource{Group: "types.kubefed.io", Version: "v1beta1", Resource: "federatednamespaces"}
var federatednamespacesKind = schema.GroupVersionKind{Group: "types.kubefed.io", Version: "v1beta1", Kind: "FederatedNamespace"}
// Get takes name of the federatedNamespace, and returns the corresponding federatedNamespace object, and an error if there is any.
func (c *FakeFederatedNamespaces) Get(name string, options v1.GetOptions) (result *v1beta1.FederatedNamespace, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(federatednamespacesResource, name), &v1beta1.FederatedNamespace{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.FederatedNamespace), err
}
// List takes label and field selectors, and returns the list of FederatedNamespaces that match those selectors.
func (c *FakeFederatedNamespaces) List(opts v1.ListOptions) (result *v1beta1.FederatedNamespaceList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(federatednamespacesResource, federatednamespacesKind, opts), &v1beta1.FederatedNamespaceList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1beta1.FederatedNamespaceList{ListMeta: obj.(*v1beta1.FederatedNamespaceList).ListMeta}
for _, item := range obj.(*v1beta1.FederatedNamespaceList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested federatedNamespaces.
func (c *FakeFederatedNamespaces) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(federatednamespacesResource, opts))
}
// Create takes the representation of a federatedNamespace and creates it. Returns the server's representation of the federatedNamespace, and an error, if there is any.
func (c *FakeFederatedNamespaces) Create(federatedNamespace *v1beta1.FederatedNamespace) (result *v1beta1.FederatedNamespace, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(federatednamespacesResource, federatedNamespace), &v1beta1.FederatedNamespace{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.FederatedNamespace), err
}
// Update takes the representation of a federatedNamespace and updates it. Returns the server's representation of the federatedNamespace, and an error, if there is any.
func (c *FakeFederatedNamespaces) Update(federatedNamespace *v1beta1.FederatedNamespace) (result *v1beta1.FederatedNamespace, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(federatednamespacesResource, federatedNamespace), &v1beta1.FederatedNamespace{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.FederatedNamespace), err
}
// Delete takes name of the federatedNamespace and deletes it. Returns an error if one occurs.
func (c *FakeFederatedNamespaces) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(federatednamespacesResource, name), &v1beta1.FederatedNamespace{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeFederatedNamespaces) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(federatednamespacesResource, listOptions)
_, err := c.Fake.Invokes(action, &v1beta1.FederatedNamespaceList{})
return err
}
// Patch applies the patch and returns the patched federatedNamespace.
func (c *FakeFederatedNamespaces) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.FederatedNamespace, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(federatednamespacesResource, name, pt, data, subresources...), &v1beta1.FederatedNamespace{})
if obj == nil {
return nil, err
}
return obj.(*v1beta1.FederatedNamespace), err
}

View File

@@ -0,0 +1,40 @@
/*
Copyright 2020 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
v1beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/types/v1beta1"
)
type FakeTypesV1beta1 struct {
*testing.Fake
}
func (c *FakeTypesV1beta1) FederatedNamespaces() v1beta1.FederatedNamespaceInterface {
return &FakeFederatedNamespaces{c}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeTypesV1beta1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View File

@@ -0,0 +1,164 @@
/*
Copyright 2020 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1beta1
import (
"time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
v1beta1 "kubesphere.io/kubesphere/pkg/apis/types/v1beta1"
scheme "kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme"
)
// FederatedNamespacesGetter has a method to return a FederatedNamespaceInterface.
// A group's client should implement this interface.
type FederatedNamespacesGetter interface {
FederatedNamespaces() FederatedNamespaceInterface
}
// FederatedNamespaceInterface has methods to work with FederatedNamespace resources.
type FederatedNamespaceInterface interface {
Create(*v1beta1.FederatedNamespace) (*v1beta1.FederatedNamespace, error)
Update(*v1beta1.FederatedNamespace) (*v1beta1.FederatedNamespace, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*v1beta1.FederatedNamespace, error)
List(opts v1.ListOptions) (*v1beta1.FederatedNamespaceList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.FederatedNamespace, err error)
FederatedNamespaceExpansion
}
// federatedNamespaces implements FederatedNamespaceInterface
type federatedNamespaces struct {
client rest.Interface
}
// newFederatedNamespaces returns a FederatedNamespaces
func newFederatedNamespaces(c *TypesV1beta1Client) *federatedNamespaces {
return &federatedNamespaces{
client: c.RESTClient(),
}
}
// Get takes name of the federatedNamespace, and returns the corresponding federatedNamespace object, and an error if there is any.
func (c *federatedNamespaces) Get(name string, options v1.GetOptions) (result *v1beta1.FederatedNamespace, err error) {
result = &v1beta1.FederatedNamespace{}
err = c.client.Get().
Resource("federatednamespaces").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of FederatedNamespaces that match those selectors.
func (c *federatedNamespaces) List(opts v1.ListOptions) (result *v1beta1.FederatedNamespaceList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1beta1.FederatedNamespaceList{}
err = c.client.Get().
Resource("federatednamespaces").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested federatedNamespaces.
func (c *federatedNamespaces) Watch(opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Resource("federatednamespaces").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
// Create takes the representation of a federatedNamespace and creates it. Returns the server's representation of the federatedNamespace, and an error, if there is any.
func (c *federatedNamespaces) Create(federatedNamespace *v1beta1.FederatedNamespace) (result *v1beta1.FederatedNamespace, err error) {
result = &v1beta1.FederatedNamespace{}
err = c.client.Post().
Resource("federatednamespaces").
Body(federatedNamespace).
Do().
Into(result)
return
}
// Update takes the representation of a federatedNamespace and updates it. Returns the server's representation of the federatedNamespace, and an error, if there is any.
func (c *federatedNamespaces) Update(federatedNamespace *v1beta1.FederatedNamespace) (result *v1beta1.FederatedNamespace, err error) {
result = &v1beta1.FederatedNamespace{}
err = c.client.Put().
Resource("federatednamespaces").
Name(federatedNamespace.Name).
Body(federatedNamespace).
Do().
Into(result)
return
}
// Delete takes name of the federatedNamespace and deletes it. Returns an error if one occurs.
func (c *federatedNamespaces) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Resource("federatednamespaces").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *federatedNamespaces) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Resource("federatednamespaces").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched federatedNamespace.
func (c *federatedNamespaces) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.FederatedNamespace, err error) {
result = &v1beta1.FederatedNamespace{}
err = c.client.Patch(pt).
Resource("federatednamespaces").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View File

@@ -0,0 +1,21 @@
/*
Copyright 2020 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1beta1
type FederatedNamespaceExpansion interface{}

View File

@@ -0,0 +1,89 @@
/*
Copyright 2020 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1beta1
import (
rest "k8s.io/client-go/rest"
v1beta1 "kubesphere.io/kubesphere/pkg/apis/types/v1beta1"
"kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme"
)
type TypesV1beta1Interface interface {
RESTClient() rest.Interface
FederatedNamespacesGetter
}
// TypesV1beta1Client is used to interact with features provided by the types.kubefed.io group.
type TypesV1beta1Client struct {
restClient rest.Interface
}
func (c *TypesV1beta1Client) FederatedNamespaces() FederatedNamespaceInterface {
return newFederatedNamespaces(c)
}
// NewForConfig creates a new TypesV1beta1Client for the given config.
func NewForConfig(c *rest.Config) (*TypesV1beta1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &TypesV1beta1Client{client}, nil
}
// NewForConfigOrDie creates a new TypesV1beta1Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *TypesV1beta1Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new TypesV1beta1Client for the given RESTClient.
func New(c rest.Interface) *TypesV1beta1Client {
return &TypesV1beta1Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v1beta1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *TypesV1beta1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}