feat:group authorizetion. Add group and groupbinding crds, generated clientset

Signed-off-by: Roland.Ma <rolandma@yunify.com>
This commit is contained in:
Roland.Ma
2020-10-15 13:57:24 +00:00
parent 44799ae68a
commit 7c6723da46
23 changed files with 1404 additions and 0 deletions

View File

@@ -0,0 +1,131 @@
/*
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"
v1alpha2 "kubesphere.io/kubesphere/pkg/apis/iam/v1alpha2"
)
// FakeGroups implements GroupInterface
type FakeGroups struct {
Fake *FakeIamV1alpha2
}
var groupsResource = schema.GroupVersionResource{Group: "iam.kubesphere.io", Version: "v1alpha2", Resource: "groups"}
var groupsKind = schema.GroupVersionKind{Group: "iam.kubesphere.io", Version: "v1alpha2", Kind: "Group"}
// Get takes name of the group, and returns the corresponding group object, and an error if there is any.
func (c *FakeGroups) Get(name string, options v1.GetOptions) (result *v1alpha2.Group, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(groupsResource, name), &v1alpha2.Group{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.Group), err
}
// List takes label and field selectors, and returns the list of Groups that match those selectors.
func (c *FakeGroups) List(opts v1.ListOptions) (result *v1alpha2.GroupList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(groupsResource, groupsKind, opts), &v1alpha2.GroupList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha2.GroupList{ListMeta: obj.(*v1alpha2.GroupList).ListMeta}
for _, item := range obj.(*v1alpha2.GroupList).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 groups.
func (c *FakeGroups) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(groupsResource, opts))
}
// Create takes the representation of a group and creates it. Returns the server's representation of the group, and an error, if there is any.
func (c *FakeGroups) Create(group *v1alpha2.Group) (result *v1alpha2.Group, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(groupsResource, group), &v1alpha2.Group{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.Group), err
}
// Update takes the representation of a group and updates it. Returns the server's representation of the group, and an error, if there is any.
func (c *FakeGroups) Update(group *v1alpha2.Group) (result *v1alpha2.Group, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(groupsResource, group), &v1alpha2.Group{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.Group), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeGroups) UpdateStatus(group *v1alpha2.Group) (*v1alpha2.Group, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(groupsResource, "status", group), &v1alpha2.Group{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.Group), err
}
// Delete takes name of the group and deletes it. Returns an error if one occurs.
func (c *FakeGroups) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(groupsResource, name), &v1alpha2.Group{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeGroups) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(groupsResource, listOptions)
_, err := c.Fake.Invokes(action, &v1alpha2.GroupList{})
return err
}
// Patch applies the patch and returns the patched group.
func (c *FakeGroups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.Group, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(groupsResource, name, pt, data, subresources...), &v1alpha2.Group{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.Group), err
}

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"
v1alpha2 "kubesphere.io/kubesphere/pkg/apis/iam/v1alpha2"
)
// FakeGroupBindings implements GroupBindingInterface
type FakeGroupBindings struct {
Fake *FakeIamV1alpha2
}
var groupbindingsResource = schema.GroupVersionResource{Group: "iam.kubesphere.io", Version: "v1alpha2", Resource: "groupbindings"}
var groupbindingsKind = schema.GroupVersionKind{Group: "iam.kubesphere.io", Version: "v1alpha2", Kind: "GroupBinding"}
// Get takes name of the groupBinding, and returns the corresponding groupBinding object, and an error if there is any.
func (c *FakeGroupBindings) Get(name string, options v1.GetOptions) (result *v1alpha2.GroupBinding, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(groupbindingsResource, name), &v1alpha2.GroupBinding{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.GroupBinding), err
}
// List takes label and field selectors, and returns the list of GroupBindings that match those selectors.
func (c *FakeGroupBindings) List(opts v1.ListOptions) (result *v1alpha2.GroupBindingList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(groupbindingsResource, groupbindingsKind, opts), &v1alpha2.GroupBindingList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha2.GroupBindingList{ListMeta: obj.(*v1alpha2.GroupBindingList).ListMeta}
for _, item := range obj.(*v1alpha2.GroupBindingList).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 groupBindings.
func (c *FakeGroupBindings) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(groupbindingsResource, opts))
}
// Create takes the representation of a groupBinding and creates it. Returns the server's representation of the groupBinding, and an error, if there is any.
func (c *FakeGroupBindings) Create(groupBinding *v1alpha2.GroupBinding) (result *v1alpha2.GroupBinding, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(groupbindingsResource, groupBinding), &v1alpha2.GroupBinding{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.GroupBinding), err
}
// Update takes the representation of a groupBinding and updates it. Returns the server's representation of the groupBinding, and an error, if there is any.
func (c *FakeGroupBindings) Update(groupBinding *v1alpha2.GroupBinding) (result *v1alpha2.GroupBinding, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(groupbindingsResource, groupBinding), &v1alpha2.GroupBinding{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.GroupBinding), err
}
// Delete takes name of the groupBinding and deletes it. Returns an error if one occurs.
func (c *FakeGroupBindings) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(groupbindingsResource, name), &v1alpha2.GroupBinding{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeGroupBindings) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(groupbindingsResource, listOptions)
_, err := c.Fake.Invokes(action, &v1alpha2.GroupBindingList{})
return err
}
// Patch applies the patch and returns the patched groupBinding.
func (c *FakeGroupBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.GroupBinding, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(groupbindingsResource, name, pt, data, subresources...), &v1alpha2.GroupBinding{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.GroupBinding), err
}

View File

@@ -36,6 +36,14 @@ func (c *FakeIamV1alpha2) GlobalRoleBindings() v1alpha2.GlobalRoleBindingInterfa
return &FakeGlobalRoleBindings{c}
}
func (c *FakeIamV1alpha2) Groups() v1alpha2.GroupInterface {
return &FakeGroups{c}
}
func (c *FakeIamV1alpha2) GroupBindings() v1alpha2.GroupBindingInterface {
return &FakeGroupBindings{c}
}
func (c *FakeIamV1alpha2) LoginRecords() v1alpha2.LoginRecordInterface {
return &FakeLoginRecords{c}
}

View File

@@ -22,6 +22,10 @@ type GlobalRoleExpansion interface{}
type GlobalRoleBindingExpansion interface{}
type GroupExpansion interface{}
type GroupBindingExpansion interface{}
type LoginRecordExpansion interface{}
type RoleBaseExpansion interface{}

View File

@@ -0,0 +1,180 @@
/*
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 v1alpha2
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"
v1alpha2 "kubesphere.io/kubesphere/pkg/apis/iam/v1alpha2"
scheme "kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme"
)
// GroupsGetter has a method to return a GroupInterface.
// A group's client should implement this interface.
type GroupsGetter interface {
Groups() GroupInterface
}
// GroupInterface has methods to work with Group resources.
type GroupInterface interface {
Create(*v1alpha2.Group) (*v1alpha2.Group, error)
Update(*v1alpha2.Group) (*v1alpha2.Group, error)
UpdateStatus(*v1alpha2.Group) (*v1alpha2.Group, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*v1alpha2.Group, error)
List(opts v1.ListOptions) (*v1alpha2.GroupList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.Group, err error)
GroupExpansion
}
// groups implements GroupInterface
type groups struct {
client rest.Interface
}
// newGroups returns a Groups
func newGroups(c *IamV1alpha2Client) *groups {
return &groups{
client: c.RESTClient(),
}
}
// Get takes name of the group, and returns the corresponding group object, and an error if there is any.
func (c *groups) Get(name string, options v1.GetOptions) (result *v1alpha2.Group, err error) {
result = &v1alpha2.Group{}
err = c.client.Get().
Resource("groups").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of Groups that match those selectors.
func (c *groups) List(opts v1.ListOptions) (result *v1alpha2.GroupList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha2.GroupList{}
err = c.client.Get().
Resource("groups").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested groups.
func (c *groups) 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("groups").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
// Create takes the representation of a group and creates it. Returns the server's representation of the group, and an error, if there is any.
func (c *groups) Create(group *v1alpha2.Group) (result *v1alpha2.Group, err error) {
result = &v1alpha2.Group{}
err = c.client.Post().
Resource("groups").
Body(group).
Do().
Into(result)
return
}
// Update takes the representation of a group and updates it. Returns the server's representation of the group, and an error, if there is any.
func (c *groups) Update(group *v1alpha2.Group) (result *v1alpha2.Group, err error) {
result = &v1alpha2.Group{}
err = c.client.Put().
Resource("groups").
Name(group.Name).
Body(group).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *groups) UpdateStatus(group *v1alpha2.Group) (result *v1alpha2.Group, err error) {
result = &v1alpha2.Group{}
err = c.client.Put().
Resource("groups").
Name(group.Name).
SubResource("status").
Body(group).
Do().
Into(result)
return
}
// Delete takes name of the group and deletes it. Returns an error if one occurs.
func (c *groups) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Resource("groups").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *groups) 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("groups").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched group.
func (c *groups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.Group, err error) {
result = &v1alpha2.Group{}
err = c.client.Patch(pt).
Resource("groups").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

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 v1alpha2
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"
v1alpha2 "kubesphere.io/kubesphere/pkg/apis/iam/v1alpha2"
scheme "kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme"
)
// GroupBindingsGetter has a method to return a GroupBindingInterface.
// A group's client should implement this interface.
type GroupBindingsGetter interface {
GroupBindings() GroupBindingInterface
}
// GroupBindingInterface has methods to work with GroupBinding resources.
type GroupBindingInterface interface {
Create(*v1alpha2.GroupBinding) (*v1alpha2.GroupBinding, error)
Update(*v1alpha2.GroupBinding) (*v1alpha2.GroupBinding, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*v1alpha2.GroupBinding, error)
List(opts v1.ListOptions) (*v1alpha2.GroupBindingList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.GroupBinding, err error)
GroupBindingExpansion
}
// groupBindings implements GroupBindingInterface
type groupBindings struct {
client rest.Interface
}
// newGroupBindings returns a GroupBindings
func newGroupBindings(c *IamV1alpha2Client) *groupBindings {
return &groupBindings{
client: c.RESTClient(),
}
}
// Get takes name of the groupBinding, and returns the corresponding groupBinding object, and an error if there is any.
func (c *groupBindings) Get(name string, options v1.GetOptions) (result *v1alpha2.GroupBinding, err error) {
result = &v1alpha2.GroupBinding{}
err = c.client.Get().
Resource("groupbindings").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of GroupBindings that match those selectors.
func (c *groupBindings) List(opts v1.ListOptions) (result *v1alpha2.GroupBindingList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha2.GroupBindingList{}
err = c.client.Get().
Resource("groupbindings").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested groupBindings.
func (c *groupBindings) 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("groupbindings").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
// Create takes the representation of a groupBinding and creates it. Returns the server's representation of the groupBinding, and an error, if there is any.
func (c *groupBindings) Create(groupBinding *v1alpha2.GroupBinding) (result *v1alpha2.GroupBinding, err error) {
result = &v1alpha2.GroupBinding{}
err = c.client.Post().
Resource("groupbindings").
Body(groupBinding).
Do().
Into(result)
return
}
// Update takes the representation of a groupBinding and updates it. Returns the server's representation of the groupBinding, and an error, if there is any.
func (c *groupBindings) Update(groupBinding *v1alpha2.GroupBinding) (result *v1alpha2.GroupBinding, err error) {
result = &v1alpha2.GroupBinding{}
err = c.client.Put().
Resource("groupbindings").
Name(groupBinding.Name).
Body(groupBinding).
Do().
Into(result)
return
}
// Delete takes name of the groupBinding and deletes it. Returns an error if one occurs.
func (c *groupBindings) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Resource("groupbindings").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *groupBindings) 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("groupbindings").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched groupBinding.
func (c *groupBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.GroupBinding, err error) {
result = &v1alpha2.GroupBinding{}
err = c.client.Patch(pt).
Resource("groupbindings").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View File

@@ -28,6 +28,8 @@ type IamV1alpha2Interface interface {
RESTClient() rest.Interface
GlobalRolesGetter
GlobalRoleBindingsGetter
GroupsGetter
GroupBindingsGetter
LoginRecordsGetter
RoleBasesGetter
UsersGetter
@@ -48,6 +50,14 @@ func (c *IamV1alpha2Client) GlobalRoleBindings() GlobalRoleBindingInterface {
return newGlobalRoleBindings(c)
}
func (c *IamV1alpha2Client) Groups() GroupInterface {
return newGroups(c)
}
func (c *IamV1alpha2Client) GroupBindings() GroupBindingInterface {
return newGroupBindings(c)
}
func (c *IamV1alpha2Client) LoginRecords() LoginRecordInterface {
return newLoginRecords(c)
}