mirror of
https://github.com/rancher/types.git
synced 2025-08-31 12:48:45 +00:00
Changes to authn types
This commit is contained in:
committed by
Darren Shepherd
parent
2fc465d61c
commit
446c7ae47b
@@ -8,52 +8,45 @@ type Token struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
TokenID string `json:"tokenID,omitempty"`
|
||||
TokenValue string `json:"tokenValue,omitempty"`
|
||||
User string `json:"user,omitempty"`
|
||||
ExternalID string `json:"externalID,omitempty"`
|
||||
AuthProvider string `json:"authProvider,omitempty"`
|
||||
TTLMillis string `json:"ttl,omitempty"`
|
||||
RefreshTTLMillis string `json:"refreshTTL,omitempty"`
|
||||
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
|
||||
IsDerived bool `json:"isDerived,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
TokenID string `json:"tokenId,omitempty"`
|
||||
TokenValue string `json:"tokenValue,omitempty"`
|
||||
User string `json:"user,omitempty"`
|
||||
ExternalID string `json:"externalId,omitempty"`
|
||||
AuthProvider string `json:"authProvider,omitempty"`
|
||||
TTLMillis string `json:"ttl,omitempty"`
|
||||
IdentityRefreshTTLMillis string `json:"identityRefreshTTL,omitempty"`
|
||||
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
|
||||
IsDerived bool `json:"isDerived,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
UserName string `json:"userName,omitempty"`
|
||||
Secret string `json:"secret,omitempty"`
|
||||
DisplayName string `json:"displayName,omitempty"`
|
||||
ExternalID string `json:"externalID,omitempty"`
|
||||
Secret string `json:"secret,omitempty"`
|
||||
ExternalID string `json:"externalId,omitempty"`
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
GroupName string `json:"groupName,omitempty"`
|
||||
DisplayName string `json:"displayName,omitempty"`
|
||||
ExternalID string `json:"externalID,omitempty"`
|
||||
}
|
||||
|
||||
type GroupMember struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
GroupExternalID string `json:"groupExternalID,omitempty"`
|
||||
MemberExternalID string `json:"memberExternalID,omitempty"`
|
||||
GroupName string `json:"groupName,omitempty" norman:"type=reference[/v3/schemas/group]"`
|
||||
ExternalID string `json:"externalId,omitempty"`
|
||||
}
|
||||
|
||||
type Identity struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
ExternalID string `json:"externalID,omitempty"`
|
||||
DisplayName string `json:"displayName,omitempty"`
|
||||
IdentityName string `json:"identityName,omitempty"`
|
||||
LoginName string `json:"loginName,omitempty"`
|
||||
ProfilePicture string `json:"profilePicture,omitempty"`
|
||||
ProfileURL string `json:"profileURL,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
@@ -61,3 +54,33 @@ type Identity struct {
|
||||
MemberOf bool `json:"memberOf,omitempty"`
|
||||
ExtraInfo map[string]string `json:"extraInfo,omitempty"`
|
||||
}
|
||||
|
||||
//LoginInput structure defines all properties that can be sent by client to create a token
|
||||
type LoginInput struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
TTLMillis string `json:"ttl,omitempty"`
|
||||
IdentityRefreshTTLMillis string `json:"identityRefreshTTL,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ResponseType string `json:"responseType,omitempty"` //json or cookie
|
||||
LocalCredential LocalCredential `json:"localCredential, omitempty"`
|
||||
GithubCredential GithubCredential `json:"githubCredential, omitempty"`
|
||||
}
|
||||
|
||||
//LocalCredential stores the local auth creds
|
||||
type LocalCredential struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
//GithubCredential stores the github auth creds
|
||||
type GithubCredential struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
@@ -126,5 +126,8 @@ func authnTypes(schemas *types.Schemas) *types.Schemas {
|
||||
MustImport(&Version, v3.User{}).
|
||||
MustImport(&Version, v3.Group{}).
|
||||
MustImport(&Version, v3.GroupMember{}).
|
||||
MustImport(&Version, v3.Identity{})
|
||||
MustImport(&Version, v3.Identity{}).
|
||||
MustImport(&Version, v3.LoginInput{}).
|
||||
MustImport(&Version, v3.LocalCredential{}).
|
||||
MustImport(&Version, v3.GithubCredential{})
|
||||
}
|
||||
|
@@ -785,6 +785,67 @@ func (in *Filter) DeepCopy() *Filter {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GithubCredential) DeepCopyInto(out *GithubCredential) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GithubCredential.
|
||||
func (in *GithubCredential) DeepCopy() *GithubCredential {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GithubCredential)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *GithubCredential) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GithubCredentialList) DeepCopyInto(out *GithubCredentialList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]GithubCredential, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GithubCredentialList.
|
||||
func (in *GithubCredentialList) DeepCopy() *GithubCredentialList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GithubCredentialList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *GithubCredentialList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GoogleKubernetesEngineConfig) DeepCopyInto(out *GoogleKubernetesEngineConfig) {
|
||||
*out = *in
|
||||
@@ -1094,6 +1155,130 @@ func (in *ListOpts) DeepCopy() *ListOpts {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LocalCredential) DeepCopyInto(out *LocalCredential) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LocalCredential.
|
||||
func (in *LocalCredential) DeepCopy() *LocalCredential {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(LocalCredential)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *LocalCredential) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LocalCredentialList) DeepCopyInto(out *LocalCredentialList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]LocalCredential, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LocalCredentialList.
|
||||
func (in *LocalCredentialList) DeepCopy() *LocalCredentialList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(LocalCredentialList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *LocalCredentialList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LoginInput) DeepCopyInto(out *LoginInput) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.LocalCredential.DeepCopyInto(&out.LocalCredential)
|
||||
in.GithubCredential.DeepCopyInto(&out.GithubCredential)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoginInput.
|
||||
func (in *LoginInput) DeepCopy() *LoginInput {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(LoginInput)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *LoginInput) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LoginInputList) DeepCopyInto(out *LoginInputList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]LoginInput, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoginInputList.
|
||||
func (in *LoginInputList) DeepCopy() *LoginInputList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(LoginInputList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *LoginInputList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Machine) DeepCopyInto(out *Machine) {
|
||||
*out = *in
|
||||
|
@@ -0,0 +1,193 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rancher/norman/clientbase"
|
||||
"github.com/rancher/norman/controller"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
var (
|
||||
GithubCredentialGroupVersionKind = schema.GroupVersionKind{
|
||||
Version: "v3",
|
||||
Group: "management.cattle.io",
|
||||
Kind: "GithubCredential",
|
||||
}
|
||||
GithubCredentialResource = metav1.APIResource{
|
||||
Name: "githubcredentials",
|
||||
SingularName: "githubcredential",
|
||||
Namespaced: false,
|
||||
Kind: GithubCredentialGroupVersionKind.Kind,
|
||||
}
|
||||
)
|
||||
|
||||
type GithubCredentialList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []GithubCredential
|
||||
}
|
||||
|
||||
type GithubCredentialHandlerFunc func(key string, obj *GithubCredential) error
|
||||
|
||||
type GithubCredentialLister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*GithubCredential, err error)
|
||||
Get(namespace, name string) (*GithubCredential, error)
|
||||
}
|
||||
|
||||
type GithubCredentialController interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() GithubCredentialLister
|
||||
AddHandler(handler GithubCredentialHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
||||
type GithubCredentialInterface interface {
|
||||
ObjectClient() *clientbase.ObjectClient
|
||||
Create(*GithubCredential) (*GithubCredential, error)
|
||||
Get(name string, opts metav1.GetOptions) (*GithubCredential, error)
|
||||
Update(*GithubCredential) (*GithubCredential, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*GithubCredentialList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
Controller() GithubCredentialController
|
||||
}
|
||||
|
||||
type githubCredentialLister struct {
|
||||
controller *githubCredentialController
|
||||
}
|
||||
|
||||
func (l *githubCredentialLister) List(namespace string, selector labels.Selector) (ret []*GithubCredential, err error) {
|
||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||
ret = append(ret, obj.(*GithubCredential))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (l *githubCredentialLister) Get(namespace, name string) (*GithubCredential, error) {
|
||||
var key string
|
||||
if namespace != "" {
|
||||
key = namespace + "/" + name
|
||||
} else {
|
||||
key = name
|
||||
}
|
||||
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(schema.GroupResource{
|
||||
Group: GithubCredentialGroupVersionKind.Group,
|
||||
Resource: "githubCredential",
|
||||
}, name)
|
||||
}
|
||||
return obj.(*GithubCredential), nil
|
||||
}
|
||||
|
||||
type githubCredentialController struct {
|
||||
controller.GenericController
|
||||
}
|
||||
|
||||
func (c *githubCredentialController) Lister() GithubCredentialLister {
|
||||
return &githubCredentialLister{
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *githubCredentialController) AddHandler(handler GithubCredentialHandlerFunc) {
|
||||
c.GenericController.AddHandler(func(key string) error {
|
||||
obj, exists, err := c.Informer().GetStore().GetByKey(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
return handler(key, nil)
|
||||
}
|
||||
return handler(key, obj.(*GithubCredential))
|
||||
})
|
||||
}
|
||||
|
||||
type githubCredentialFactory struct {
|
||||
}
|
||||
|
||||
func (c githubCredentialFactory) Object() runtime.Object {
|
||||
return &GithubCredential{}
|
||||
}
|
||||
|
||||
func (c githubCredentialFactory) List() runtime.Object {
|
||||
return &GithubCredentialList{}
|
||||
}
|
||||
|
||||
func (s *githubCredentialClient) Controller() GithubCredentialController {
|
||||
s.client.Lock()
|
||||
defer s.client.Unlock()
|
||||
|
||||
c, ok := s.client.githubCredentialControllers[s.ns]
|
||||
if ok {
|
||||
return c
|
||||
}
|
||||
|
||||
genericController := controller.NewGenericController(GithubCredentialGroupVersionKind.Kind+"Controller",
|
||||
s.objectClient)
|
||||
|
||||
c = &githubCredentialController{
|
||||
GenericController: genericController,
|
||||
}
|
||||
|
||||
s.client.githubCredentialControllers[s.ns] = c
|
||||
s.client.starters = append(s.client.starters, c)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
type githubCredentialClient struct {
|
||||
client *Client
|
||||
ns string
|
||||
objectClient *clientbase.ObjectClient
|
||||
controller GithubCredentialController
|
||||
}
|
||||
|
||||
func (s *githubCredentialClient) ObjectClient() *clientbase.ObjectClient {
|
||||
return s.objectClient
|
||||
}
|
||||
|
||||
func (s *githubCredentialClient) Create(o *GithubCredential) (*GithubCredential, error) {
|
||||
obj, err := s.objectClient.Create(o)
|
||||
return obj.(*GithubCredential), err
|
||||
}
|
||||
|
||||
func (s *githubCredentialClient) Get(name string, opts metav1.GetOptions) (*GithubCredential, error) {
|
||||
obj, err := s.objectClient.Get(name, opts)
|
||||
return obj.(*GithubCredential), err
|
||||
}
|
||||
|
||||
func (s *githubCredentialClient) Update(o *GithubCredential) (*GithubCredential, error) {
|
||||
obj, err := s.objectClient.Update(o.Name, o)
|
||||
return obj.(*GithubCredential), err
|
||||
}
|
||||
|
||||
func (s *githubCredentialClient) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.Delete(name, options)
|
||||
}
|
||||
|
||||
func (s *githubCredentialClient) List(opts metav1.ListOptions) (*GithubCredentialList, error) {
|
||||
obj, err := s.objectClient.List(opts)
|
||||
return obj.(*GithubCredentialList), err
|
||||
}
|
||||
|
||||
func (s *githubCredentialClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return s.objectClient.Watch(opts)
|
||||
}
|
||||
|
||||
func (s *githubCredentialClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type GithubCredentialLifecycle interface {
|
||||
Create(obj *GithubCredential) error
|
||||
Remove(obj *GithubCredential) error
|
||||
Updated(obj *GithubCredential) error
|
||||
}
|
||||
|
||||
type githubCredentialLifecycleAdapter struct {
|
||||
lifecycle GithubCredentialLifecycle
|
||||
}
|
||||
|
||||
func (w *githubCredentialLifecycleAdapter) Create(obj runtime.Object) error {
|
||||
return w.lifecycle.Create(obj.(*GithubCredential))
|
||||
}
|
||||
|
||||
func (w *githubCredentialLifecycleAdapter) Finalize(obj runtime.Object) error {
|
||||
return w.lifecycle.Remove(obj.(*GithubCredential))
|
||||
}
|
||||
|
||||
func (w *githubCredentialLifecycleAdapter) Updated(obj runtime.Object) error {
|
||||
return w.lifecycle.Updated(obj.(*GithubCredential))
|
||||
}
|
||||
|
||||
func NewGithubCredentialLifecycleAdapter(name string, client GithubCredentialInterface, l GithubCredentialLifecycle) GithubCredentialHandlerFunc {
|
||||
adapter := &githubCredentialLifecycleAdapter{lifecycle: l}
|
||||
syncFn := lifecycle.NewObjectLifecycleAdapter(name, adapter, client.ObjectClient())
|
||||
return func(key string, obj *GithubCredential) error {
|
||||
if obj == nil {
|
||||
return syncFn(key, nil)
|
||||
}
|
||||
return syncFn(key, obj)
|
||||
}
|
||||
}
|
@@ -32,6 +32,9 @@ type Interface interface {
|
||||
GroupsGetter
|
||||
GroupMembersGetter
|
||||
IdentitiesGetter
|
||||
LocalCredentialsGetter
|
||||
GithubCredentialsGetter
|
||||
LoginInputsGetter
|
||||
DynamicSchemasGetter
|
||||
}
|
||||
|
||||
@@ -58,6 +61,9 @@ type Client struct {
|
||||
groupControllers map[string]GroupController
|
||||
groupMemberControllers map[string]GroupMemberController
|
||||
identityControllers map[string]IdentityController
|
||||
localCredentialControllers map[string]LocalCredentialController
|
||||
githubCredentialControllers map[string]GithubCredentialController
|
||||
loginInputControllers map[string]LoginInputController
|
||||
dynamicSchemaControllers map[string]DynamicSchemaController
|
||||
}
|
||||
|
||||
@@ -93,6 +99,9 @@ func NewForConfig(config rest.Config) (Interface, error) {
|
||||
groupControllers: map[string]GroupController{},
|
||||
groupMemberControllers: map[string]GroupMemberController{},
|
||||
identityControllers: map[string]IdentityController{},
|
||||
localCredentialControllers: map[string]LocalCredentialController{},
|
||||
githubCredentialControllers: map[string]GithubCredentialController{},
|
||||
loginInputControllers: map[string]LoginInputController{},
|
||||
dynamicSchemaControllers: map[string]DynamicSchemaController{},
|
||||
}, nil
|
||||
}
|
||||
@@ -343,6 +352,45 @@ func (c *Client) Identities(namespace string) IdentityInterface {
|
||||
}
|
||||
}
|
||||
|
||||
type LocalCredentialsGetter interface {
|
||||
LocalCredentials(namespace string) LocalCredentialInterface
|
||||
}
|
||||
|
||||
func (c *Client) LocalCredentials(namespace string) LocalCredentialInterface {
|
||||
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &LocalCredentialResource, LocalCredentialGroupVersionKind, localCredentialFactory{})
|
||||
return &localCredentialClient{
|
||||
ns: namespace,
|
||||
client: c,
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
||||
|
||||
type GithubCredentialsGetter interface {
|
||||
GithubCredentials(namespace string) GithubCredentialInterface
|
||||
}
|
||||
|
||||
func (c *Client) GithubCredentials(namespace string) GithubCredentialInterface {
|
||||
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &GithubCredentialResource, GithubCredentialGroupVersionKind, githubCredentialFactory{})
|
||||
return &githubCredentialClient{
|
||||
ns: namespace,
|
||||
client: c,
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
||||
|
||||
type LoginInputsGetter interface {
|
||||
LoginInputs(namespace string) LoginInputInterface
|
||||
}
|
||||
|
||||
func (c *Client) LoginInputs(namespace string) LoginInputInterface {
|
||||
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &LoginInputResource, LoginInputGroupVersionKind, loginInputFactory{})
|
||||
return &loginInputClient{
|
||||
ns: namespace,
|
||||
client: c,
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
||||
|
||||
type DynamicSchemasGetter interface {
|
||||
DynamicSchemas(namespace string) DynamicSchemaInterface
|
||||
}
|
||||
|
@@ -0,0 +1,193 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rancher/norman/clientbase"
|
||||
"github.com/rancher/norman/controller"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
var (
|
||||
LocalCredentialGroupVersionKind = schema.GroupVersionKind{
|
||||
Version: "v3",
|
||||
Group: "management.cattle.io",
|
||||
Kind: "LocalCredential",
|
||||
}
|
||||
LocalCredentialResource = metav1.APIResource{
|
||||
Name: "localcredentials",
|
||||
SingularName: "localcredential",
|
||||
Namespaced: false,
|
||||
Kind: LocalCredentialGroupVersionKind.Kind,
|
||||
}
|
||||
)
|
||||
|
||||
type LocalCredentialList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []LocalCredential
|
||||
}
|
||||
|
||||
type LocalCredentialHandlerFunc func(key string, obj *LocalCredential) error
|
||||
|
||||
type LocalCredentialLister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*LocalCredential, err error)
|
||||
Get(namespace, name string) (*LocalCredential, error)
|
||||
}
|
||||
|
||||
type LocalCredentialController interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() LocalCredentialLister
|
||||
AddHandler(handler LocalCredentialHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
||||
type LocalCredentialInterface interface {
|
||||
ObjectClient() *clientbase.ObjectClient
|
||||
Create(*LocalCredential) (*LocalCredential, error)
|
||||
Get(name string, opts metav1.GetOptions) (*LocalCredential, error)
|
||||
Update(*LocalCredential) (*LocalCredential, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*LocalCredentialList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
Controller() LocalCredentialController
|
||||
}
|
||||
|
||||
type localCredentialLister struct {
|
||||
controller *localCredentialController
|
||||
}
|
||||
|
||||
func (l *localCredentialLister) List(namespace string, selector labels.Selector) (ret []*LocalCredential, err error) {
|
||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||
ret = append(ret, obj.(*LocalCredential))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (l *localCredentialLister) Get(namespace, name string) (*LocalCredential, error) {
|
||||
var key string
|
||||
if namespace != "" {
|
||||
key = namespace + "/" + name
|
||||
} else {
|
||||
key = name
|
||||
}
|
||||
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(schema.GroupResource{
|
||||
Group: LocalCredentialGroupVersionKind.Group,
|
||||
Resource: "localCredential",
|
||||
}, name)
|
||||
}
|
||||
return obj.(*LocalCredential), nil
|
||||
}
|
||||
|
||||
type localCredentialController struct {
|
||||
controller.GenericController
|
||||
}
|
||||
|
||||
func (c *localCredentialController) Lister() LocalCredentialLister {
|
||||
return &localCredentialLister{
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *localCredentialController) AddHandler(handler LocalCredentialHandlerFunc) {
|
||||
c.GenericController.AddHandler(func(key string) error {
|
||||
obj, exists, err := c.Informer().GetStore().GetByKey(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
return handler(key, nil)
|
||||
}
|
||||
return handler(key, obj.(*LocalCredential))
|
||||
})
|
||||
}
|
||||
|
||||
type localCredentialFactory struct {
|
||||
}
|
||||
|
||||
func (c localCredentialFactory) Object() runtime.Object {
|
||||
return &LocalCredential{}
|
||||
}
|
||||
|
||||
func (c localCredentialFactory) List() runtime.Object {
|
||||
return &LocalCredentialList{}
|
||||
}
|
||||
|
||||
func (s *localCredentialClient) Controller() LocalCredentialController {
|
||||
s.client.Lock()
|
||||
defer s.client.Unlock()
|
||||
|
||||
c, ok := s.client.localCredentialControllers[s.ns]
|
||||
if ok {
|
||||
return c
|
||||
}
|
||||
|
||||
genericController := controller.NewGenericController(LocalCredentialGroupVersionKind.Kind+"Controller",
|
||||
s.objectClient)
|
||||
|
||||
c = &localCredentialController{
|
||||
GenericController: genericController,
|
||||
}
|
||||
|
||||
s.client.localCredentialControllers[s.ns] = c
|
||||
s.client.starters = append(s.client.starters, c)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
type localCredentialClient struct {
|
||||
client *Client
|
||||
ns string
|
||||
objectClient *clientbase.ObjectClient
|
||||
controller LocalCredentialController
|
||||
}
|
||||
|
||||
func (s *localCredentialClient) ObjectClient() *clientbase.ObjectClient {
|
||||
return s.objectClient
|
||||
}
|
||||
|
||||
func (s *localCredentialClient) Create(o *LocalCredential) (*LocalCredential, error) {
|
||||
obj, err := s.objectClient.Create(o)
|
||||
return obj.(*LocalCredential), err
|
||||
}
|
||||
|
||||
func (s *localCredentialClient) Get(name string, opts metav1.GetOptions) (*LocalCredential, error) {
|
||||
obj, err := s.objectClient.Get(name, opts)
|
||||
return obj.(*LocalCredential), err
|
||||
}
|
||||
|
||||
func (s *localCredentialClient) Update(o *LocalCredential) (*LocalCredential, error) {
|
||||
obj, err := s.objectClient.Update(o.Name, o)
|
||||
return obj.(*LocalCredential), err
|
||||
}
|
||||
|
||||
func (s *localCredentialClient) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.Delete(name, options)
|
||||
}
|
||||
|
||||
func (s *localCredentialClient) List(opts metav1.ListOptions) (*LocalCredentialList, error) {
|
||||
obj, err := s.objectClient.List(opts)
|
||||
return obj.(*LocalCredentialList), err
|
||||
}
|
||||
|
||||
func (s *localCredentialClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return s.objectClient.Watch(opts)
|
||||
}
|
||||
|
||||
func (s *localCredentialClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type LocalCredentialLifecycle interface {
|
||||
Create(obj *LocalCredential) error
|
||||
Remove(obj *LocalCredential) error
|
||||
Updated(obj *LocalCredential) error
|
||||
}
|
||||
|
||||
type localCredentialLifecycleAdapter struct {
|
||||
lifecycle LocalCredentialLifecycle
|
||||
}
|
||||
|
||||
func (w *localCredentialLifecycleAdapter) Create(obj runtime.Object) error {
|
||||
return w.lifecycle.Create(obj.(*LocalCredential))
|
||||
}
|
||||
|
||||
func (w *localCredentialLifecycleAdapter) Finalize(obj runtime.Object) error {
|
||||
return w.lifecycle.Remove(obj.(*LocalCredential))
|
||||
}
|
||||
|
||||
func (w *localCredentialLifecycleAdapter) Updated(obj runtime.Object) error {
|
||||
return w.lifecycle.Updated(obj.(*LocalCredential))
|
||||
}
|
||||
|
||||
func NewLocalCredentialLifecycleAdapter(name string, client LocalCredentialInterface, l LocalCredentialLifecycle) LocalCredentialHandlerFunc {
|
||||
adapter := &localCredentialLifecycleAdapter{lifecycle: l}
|
||||
syncFn := lifecycle.NewObjectLifecycleAdapter(name, adapter, client.ObjectClient())
|
||||
return func(key string, obj *LocalCredential) error {
|
||||
if obj == nil {
|
||||
return syncFn(key, nil)
|
||||
}
|
||||
return syncFn(key, obj)
|
||||
}
|
||||
}
|
@@ -0,0 +1,193 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rancher/norman/clientbase"
|
||||
"github.com/rancher/norman/controller"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
var (
|
||||
LoginInputGroupVersionKind = schema.GroupVersionKind{
|
||||
Version: "v3",
|
||||
Group: "management.cattle.io",
|
||||
Kind: "LoginInput",
|
||||
}
|
||||
LoginInputResource = metav1.APIResource{
|
||||
Name: "logininputs",
|
||||
SingularName: "logininput",
|
||||
Namespaced: false,
|
||||
Kind: LoginInputGroupVersionKind.Kind,
|
||||
}
|
||||
)
|
||||
|
||||
type LoginInputList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []LoginInput
|
||||
}
|
||||
|
||||
type LoginInputHandlerFunc func(key string, obj *LoginInput) error
|
||||
|
||||
type LoginInputLister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*LoginInput, err error)
|
||||
Get(namespace, name string) (*LoginInput, error)
|
||||
}
|
||||
|
||||
type LoginInputController interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() LoginInputLister
|
||||
AddHandler(handler LoginInputHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
||||
type LoginInputInterface interface {
|
||||
ObjectClient() *clientbase.ObjectClient
|
||||
Create(*LoginInput) (*LoginInput, error)
|
||||
Get(name string, opts metav1.GetOptions) (*LoginInput, error)
|
||||
Update(*LoginInput) (*LoginInput, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*LoginInputList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
Controller() LoginInputController
|
||||
}
|
||||
|
||||
type loginInputLister struct {
|
||||
controller *loginInputController
|
||||
}
|
||||
|
||||
func (l *loginInputLister) List(namespace string, selector labels.Selector) (ret []*LoginInput, err error) {
|
||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||
ret = append(ret, obj.(*LoginInput))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (l *loginInputLister) Get(namespace, name string) (*LoginInput, error) {
|
||||
var key string
|
||||
if namespace != "" {
|
||||
key = namespace + "/" + name
|
||||
} else {
|
||||
key = name
|
||||
}
|
||||
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(schema.GroupResource{
|
||||
Group: LoginInputGroupVersionKind.Group,
|
||||
Resource: "loginInput",
|
||||
}, name)
|
||||
}
|
||||
return obj.(*LoginInput), nil
|
||||
}
|
||||
|
||||
type loginInputController struct {
|
||||
controller.GenericController
|
||||
}
|
||||
|
||||
func (c *loginInputController) Lister() LoginInputLister {
|
||||
return &loginInputLister{
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *loginInputController) AddHandler(handler LoginInputHandlerFunc) {
|
||||
c.GenericController.AddHandler(func(key string) error {
|
||||
obj, exists, err := c.Informer().GetStore().GetByKey(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
return handler(key, nil)
|
||||
}
|
||||
return handler(key, obj.(*LoginInput))
|
||||
})
|
||||
}
|
||||
|
||||
type loginInputFactory struct {
|
||||
}
|
||||
|
||||
func (c loginInputFactory) Object() runtime.Object {
|
||||
return &LoginInput{}
|
||||
}
|
||||
|
||||
func (c loginInputFactory) List() runtime.Object {
|
||||
return &LoginInputList{}
|
||||
}
|
||||
|
||||
func (s *loginInputClient) Controller() LoginInputController {
|
||||
s.client.Lock()
|
||||
defer s.client.Unlock()
|
||||
|
||||
c, ok := s.client.loginInputControllers[s.ns]
|
||||
if ok {
|
||||
return c
|
||||
}
|
||||
|
||||
genericController := controller.NewGenericController(LoginInputGroupVersionKind.Kind+"Controller",
|
||||
s.objectClient)
|
||||
|
||||
c = &loginInputController{
|
||||
GenericController: genericController,
|
||||
}
|
||||
|
||||
s.client.loginInputControllers[s.ns] = c
|
||||
s.client.starters = append(s.client.starters, c)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
type loginInputClient struct {
|
||||
client *Client
|
||||
ns string
|
||||
objectClient *clientbase.ObjectClient
|
||||
controller LoginInputController
|
||||
}
|
||||
|
||||
func (s *loginInputClient) ObjectClient() *clientbase.ObjectClient {
|
||||
return s.objectClient
|
||||
}
|
||||
|
||||
func (s *loginInputClient) Create(o *LoginInput) (*LoginInput, error) {
|
||||
obj, err := s.objectClient.Create(o)
|
||||
return obj.(*LoginInput), err
|
||||
}
|
||||
|
||||
func (s *loginInputClient) Get(name string, opts metav1.GetOptions) (*LoginInput, error) {
|
||||
obj, err := s.objectClient.Get(name, opts)
|
||||
return obj.(*LoginInput), err
|
||||
}
|
||||
|
||||
func (s *loginInputClient) Update(o *LoginInput) (*LoginInput, error) {
|
||||
obj, err := s.objectClient.Update(o.Name, o)
|
||||
return obj.(*LoginInput), err
|
||||
}
|
||||
|
||||
func (s *loginInputClient) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.Delete(name, options)
|
||||
}
|
||||
|
||||
func (s *loginInputClient) List(opts metav1.ListOptions) (*LoginInputList, error) {
|
||||
obj, err := s.objectClient.List(opts)
|
||||
return obj.(*LoginInputList), err
|
||||
}
|
||||
|
||||
func (s *loginInputClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return s.objectClient.Watch(opts)
|
||||
}
|
||||
|
||||
func (s *loginInputClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type LoginInputLifecycle interface {
|
||||
Create(obj *LoginInput) error
|
||||
Remove(obj *LoginInput) error
|
||||
Updated(obj *LoginInput) error
|
||||
}
|
||||
|
||||
type loginInputLifecycleAdapter struct {
|
||||
lifecycle LoginInputLifecycle
|
||||
}
|
||||
|
||||
func (w *loginInputLifecycleAdapter) Create(obj runtime.Object) error {
|
||||
return w.lifecycle.Create(obj.(*LoginInput))
|
||||
}
|
||||
|
||||
func (w *loginInputLifecycleAdapter) Finalize(obj runtime.Object) error {
|
||||
return w.lifecycle.Remove(obj.(*LoginInput))
|
||||
}
|
||||
|
||||
func (w *loginInputLifecycleAdapter) Updated(obj runtime.Object) error {
|
||||
return w.lifecycle.Updated(obj.(*LoginInput))
|
||||
}
|
||||
|
||||
func NewLoginInputLifecycleAdapter(name string, client LoginInputInterface, l LoginInputLifecycle) LoginInputHandlerFunc {
|
||||
adapter := &loginInputLifecycleAdapter{lifecycle: l}
|
||||
syncFn := lifecycle.NewObjectLifecycleAdapter(name, adapter, client.ObjectClient())
|
||||
return func(key string, obj *LoginInput) error {
|
||||
if obj == nil {
|
||||
return syncFn(key, nil)
|
||||
}
|
||||
return syncFn(key, obj)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user