1
0
mirror of https://github.com/rancher/types.git synced 2025-09-18 16:10:58 +00:00

Merge pull request #201 from gitlawr/pipelines

Add types for pipeline
This commit is contained in:
Alena Prokharchyk
2018-02-13 12:23:58 -08:00
committed by GitHub
46 changed files with 4193 additions and 1 deletions

View File

@@ -0,0 +1,224 @@
package v3
import (
"github.com/rancher/norman/types"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type ClusterPipeline struct {
types.Namespaced
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ClusterPipelineSpec `json:"spec"`
Status ClusterPipelineStatus `json:"status"`
}
type Pipeline struct {
types.Namespaced
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec PipelineSpec `json:"spec"`
Status PipelineStatus `json:"status"`
}
type PipelineExecution struct {
types.Namespaced
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec PipelineExecutionSpec `json:"spec"`
Status PipelineExecutionStatus `json:"status"`
}
type PipelineExecutionLog struct {
types.Namespaced
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec PipelineExecutionLogSpec `json:"spec"`
}
type SourceCodeCredential struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec SourceCodeCredentialSpec `json:"spec"`
Status SourceCodeCredentialStatus `json:"status"`
}
type SourceCodeRepository struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec SourceCodeRepositorySpec `json:"spec"`
Status SourceCodeRepositoryStatus `json:"status"`
}
type ClusterPipelineSpec struct {
ClusterName string `json:"clusterName" norman:"type=reference[cluster]"`
Deploy bool `json:"deploy"`
GithubConfig *GithubClusterConfig `json:"githubConfig,omitempty"`
}
type ClusterPipelineStatus struct {
}
type GithubClusterConfig struct {
TLS bool `json:"tls,omitempty"`
Host string `json:"host,omitempty"`
ClientID string `json:"clientId,omitempty"`
ClientSecret string `json:"clientSecret,omitempty"`
RedirectURL string `json:"redirectUrl,omitempty"`
}
type PipelineStatus struct {
State string `json:"state,omitempty" norman:"required,options=active|inactive,default=active"`
NextRun int `json:"nextRun" yaml:"nextRun,omitempty" norman:"default=1,min=1"`
LastExecutionID string `json:"lastExecutionId,omitempty" yaml:"lastExecutionId,omitempty"`
LastRunState string `json:"lastRunState,omitempty" yaml:"lastRunState,omitempty"`
LastStarted string `json:"lastStarted,omitempty" yaml:"lastStarted,omitempty"`
NextStart string `json:"nextStart,omitempty" yaml:"nextStart,omitempty"`
WebHookID string `json:"webhookId,omitempty" yaml:"webhookId,omitempty"`
Token string `json:"token,omitempty" yaml:"token,omitempty"`
}
type PipelineSpec struct {
ProjectName string `json:"projectName" yaml:"projectName" norman:"required,type=reference[project]"`
DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty" norman:"required"`
TriggerWebhook bool `json:"triggerWebhook,omitempty" yaml:"triggerWebhook,omitempty"`
TriggerCronTimezone string `json:"triggerCronTimezone,omitempty" yaml:"triggerCronTimezone,omitempty"`
TriggerCronExpression string `json:"triggerCronExpression,omitempty" yaml:"triggerCronExpression,omitempty"`
Stages []Stage `json:"stages,omitempty" yaml:"stages,omitempty" norman:"required"`
}
type Stage struct {
Name string `json:"name,omitempty" yaml:"name,omitempty" norman:"required"`
Steps []Step `json:"steps,omitempty" yaml:"steps,omitempty" norman:"required"`
}
type Step struct {
SourceCodeConfig *SourceCodeConfig `json:"sourceCodeConfig,omitempty" yaml:"sourceCodeConfig,omitempty"`
RunScriptConfig *RunScriptConfig `json:"runScriptConfig,omitempty" yaml:"runScriptConfig,omitempty"`
PublishImageConfig *PublishImageConfig `json:"publishImageConfig,omitempty" yaml:"publishImageConfig,omitempty"`
//Step timeout in minutes
Timeout int `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}
type SourceCodeConfig struct {
URL string `json:"url,omitempty" yaml:"url,omitempty" norman:"required"`
Branch string `json:"branch,omitempty" yaml:"branch,omitempty" `
BranchCondition string `json:"branchCondition,omitempty" yaml:"branchCondition,omitempty" norman:"options=only|except|all"`
SourceCodeCredentialName string `json:"sourceCodeCredentialName,omitempty" yaml:"sourceCodeCredentialName,omitempty" norman:"type=reference[sourceCodeCredential]"`
}
type RunScriptConfig struct {
Image string `json:"image,omitempty" yaml:"image,omitempty" norman:"required"`
IsShell bool `json:"isShell,omitempty" yaml:"isShell,omitempty"`
ShellScript string `json:"shellScript,omitempty" yaml:"shellScript,omitempty"`
Entrypoint string `json:"entrypoint,omitempty" yaml:"enrtypoint,omitempty"`
Command string `json:"command,omitempty" yaml:"command,omitempty"`
Env []string `json:"env,omitempty" yaml:"env,omitempty"`
}
type PublishImageConfig struct {
DockerfilePath string `json:"dockerfilePath,omittempty" yaml:"dockerfilePath,omitempty" norman:"required,default=./Dockerfile"`
BuildContext string `json:"buildContext,omitempty" yaml:"buildContext,omitempty" norman:"required,default=."`
Tag string `json:"tag,omitempty" yaml:"tag,omitempty" norman:"required,default=${CICD_GIT_REPOSITORY_NAME}:${CICD_GIT_BRANCH}"`
}
type PipelineExecutionSpec struct {
ProjectName string `json:"projectName" norman:"required,type=reference[project]"`
PipelineName string `json:"pipelineName" norman:"required,type=reference[pipeline]"`
Run int `json:"run,omitempty" norman:"required,min=1"`
TriggeredBy string `json:"triggeredBy,omitempty" norman:"required,options=user|cron|webhook"`
TriggerUserName string `json:"triggerUserName,omitempty" norman:"type=reference[user]"`
Pipeline Pipeline `json:"pipeline,omitempty" norman:"required"`
}
type PipelineExecutionStatus struct {
Commit string `json:"commit,omitempty"`
State string `json:"state,omitempty"`
Started string `json:"started,omitempty"`
Ended string `json:"ended,omitempty"`
Stages []StageStatus `json:"stages,omitempty"`
}
type StageStatus struct {
State string `json:"state,omitempty"`
Started string `json:"started,omitempty"`
Ended string `json:"ended,omitempty"`
Steps []StepStatus `json:"steps,omitempty"`
}
type StepStatus struct {
State string `json:"state,omitempty"`
Started string `json:"started,omitempty"`
Ended string `json:"ended,omitempty"`
}
type SourceCodeCredentialSpec struct {
ClusterName string `json:"clusterName" norman:"required,type=reference[cluster]"`
SourceCodeType string `json:"sourceCodeType,omitempty" norman:"required,options=github"`
UserName string `json:"userName" norman:"required,type=reference[user]"`
DisplayName string `json:"displayName,omitempty" norman:"required"`
AvatarURL string `json:"avatarUrl,omitempty"`
HTMLURL string `json:"htmlUrl,omitempty"`
LoginName string `json:"loginName,omitempty"`
AccessToken string `json:"accessToken,omitempty"`
}
type SourceCodeCredentialStatus struct {
}
type SourceCodeRepositorySpec struct {
ClusterName string `json:"clusterName" norman:"required,type=reference[cluster]"`
SourceCodeType string `json:"sourceCodeType,omitempty" norman:"required,options=github"`
UserName string `json:"userName" norman:"required,type=reference[user]"`
SourceCodeCredentialName string `json:"sourceCodeCredentialName,omitempty" norman:"required,type=reference[sourceCodeCredential]"`
URL string `json:"url,omitempty"`
Permissions RepoPerm `json:"permissions,omitempty"`
Language string `json:"language,omitempty"`
}
type SourceCodeRepositoryStatus struct {
}
type RepoPerm struct {
Pull bool `json:"pull,omitempty"`
Push bool `json:"push,omitempty"`
Admin bool `json:"admin,omitempty"`
}
type PipelineExecutionLogSpec struct {
ProjectName string `json:"projectName" yaml:"projectName" norman:"required,type=reference[project]"`
PipelineExecutionName string `json:"pipelineExecutionName,omitempty" norman:"type=reference[pipelineExecution]"`
Stage int `json:"stage,omitempty" norman:"min=1"`
Step int `json:"step,omitempty" norman:"min=1"`
Line int `json:"line,omitempty"`
Message string `json:"message,omitempty"`
}
type AuthAppInput struct {
SourceCodeType string `json:"sourceCodeType,omitempty" norman:"type=string,required"`
RedirectURL string `json:"redirectUrl,omitempty" norman:"type=string"`
TLS bool `json:"tls,omitempty"`
Host string `json:"host,omitempty"`
ClientID string `json:"clientId,omitempty" norman:"type=string,required"`
ClientSecret string `json:"clientSecret,omitempty" norman:"type=string,required"`
Code string `json:"code,omitempty" norman:"type=string,required"`
}
type AuthUserInput struct {
SourceCodeType string `json:"sourceCodeType,omitempty" norman:"type=string,required"`
RedirectURL string `json:"redirectUrl,omitempty" norman:"type=string"`
Code string `json:"code,omitempty" norman:"type=string,required"`
}

View File

@@ -32,7 +32,8 @@ var (
Init(logTypes).
Init(globalTypes).
Init(rkeTypes).
Init(alertTypes)
Init(alertTypes).
Init(pipelineTypes)
TokenSchemas = factory.Schemas(&Version).
Init(tokens)
@@ -330,3 +331,57 @@ func alertTypes(schema *types.Schemas) *types.Schemas {
})
}
func pipelineTypes(schema *types.Schemas) *types.Schemas {
return schema.
AddMapperForType(&Version, &v3.ClusterPipeline{},
m.DisplayName{}).
AddMapperForType(&Version, &v3.Pipeline{},
&m.Embed{Field: "status"},
m.DisplayName{}).
AddMapperForType(&Version, &v3.PipelineExecution{},
&m.Embed{Field: "status"},
m.DisplayName{}).
AddMapperForType(&Version, &v3.SourceCodeCredential{},
m.DisplayName{}).
AddMapperForType(&Version, &v3.SourceCodeRepository{}, m.DisplayName{}).
AddMapperForType(&Version, &v3.PipelineExecutionLog{}).
MustImport(&Version, v3.AuthAppInput{}).
MustImport(&Version, v3.AuthUserInput{}).
MustImportAndCustomize(&Version, v3.SourceCodeCredential{}, func(schema *types.Schema) {
schema.ResourceActions = map[string]types.Action{
"refreshrepos": {},
}
}).
MustImportAndCustomize(&Version, v3.ClusterPipeline{}, func(schema *types.Schema) {
schema.ResourceActions = map[string]types.Action{
"deploy": {},
"destroy": {},
"authapp": {
Input: "authAppInput",
Output: "cluterPipeline",
},
"revokeapp": {},
"authuser": {
Input: "authUserInput",
Output: "sourceCodeCredential",
},
}
}).
MustImportAndCustomize(&Version, v3.Pipeline{}, func(schema *types.Schema) {
schema.ResourceActions = map[string]types.Action{
"activate": {},
"deactivate": {},
"run": {},
}
}).
MustImportAndCustomize(&Version, v3.PipelineExecution{}, func(schema *types.Schema) {
schema.ResourceActions = map[string]types.Action{
"stop": {},
"rerun": {},
}
}).
MustImport(&Version, v3.SourceCodeRepository{}).
MustImport(&Version, v3.PipelineExecutionLog{})
}

View File

@@ -0,0 +1,252 @@
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 (
ClusterPipelineGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "ClusterPipeline",
}
ClusterPipelineResource = metav1.APIResource{
Name: "clusterpipelines",
SingularName: "clusterpipeline",
Namespaced: true,
Kind: ClusterPipelineGroupVersionKind.Kind,
}
)
type ClusterPipelineList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterPipeline
}
type ClusterPipelineHandlerFunc func(key string, obj *ClusterPipeline) error
type ClusterPipelineLister interface {
List(namespace string, selector labels.Selector) (ret []*ClusterPipeline, err error)
Get(namespace, name string) (*ClusterPipeline, error)
}
type ClusterPipelineController interface {
Informer() cache.SharedIndexInformer
Lister() ClusterPipelineLister
AddHandler(name string, handler ClusterPipelineHandlerFunc)
AddClusterScopedHandler(name, clusterName string, handler ClusterPipelineHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type ClusterPipelineInterface interface {
ObjectClient() *clientbase.ObjectClient
Create(*ClusterPipeline) (*ClusterPipeline, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*ClusterPipeline, error)
Get(name string, opts metav1.GetOptions) (*ClusterPipeline, error)
Update(*ClusterPipeline) (*ClusterPipeline, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*ClusterPipelineList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() ClusterPipelineController
AddHandler(name string, sync ClusterPipelineHandlerFunc)
AddLifecycle(name string, lifecycle ClusterPipelineLifecycle)
AddClusterScopedHandler(name, clusterName string, sync ClusterPipelineHandlerFunc)
AddClusterScopedLifecycle(name, clusterName string, lifecycle ClusterPipelineLifecycle)
}
type clusterPipelineLister struct {
controller *clusterPipelineController
}
func (l *clusterPipelineLister) List(namespace string, selector labels.Selector) (ret []*ClusterPipeline, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*ClusterPipeline))
})
return
}
func (l *clusterPipelineLister) Get(namespace, name string) (*ClusterPipeline, 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: ClusterPipelineGroupVersionKind.Group,
Resource: "clusterPipeline",
}, name)
}
return obj.(*ClusterPipeline), nil
}
type clusterPipelineController struct {
controller.GenericController
}
func (c *clusterPipelineController) Lister() ClusterPipelineLister {
return &clusterPipelineLister{
controller: c,
}
}
func (c *clusterPipelineController) AddHandler(name string, handler ClusterPipelineHandlerFunc) {
c.GenericController.AddHandler(name, 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.(*ClusterPipeline))
})
}
func (c *clusterPipelineController) AddClusterScopedHandler(name, cluster string, handler ClusterPipelineHandlerFunc) {
c.GenericController.AddHandler(name, func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
if err != nil {
return err
}
if !exists {
return handler(key, nil)
}
if !controller.ObjectInCluster(cluster, obj) {
return nil
}
return handler(key, obj.(*ClusterPipeline))
})
}
type clusterPipelineFactory struct {
}
func (c clusterPipelineFactory) Object() runtime.Object {
return &ClusterPipeline{}
}
func (c clusterPipelineFactory) List() runtime.Object {
return &ClusterPipelineList{}
}
func (s *clusterPipelineClient) Controller() ClusterPipelineController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.clusterPipelineControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(ClusterPipelineGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &clusterPipelineController{
GenericController: genericController,
}
s.client.clusterPipelineControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type clusterPipelineClient struct {
client *Client
ns string
objectClient *clientbase.ObjectClient
controller ClusterPipelineController
}
func (s *clusterPipelineClient) ObjectClient() *clientbase.ObjectClient {
return s.objectClient
}
func (s *clusterPipelineClient) Create(o *ClusterPipeline) (*ClusterPipeline, error) {
obj, err := s.objectClient.Create(o)
return obj.(*ClusterPipeline), err
}
func (s *clusterPipelineClient) Get(name string, opts metav1.GetOptions) (*ClusterPipeline, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*ClusterPipeline), err
}
func (s *clusterPipelineClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*ClusterPipeline, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*ClusterPipeline), err
}
func (s *clusterPipelineClient) Update(o *ClusterPipeline) (*ClusterPipeline, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*ClusterPipeline), err
}
func (s *clusterPipelineClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *clusterPipelineClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *clusterPipelineClient) List(opts metav1.ListOptions) (*ClusterPipelineList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*ClusterPipelineList), err
}
func (s *clusterPipelineClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *clusterPipelineClient) Patch(o *ClusterPipeline, data []byte, subresources ...string) (*ClusterPipeline, error) {
obj, err := s.objectClient.Patch(o.Name, o, data, subresources...)
return obj.(*ClusterPipeline), err
}
func (s *clusterPipelineClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *clusterPipelineClient) AddHandler(name string, sync ClusterPipelineHandlerFunc) {
s.Controller().AddHandler(name, sync)
}
func (s *clusterPipelineClient) AddLifecycle(name string, lifecycle ClusterPipelineLifecycle) {
sync := NewClusterPipelineLifecycleAdapter(name, false, s, lifecycle)
s.AddHandler(name, sync)
}
func (s *clusterPipelineClient) AddClusterScopedHandler(name, clusterName string, sync ClusterPipelineHandlerFunc) {
s.Controller().AddClusterScopedHandler(name, clusterName, sync)
}
func (s *clusterPipelineClient) AddClusterScopedLifecycle(name, clusterName string, lifecycle ClusterPipelineLifecycle) {
sync := NewClusterPipelineLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.AddClusterScopedHandler(name, clusterName, sync)
}

View File

@@ -0,0 +1,51 @@
package v3
import (
"github.com/rancher/norman/lifecycle"
"k8s.io/apimachinery/pkg/runtime"
)
type ClusterPipelineLifecycle interface {
Create(obj *ClusterPipeline) (*ClusterPipeline, error)
Remove(obj *ClusterPipeline) (*ClusterPipeline, error)
Updated(obj *ClusterPipeline) (*ClusterPipeline, error)
}
type clusterPipelineLifecycleAdapter struct {
lifecycle ClusterPipelineLifecycle
}
func (w *clusterPipelineLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*ClusterPipeline))
if o == nil {
return nil, err
}
return o, err
}
func (w *clusterPipelineLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*ClusterPipeline))
if o == nil {
return nil, err
}
return o, err
}
func (w *clusterPipelineLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*ClusterPipeline))
if o == nil {
return nil, err
}
return o, err
}
func NewClusterPipelineLifecycleAdapter(name string, clusterScoped bool, client ClusterPipelineInterface, l ClusterPipelineLifecycle) ClusterPipelineHandlerFunc {
adapter := &clusterPipelineLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *ClusterPipeline) error {
if obj == nil {
return syncFn(key, nil)
}
return syncFn(key, obj)
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -45,6 +45,12 @@ type Interface interface {
NotifiersGetter
ClusterAlertsGetter
ProjectAlertsGetter
SourceCodeCredentialsGetter
ClusterPipelinesGetter
PipelinesGetter
PipelineExecutionsGetter
SourceCodeRepositoriesGetter
PipelineExecutionLogsGetter
}
type Client struct {
@@ -83,6 +89,12 @@ type Client struct {
notifierControllers map[string]NotifierController
clusterAlertControllers map[string]ClusterAlertController
projectAlertControllers map[string]ProjectAlertController
sourceCodeCredentialControllers map[string]SourceCodeCredentialController
clusterPipelineControllers map[string]ClusterPipelineController
pipelineControllers map[string]PipelineController
pipelineExecutionControllers map[string]PipelineExecutionController
sourceCodeRepositoryControllers map[string]SourceCodeRepositoryController
pipelineExecutionLogControllers map[string]PipelineExecutionLogController
}
func NewForConfig(config rest.Config) (Interface, error) {
@@ -130,6 +142,12 @@ func NewForConfig(config rest.Config) (Interface, error) {
notifierControllers: map[string]NotifierController{},
clusterAlertControllers: map[string]ClusterAlertController{},
projectAlertControllers: map[string]ProjectAlertController{},
sourceCodeCredentialControllers: map[string]SourceCodeCredentialController{},
clusterPipelineControllers: map[string]ClusterPipelineController{},
pipelineControllers: map[string]PipelineController{},
pipelineExecutionControllers: map[string]PipelineExecutionController{},
sourceCodeRepositoryControllers: map[string]SourceCodeRepositoryController{},
pipelineExecutionLogControllers: map[string]PipelineExecutionLogController{},
}, nil
}
@@ -547,3 +565,81 @@ func (c *Client) ProjectAlerts(namespace string) ProjectAlertInterface {
objectClient: objectClient,
}
}
type SourceCodeCredentialsGetter interface {
SourceCodeCredentials(namespace string) SourceCodeCredentialInterface
}
func (c *Client) SourceCodeCredentials(namespace string) SourceCodeCredentialInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &SourceCodeCredentialResource, SourceCodeCredentialGroupVersionKind, sourceCodeCredentialFactory{})
return &sourceCodeCredentialClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type ClusterPipelinesGetter interface {
ClusterPipelines(namespace string) ClusterPipelineInterface
}
func (c *Client) ClusterPipelines(namespace string) ClusterPipelineInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &ClusterPipelineResource, ClusterPipelineGroupVersionKind, clusterPipelineFactory{})
return &clusterPipelineClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type PipelinesGetter interface {
Pipelines(namespace string) PipelineInterface
}
func (c *Client) Pipelines(namespace string) PipelineInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &PipelineResource, PipelineGroupVersionKind, pipelineFactory{})
return &pipelineClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type PipelineExecutionsGetter interface {
PipelineExecutions(namespace string) PipelineExecutionInterface
}
func (c *Client) PipelineExecutions(namespace string) PipelineExecutionInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &PipelineExecutionResource, PipelineExecutionGroupVersionKind, pipelineExecutionFactory{})
return &pipelineExecutionClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type SourceCodeRepositoriesGetter interface {
SourceCodeRepositories(namespace string) SourceCodeRepositoryInterface
}
func (c *Client) SourceCodeRepositories(namespace string) SourceCodeRepositoryInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &SourceCodeRepositoryResource, SourceCodeRepositoryGroupVersionKind, sourceCodeRepositoryFactory{})
return &sourceCodeRepositoryClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type PipelineExecutionLogsGetter interface {
PipelineExecutionLogs(namespace string) PipelineExecutionLogInterface
}
func (c *Client) PipelineExecutionLogs(namespace string) PipelineExecutionLogInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &PipelineExecutionLogResource, PipelineExecutionLogGroupVersionKind, pipelineExecutionLogFactory{})
return &pipelineExecutionLogClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}

View File

@@ -0,0 +1,252 @@
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 (
PipelineGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "Pipeline",
}
PipelineResource = metav1.APIResource{
Name: "pipelines",
SingularName: "pipeline",
Namespaced: true,
Kind: PipelineGroupVersionKind.Kind,
}
)
type PipelineList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Pipeline
}
type PipelineHandlerFunc func(key string, obj *Pipeline) error
type PipelineLister interface {
List(namespace string, selector labels.Selector) (ret []*Pipeline, err error)
Get(namespace, name string) (*Pipeline, error)
}
type PipelineController interface {
Informer() cache.SharedIndexInformer
Lister() PipelineLister
AddHandler(name string, handler PipelineHandlerFunc)
AddClusterScopedHandler(name, clusterName string, handler PipelineHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type PipelineInterface interface {
ObjectClient() *clientbase.ObjectClient
Create(*Pipeline) (*Pipeline, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*Pipeline, error)
Get(name string, opts metav1.GetOptions) (*Pipeline, error)
Update(*Pipeline) (*Pipeline, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*PipelineList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() PipelineController
AddHandler(name string, sync PipelineHandlerFunc)
AddLifecycle(name string, lifecycle PipelineLifecycle)
AddClusterScopedHandler(name, clusterName string, sync PipelineHandlerFunc)
AddClusterScopedLifecycle(name, clusterName string, lifecycle PipelineLifecycle)
}
type pipelineLister struct {
controller *pipelineController
}
func (l *pipelineLister) List(namespace string, selector labels.Selector) (ret []*Pipeline, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*Pipeline))
})
return
}
func (l *pipelineLister) Get(namespace, name string) (*Pipeline, 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: PipelineGroupVersionKind.Group,
Resource: "pipeline",
}, name)
}
return obj.(*Pipeline), nil
}
type pipelineController struct {
controller.GenericController
}
func (c *pipelineController) Lister() PipelineLister {
return &pipelineLister{
controller: c,
}
}
func (c *pipelineController) AddHandler(name string, handler PipelineHandlerFunc) {
c.GenericController.AddHandler(name, 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.(*Pipeline))
})
}
func (c *pipelineController) AddClusterScopedHandler(name, cluster string, handler PipelineHandlerFunc) {
c.GenericController.AddHandler(name, func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
if err != nil {
return err
}
if !exists {
return handler(key, nil)
}
if !controller.ObjectInCluster(cluster, obj) {
return nil
}
return handler(key, obj.(*Pipeline))
})
}
type pipelineFactory struct {
}
func (c pipelineFactory) Object() runtime.Object {
return &Pipeline{}
}
func (c pipelineFactory) List() runtime.Object {
return &PipelineList{}
}
func (s *pipelineClient) Controller() PipelineController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.pipelineControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(PipelineGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &pipelineController{
GenericController: genericController,
}
s.client.pipelineControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type pipelineClient struct {
client *Client
ns string
objectClient *clientbase.ObjectClient
controller PipelineController
}
func (s *pipelineClient) ObjectClient() *clientbase.ObjectClient {
return s.objectClient
}
func (s *pipelineClient) Create(o *Pipeline) (*Pipeline, error) {
obj, err := s.objectClient.Create(o)
return obj.(*Pipeline), err
}
func (s *pipelineClient) Get(name string, opts metav1.GetOptions) (*Pipeline, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*Pipeline), err
}
func (s *pipelineClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*Pipeline, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*Pipeline), err
}
func (s *pipelineClient) Update(o *Pipeline) (*Pipeline, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*Pipeline), err
}
func (s *pipelineClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *pipelineClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *pipelineClient) List(opts metav1.ListOptions) (*PipelineList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*PipelineList), err
}
func (s *pipelineClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *pipelineClient) Patch(o *Pipeline, data []byte, subresources ...string) (*Pipeline, error) {
obj, err := s.objectClient.Patch(o.Name, o, data, subresources...)
return obj.(*Pipeline), err
}
func (s *pipelineClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *pipelineClient) AddHandler(name string, sync PipelineHandlerFunc) {
s.Controller().AddHandler(name, sync)
}
func (s *pipelineClient) AddLifecycle(name string, lifecycle PipelineLifecycle) {
sync := NewPipelineLifecycleAdapter(name, false, s, lifecycle)
s.AddHandler(name, sync)
}
func (s *pipelineClient) AddClusterScopedHandler(name, clusterName string, sync PipelineHandlerFunc) {
s.Controller().AddClusterScopedHandler(name, clusterName, sync)
}
func (s *pipelineClient) AddClusterScopedLifecycle(name, clusterName string, lifecycle PipelineLifecycle) {
sync := NewPipelineLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.AddClusterScopedHandler(name, clusterName, sync)
}

View File

@@ -0,0 +1,252 @@
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 (
PipelineExecutionGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "PipelineExecution",
}
PipelineExecutionResource = metav1.APIResource{
Name: "pipelineexecutions",
SingularName: "pipelineexecution",
Namespaced: true,
Kind: PipelineExecutionGroupVersionKind.Kind,
}
)
type PipelineExecutionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []PipelineExecution
}
type PipelineExecutionHandlerFunc func(key string, obj *PipelineExecution) error
type PipelineExecutionLister interface {
List(namespace string, selector labels.Selector) (ret []*PipelineExecution, err error)
Get(namespace, name string) (*PipelineExecution, error)
}
type PipelineExecutionController interface {
Informer() cache.SharedIndexInformer
Lister() PipelineExecutionLister
AddHandler(name string, handler PipelineExecutionHandlerFunc)
AddClusterScopedHandler(name, clusterName string, handler PipelineExecutionHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type PipelineExecutionInterface interface {
ObjectClient() *clientbase.ObjectClient
Create(*PipelineExecution) (*PipelineExecution, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*PipelineExecution, error)
Get(name string, opts metav1.GetOptions) (*PipelineExecution, error)
Update(*PipelineExecution) (*PipelineExecution, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*PipelineExecutionList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() PipelineExecutionController
AddHandler(name string, sync PipelineExecutionHandlerFunc)
AddLifecycle(name string, lifecycle PipelineExecutionLifecycle)
AddClusterScopedHandler(name, clusterName string, sync PipelineExecutionHandlerFunc)
AddClusterScopedLifecycle(name, clusterName string, lifecycle PipelineExecutionLifecycle)
}
type pipelineExecutionLister struct {
controller *pipelineExecutionController
}
func (l *pipelineExecutionLister) List(namespace string, selector labels.Selector) (ret []*PipelineExecution, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*PipelineExecution))
})
return
}
func (l *pipelineExecutionLister) Get(namespace, name string) (*PipelineExecution, 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: PipelineExecutionGroupVersionKind.Group,
Resource: "pipelineExecution",
}, name)
}
return obj.(*PipelineExecution), nil
}
type pipelineExecutionController struct {
controller.GenericController
}
func (c *pipelineExecutionController) Lister() PipelineExecutionLister {
return &pipelineExecutionLister{
controller: c,
}
}
func (c *pipelineExecutionController) AddHandler(name string, handler PipelineExecutionHandlerFunc) {
c.GenericController.AddHandler(name, 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.(*PipelineExecution))
})
}
func (c *pipelineExecutionController) AddClusterScopedHandler(name, cluster string, handler PipelineExecutionHandlerFunc) {
c.GenericController.AddHandler(name, func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
if err != nil {
return err
}
if !exists {
return handler(key, nil)
}
if !controller.ObjectInCluster(cluster, obj) {
return nil
}
return handler(key, obj.(*PipelineExecution))
})
}
type pipelineExecutionFactory struct {
}
func (c pipelineExecutionFactory) Object() runtime.Object {
return &PipelineExecution{}
}
func (c pipelineExecutionFactory) List() runtime.Object {
return &PipelineExecutionList{}
}
func (s *pipelineExecutionClient) Controller() PipelineExecutionController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.pipelineExecutionControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(PipelineExecutionGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &pipelineExecutionController{
GenericController: genericController,
}
s.client.pipelineExecutionControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type pipelineExecutionClient struct {
client *Client
ns string
objectClient *clientbase.ObjectClient
controller PipelineExecutionController
}
func (s *pipelineExecutionClient) ObjectClient() *clientbase.ObjectClient {
return s.objectClient
}
func (s *pipelineExecutionClient) Create(o *PipelineExecution) (*PipelineExecution, error) {
obj, err := s.objectClient.Create(o)
return obj.(*PipelineExecution), err
}
func (s *pipelineExecutionClient) Get(name string, opts metav1.GetOptions) (*PipelineExecution, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*PipelineExecution), err
}
func (s *pipelineExecutionClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*PipelineExecution, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*PipelineExecution), err
}
func (s *pipelineExecutionClient) Update(o *PipelineExecution) (*PipelineExecution, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*PipelineExecution), err
}
func (s *pipelineExecutionClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *pipelineExecutionClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *pipelineExecutionClient) List(opts metav1.ListOptions) (*PipelineExecutionList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*PipelineExecutionList), err
}
func (s *pipelineExecutionClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *pipelineExecutionClient) Patch(o *PipelineExecution, data []byte, subresources ...string) (*PipelineExecution, error) {
obj, err := s.objectClient.Patch(o.Name, o, data, subresources...)
return obj.(*PipelineExecution), err
}
func (s *pipelineExecutionClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *pipelineExecutionClient) AddHandler(name string, sync PipelineExecutionHandlerFunc) {
s.Controller().AddHandler(name, sync)
}
func (s *pipelineExecutionClient) AddLifecycle(name string, lifecycle PipelineExecutionLifecycle) {
sync := NewPipelineExecutionLifecycleAdapter(name, false, s, lifecycle)
s.AddHandler(name, sync)
}
func (s *pipelineExecutionClient) AddClusterScopedHandler(name, clusterName string, sync PipelineExecutionHandlerFunc) {
s.Controller().AddClusterScopedHandler(name, clusterName, sync)
}
func (s *pipelineExecutionClient) AddClusterScopedLifecycle(name, clusterName string, lifecycle PipelineExecutionLifecycle) {
sync := NewPipelineExecutionLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.AddClusterScopedHandler(name, clusterName, sync)
}

View File

@@ -0,0 +1,51 @@
package v3
import (
"github.com/rancher/norman/lifecycle"
"k8s.io/apimachinery/pkg/runtime"
)
type PipelineExecutionLifecycle interface {
Create(obj *PipelineExecution) (*PipelineExecution, error)
Remove(obj *PipelineExecution) (*PipelineExecution, error)
Updated(obj *PipelineExecution) (*PipelineExecution, error)
}
type pipelineExecutionLifecycleAdapter struct {
lifecycle PipelineExecutionLifecycle
}
func (w *pipelineExecutionLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*PipelineExecution))
if o == nil {
return nil, err
}
return o, err
}
func (w *pipelineExecutionLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*PipelineExecution))
if o == nil {
return nil, err
}
return o, err
}
func (w *pipelineExecutionLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*PipelineExecution))
if o == nil {
return nil, err
}
return o, err
}
func NewPipelineExecutionLifecycleAdapter(name string, clusterScoped bool, client PipelineExecutionInterface, l PipelineExecutionLifecycle) PipelineExecutionHandlerFunc {
adapter := &pipelineExecutionLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *PipelineExecution) error {
if obj == nil {
return syncFn(key, nil)
}
return syncFn(key, obj)
}
}

View File

@@ -0,0 +1,252 @@
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 (
PipelineExecutionLogGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "PipelineExecutionLog",
}
PipelineExecutionLogResource = metav1.APIResource{
Name: "pipelineexecutionlogs",
SingularName: "pipelineexecutionlog",
Namespaced: true,
Kind: PipelineExecutionLogGroupVersionKind.Kind,
}
)
type PipelineExecutionLogList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []PipelineExecutionLog
}
type PipelineExecutionLogHandlerFunc func(key string, obj *PipelineExecutionLog) error
type PipelineExecutionLogLister interface {
List(namespace string, selector labels.Selector) (ret []*PipelineExecutionLog, err error)
Get(namespace, name string) (*PipelineExecutionLog, error)
}
type PipelineExecutionLogController interface {
Informer() cache.SharedIndexInformer
Lister() PipelineExecutionLogLister
AddHandler(name string, handler PipelineExecutionLogHandlerFunc)
AddClusterScopedHandler(name, clusterName string, handler PipelineExecutionLogHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type PipelineExecutionLogInterface interface {
ObjectClient() *clientbase.ObjectClient
Create(*PipelineExecutionLog) (*PipelineExecutionLog, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*PipelineExecutionLog, error)
Get(name string, opts metav1.GetOptions) (*PipelineExecutionLog, error)
Update(*PipelineExecutionLog) (*PipelineExecutionLog, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*PipelineExecutionLogList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() PipelineExecutionLogController
AddHandler(name string, sync PipelineExecutionLogHandlerFunc)
AddLifecycle(name string, lifecycle PipelineExecutionLogLifecycle)
AddClusterScopedHandler(name, clusterName string, sync PipelineExecutionLogHandlerFunc)
AddClusterScopedLifecycle(name, clusterName string, lifecycle PipelineExecutionLogLifecycle)
}
type pipelineExecutionLogLister struct {
controller *pipelineExecutionLogController
}
func (l *pipelineExecutionLogLister) List(namespace string, selector labels.Selector) (ret []*PipelineExecutionLog, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*PipelineExecutionLog))
})
return
}
func (l *pipelineExecutionLogLister) Get(namespace, name string) (*PipelineExecutionLog, 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: PipelineExecutionLogGroupVersionKind.Group,
Resource: "pipelineExecutionLog",
}, name)
}
return obj.(*PipelineExecutionLog), nil
}
type pipelineExecutionLogController struct {
controller.GenericController
}
func (c *pipelineExecutionLogController) Lister() PipelineExecutionLogLister {
return &pipelineExecutionLogLister{
controller: c,
}
}
func (c *pipelineExecutionLogController) AddHandler(name string, handler PipelineExecutionLogHandlerFunc) {
c.GenericController.AddHandler(name, 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.(*PipelineExecutionLog))
})
}
func (c *pipelineExecutionLogController) AddClusterScopedHandler(name, cluster string, handler PipelineExecutionLogHandlerFunc) {
c.GenericController.AddHandler(name, func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
if err != nil {
return err
}
if !exists {
return handler(key, nil)
}
if !controller.ObjectInCluster(cluster, obj) {
return nil
}
return handler(key, obj.(*PipelineExecutionLog))
})
}
type pipelineExecutionLogFactory struct {
}
func (c pipelineExecutionLogFactory) Object() runtime.Object {
return &PipelineExecutionLog{}
}
func (c pipelineExecutionLogFactory) List() runtime.Object {
return &PipelineExecutionLogList{}
}
func (s *pipelineExecutionLogClient) Controller() PipelineExecutionLogController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.pipelineExecutionLogControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(PipelineExecutionLogGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &pipelineExecutionLogController{
GenericController: genericController,
}
s.client.pipelineExecutionLogControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type pipelineExecutionLogClient struct {
client *Client
ns string
objectClient *clientbase.ObjectClient
controller PipelineExecutionLogController
}
func (s *pipelineExecutionLogClient) ObjectClient() *clientbase.ObjectClient {
return s.objectClient
}
func (s *pipelineExecutionLogClient) Create(o *PipelineExecutionLog) (*PipelineExecutionLog, error) {
obj, err := s.objectClient.Create(o)
return obj.(*PipelineExecutionLog), err
}
func (s *pipelineExecutionLogClient) Get(name string, opts metav1.GetOptions) (*PipelineExecutionLog, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*PipelineExecutionLog), err
}
func (s *pipelineExecutionLogClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*PipelineExecutionLog, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*PipelineExecutionLog), err
}
func (s *pipelineExecutionLogClient) Update(o *PipelineExecutionLog) (*PipelineExecutionLog, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*PipelineExecutionLog), err
}
func (s *pipelineExecutionLogClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *pipelineExecutionLogClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *pipelineExecutionLogClient) List(opts metav1.ListOptions) (*PipelineExecutionLogList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*PipelineExecutionLogList), err
}
func (s *pipelineExecutionLogClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *pipelineExecutionLogClient) Patch(o *PipelineExecutionLog, data []byte, subresources ...string) (*PipelineExecutionLog, error) {
obj, err := s.objectClient.Patch(o.Name, o, data, subresources...)
return obj.(*PipelineExecutionLog), err
}
func (s *pipelineExecutionLogClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *pipelineExecutionLogClient) AddHandler(name string, sync PipelineExecutionLogHandlerFunc) {
s.Controller().AddHandler(name, sync)
}
func (s *pipelineExecutionLogClient) AddLifecycle(name string, lifecycle PipelineExecutionLogLifecycle) {
sync := NewPipelineExecutionLogLifecycleAdapter(name, false, s, lifecycle)
s.AddHandler(name, sync)
}
func (s *pipelineExecutionLogClient) AddClusterScopedHandler(name, clusterName string, sync PipelineExecutionLogHandlerFunc) {
s.Controller().AddClusterScopedHandler(name, clusterName, sync)
}
func (s *pipelineExecutionLogClient) AddClusterScopedLifecycle(name, clusterName string, lifecycle PipelineExecutionLogLifecycle) {
sync := NewPipelineExecutionLogLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.AddClusterScopedHandler(name, clusterName, sync)
}

View File

@@ -0,0 +1,51 @@
package v3
import (
"github.com/rancher/norman/lifecycle"
"k8s.io/apimachinery/pkg/runtime"
)
type PipelineExecutionLogLifecycle interface {
Create(obj *PipelineExecutionLog) (*PipelineExecutionLog, error)
Remove(obj *PipelineExecutionLog) (*PipelineExecutionLog, error)
Updated(obj *PipelineExecutionLog) (*PipelineExecutionLog, error)
}
type pipelineExecutionLogLifecycleAdapter struct {
lifecycle PipelineExecutionLogLifecycle
}
func (w *pipelineExecutionLogLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*PipelineExecutionLog))
if o == nil {
return nil, err
}
return o, err
}
func (w *pipelineExecutionLogLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*PipelineExecutionLog))
if o == nil {
return nil, err
}
return o, err
}
func (w *pipelineExecutionLogLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*PipelineExecutionLog))
if o == nil {
return nil, err
}
return o, err
}
func NewPipelineExecutionLogLifecycleAdapter(name string, clusterScoped bool, client PipelineExecutionLogInterface, l PipelineExecutionLogLifecycle) PipelineExecutionLogHandlerFunc {
adapter := &pipelineExecutionLogLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *PipelineExecutionLog) error {
if obj == nil {
return syncFn(key, nil)
}
return syncFn(key, obj)
}
}

View File

@@ -0,0 +1,51 @@
package v3
import (
"github.com/rancher/norman/lifecycle"
"k8s.io/apimachinery/pkg/runtime"
)
type PipelineLifecycle interface {
Create(obj *Pipeline) (*Pipeline, error)
Remove(obj *Pipeline) (*Pipeline, error)
Updated(obj *Pipeline) (*Pipeline, error)
}
type pipelineLifecycleAdapter struct {
lifecycle PipelineLifecycle
}
func (w *pipelineLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*Pipeline))
if o == nil {
return nil, err
}
return o, err
}
func (w *pipelineLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*Pipeline))
if o == nil {
return nil, err
}
return o, err
}
func (w *pipelineLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*Pipeline))
if o == nil {
return nil, err
}
return o, err
}
func NewPipelineLifecycleAdapter(name string, clusterScoped bool, client PipelineInterface, l PipelineLifecycle) PipelineHandlerFunc {
adapter := &pipelineLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *Pipeline) error {
if obj == nil {
return syncFn(key, nil)
}
return syncFn(key, obj)
}
}

View File

@@ -95,6 +95,18 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&ClusterAlertList{},
&ProjectAlert{},
&ProjectAlertList{},
&SourceCodeCredential{},
&SourceCodeCredentialList{},
&ClusterPipeline{},
&ClusterPipelineList{},
&Pipeline{},
&PipelineList{},
&PipelineExecution{},
&PipelineExecutionList{},
&SourceCodeRepository{},
&SourceCodeRepositoryList{},
&PipelineExecutionLog{},
&PipelineExecutionLogList{},
)
return nil
}

View File

@@ -0,0 +1,251 @@
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 (
SourceCodeCredentialGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "SourceCodeCredential",
}
SourceCodeCredentialResource = metav1.APIResource{
Name: "sourcecodecredentials",
SingularName: "sourcecodecredential",
Namespaced: false,
Kind: SourceCodeCredentialGroupVersionKind.Kind,
}
)
type SourceCodeCredentialList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []SourceCodeCredential
}
type SourceCodeCredentialHandlerFunc func(key string, obj *SourceCodeCredential) error
type SourceCodeCredentialLister interface {
List(namespace string, selector labels.Selector) (ret []*SourceCodeCredential, err error)
Get(namespace, name string) (*SourceCodeCredential, error)
}
type SourceCodeCredentialController interface {
Informer() cache.SharedIndexInformer
Lister() SourceCodeCredentialLister
AddHandler(name string, handler SourceCodeCredentialHandlerFunc)
AddClusterScopedHandler(name, clusterName string, handler SourceCodeCredentialHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type SourceCodeCredentialInterface interface {
ObjectClient() *clientbase.ObjectClient
Create(*SourceCodeCredential) (*SourceCodeCredential, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*SourceCodeCredential, error)
Get(name string, opts metav1.GetOptions) (*SourceCodeCredential, error)
Update(*SourceCodeCredential) (*SourceCodeCredential, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*SourceCodeCredentialList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() SourceCodeCredentialController
AddHandler(name string, sync SourceCodeCredentialHandlerFunc)
AddLifecycle(name string, lifecycle SourceCodeCredentialLifecycle)
AddClusterScopedHandler(name, clusterName string, sync SourceCodeCredentialHandlerFunc)
AddClusterScopedLifecycle(name, clusterName string, lifecycle SourceCodeCredentialLifecycle)
}
type sourceCodeCredentialLister struct {
controller *sourceCodeCredentialController
}
func (l *sourceCodeCredentialLister) List(namespace string, selector labels.Selector) (ret []*SourceCodeCredential, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*SourceCodeCredential))
})
return
}
func (l *sourceCodeCredentialLister) Get(namespace, name string) (*SourceCodeCredential, 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: SourceCodeCredentialGroupVersionKind.Group,
Resource: "sourceCodeCredential",
}, name)
}
return obj.(*SourceCodeCredential), nil
}
type sourceCodeCredentialController struct {
controller.GenericController
}
func (c *sourceCodeCredentialController) Lister() SourceCodeCredentialLister {
return &sourceCodeCredentialLister{
controller: c,
}
}
func (c *sourceCodeCredentialController) AddHandler(name string, handler SourceCodeCredentialHandlerFunc) {
c.GenericController.AddHandler(name, 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.(*SourceCodeCredential))
})
}
func (c *sourceCodeCredentialController) AddClusterScopedHandler(name, cluster string, handler SourceCodeCredentialHandlerFunc) {
c.GenericController.AddHandler(name, func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
if err != nil {
return err
}
if !exists {
return handler(key, nil)
}
if !controller.ObjectInCluster(cluster, obj) {
return nil
}
return handler(key, obj.(*SourceCodeCredential))
})
}
type sourceCodeCredentialFactory struct {
}
func (c sourceCodeCredentialFactory) Object() runtime.Object {
return &SourceCodeCredential{}
}
func (c sourceCodeCredentialFactory) List() runtime.Object {
return &SourceCodeCredentialList{}
}
func (s *sourceCodeCredentialClient) Controller() SourceCodeCredentialController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.sourceCodeCredentialControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(SourceCodeCredentialGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &sourceCodeCredentialController{
GenericController: genericController,
}
s.client.sourceCodeCredentialControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type sourceCodeCredentialClient struct {
client *Client
ns string
objectClient *clientbase.ObjectClient
controller SourceCodeCredentialController
}
func (s *sourceCodeCredentialClient) ObjectClient() *clientbase.ObjectClient {
return s.objectClient
}
func (s *sourceCodeCredentialClient) Create(o *SourceCodeCredential) (*SourceCodeCredential, error) {
obj, err := s.objectClient.Create(o)
return obj.(*SourceCodeCredential), err
}
func (s *sourceCodeCredentialClient) Get(name string, opts metav1.GetOptions) (*SourceCodeCredential, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*SourceCodeCredential), err
}
func (s *sourceCodeCredentialClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*SourceCodeCredential, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*SourceCodeCredential), err
}
func (s *sourceCodeCredentialClient) Update(o *SourceCodeCredential) (*SourceCodeCredential, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*SourceCodeCredential), err
}
func (s *sourceCodeCredentialClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *sourceCodeCredentialClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *sourceCodeCredentialClient) List(opts metav1.ListOptions) (*SourceCodeCredentialList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*SourceCodeCredentialList), err
}
func (s *sourceCodeCredentialClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *sourceCodeCredentialClient) Patch(o *SourceCodeCredential, data []byte, subresources ...string) (*SourceCodeCredential, error) {
obj, err := s.objectClient.Patch(o.Name, o, data, subresources...)
return obj.(*SourceCodeCredential), err
}
func (s *sourceCodeCredentialClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *sourceCodeCredentialClient) AddHandler(name string, sync SourceCodeCredentialHandlerFunc) {
s.Controller().AddHandler(name, sync)
}
func (s *sourceCodeCredentialClient) AddLifecycle(name string, lifecycle SourceCodeCredentialLifecycle) {
sync := NewSourceCodeCredentialLifecycleAdapter(name, false, s, lifecycle)
s.AddHandler(name, sync)
}
func (s *sourceCodeCredentialClient) AddClusterScopedHandler(name, clusterName string, sync SourceCodeCredentialHandlerFunc) {
s.Controller().AddClusterScopedHandler(name, clusterName, sync)
}
func (s *sourceCodeCredentialClient) AddClusterScopedLifecycle(name, clusterName string, lifecycle SourceCodeCredentialLifecycle) {
sync := NewSourceCodeCredentialLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.AddClusterScopedHandler(name, clusterName, sync)
}

View File

@@ -0,0 +1,51 @@
package v3
import (
"github.com/rancher/norman/lifecycle"
"k8s.io/apimachinery/pkg/runtime"
)
type SourceCodeCredentialLifecycle interface {
Create(obj *SourceCodeCredential) (*SourceCodeCredential, error)
Remove(obj *SourceCodeCredential) (*SourceCodeCredential, error)
Updated(obj *SourceCodeCredential) (*SourceCodeCredential, error)
}
type sourceCodeCredentialLifecycleAdapter struct {
lifecycle SourceCodeCredentialLifecycle
}
func (w *sourceCodeCredentialLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*SourceCodeCredential))
if o == nil {
return nil, err
}
return o, err
}
func (w *sourceCodeCredentialLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*SourceCodeCredential))
if o == nil {
return nil, err
}
return o, err
}
func (w *sourceCodeCredentialLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*SourceCodeCredential))
if o == nil {
return nil, err
}
return o, err
}
func NewSourceCodeCredentialLifecycleAdapter(name string, clusterScoped bool, client SourceCodeCredentialInterface, l SourceCodeCredentialLifecycle) SourceCodeCredentialHandlerFunc {
adapter := &sourceCodeCredentialLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *SourceCodeCredential) error {
if obj == nil {
return syncFn(key, nil)
}
return syncFn(key, obj)
}
}

View File

@@ -0,0 +1,251 @@
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 (
SourceCodeRepositoryGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "SourceCodeRepository",
}
SourceCodeRepositoryResource = metav1.APIResource{
Name: "sourcecoderepositories",
SingularName: "sourcecoderepository",
Namespaced: false,
Kind: SourceCodeRepositoryGroupVersionKind.Kind,
}
)
type SourceCodeRepositoryList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []SourceCodeRepository
}
type SourceCodeRepositoryHandlerFunc func(key string, obj *SourceCodeRepository) error
type SourceCodeRepositoryLister interface {
List(namespace string, selector labels.Selector) (ret []*SourceCodeRepository, err error)
Get(namespace, name string) (*SourceCodeRepository, error)
}
type SourceCodeRepositoryController interface {
Informer() cache.SharedIndexInformer
Lister() SourceCodeRepositoryLister
AddHandler(name string, handler SourceCodeRepositoryHandlerFunc)
AddClusterScopedHandler(name, clusterName string, handler SourceCodeRepositoryHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type SourceCodeRepositoryInterface interface {
ObjectClient() *clientbase.ObjectClient
Create(*SourceCodeRepository) (*SourceCodeRepository, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*SourceCodeRepository, error)
Get(name string, opts metav1.GetOptions) (*SourceCodeRepository, error)
Update(*SourceCodeRepository) (*SourceCodeRepository, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*SourceCodeRepositoryList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() SourceCodeRepositoryController
AddHandler(name string, sync SourceCodeRepositoryHandlerFunc)
AddLifecycle(name string, lifecycle SourceCodeRepositoryLifecycle)
AddClusterScopedHandler(name, clusterName string, sync SourceCodeRepositoryHandlerFunc)
AddClusterScopedLifecycle(name, clusterName string, lifecycle SourceCodeRepositoryLifecycle)
}
type sourceCodeRepositoryLister struct {
controller *sourceCodeRepositoryController
}
func (l *sourceCodeRepositoryLister) List(namespace string, selector labels.Selector) (ret []*SourceCodeRepository, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*SourceCodeRepository))
})
return
}
func (l *sourceCodeRepositoryLister) Get(namespace, name string) (*SourceCodeRepository, 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: SourceCodeRepositoryGroupVersionKind.Group,
Resource: "sourceCodeRepository",
}, name)
}
return obj.(*SourceCodeRepository), nil
}
type sourceCodeRepositoryController struct {
controller.GenericController
}
func (c *sourceCodeRepositoryController) Lister() SourceCodeRepositoryLister {
return &sourceCodeRepositoryLister{
controller: c,
}
}
func (c *sourceCodeRepositoryController) AddHandler(name string, handler SourceCodeRepositoryHandlerFunc) {
c.GenericController.AddHandler(name, 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.(*SourceCodeRepository))
})
}
func (c *sourceCodeRepositoryController) AddClusterScopedHandler(name, cluster string, handler SourceCodeRepositoryHandlerFunc) {
c.GenericController.AddHandler(name, func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
if err != nil {
return err
}
if !exists {
return handler(key, nil)
}
if !controller.ObjectInCluster(cluster, obj) {
return nil
}
return handler(key, obj.(*SourceCodeRepository))
})
}
type sourceCodeRepositoryFactory struct {
}
func (c sourceCodeRepositoryFactory) Object() runtime.Object {
return &SourceCodeRepository{}
}
func (c sourceCodeRepositoryFactory) List() runtime.Object {
return &SourceCodeRepositoryList{}
}
func (s *sourceCodeRepositoryClient) Controller() SourceCodeRepositoryController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.sourceCodeRepositoryControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(SourceCodeRepositoryGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &sourceCodeRepositoryController{
GenericController: genericController,
}
s.client.sourceCodeRepositoryControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type sourceCodeRepositoryClient struct {
client *Client
ns string
objectClient *clientbase.ObjectClient
controller SourceCodeRepositoryController
}
func (s *sourceCodeRepositoryClient) ObjectClient() *clientbase.ObjectClient {
return s.objectClient
}
func (s *sourceCodeRepositoryClient) Create(o *SourceCodeRepository) (*SourceCodeRepository, error) {
obj, err := s.objectClient.Create(o)
return obj.(*SourceCodeRepository), err
}
func (s *sourceCodeRepositoryClient) Get(name string, opts metav1.GetOptions) (*SourceCodeRepository, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*SourceCodeRepository), err
}
func (s *sourceCodeRepositoryClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*SourceCodeRepository, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*SourceCodeRepository), err
}
func (s *sourceCodeRepositoryClient) Update(o *SourceCodeRepository) (*SourceCodeRepository, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*SourceCodeRepository), err
}
func (s *sourceCodeRepositoryClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *sourceCodeRepositoryClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *sourceCodeRepositoryClient) List(opts metav1.ListOptions) (*SourceCodeRepositoryList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*SourceCodeRepositoryList), err
}
func (s *sourceCodeRepositoryClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *sourceCodeRepositoryClient) Patch(o *SourceCodeRepository, data []byte, subresources ...string) (*SourceCodeRepository, error) {
obj, err := s.objectClient.Patch(o.Name, o, data, subresources...)
return obj.(*SourceCodeRepository), err
}
func (s *sourceCodeRepositoryClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *sourceCodeRepositoryClient) AddHandler(name string, sync SourceCodeRepositoryHandlerFunc) {
s.Controller().AddHandler(name, sync)
}
func (s *sourceCodeRepositoryClient) AddLifecycle(name string, lifecycle SourceCodeRepositoryLifecycle) {
sync := NewSourceCodeRepositoryLifecycleAdapter(name, false, s, lifecycle)
s.AddHandler(name, sync)
}
func (s *sourceCodeRepositoryClient) AddClusterScopedHandler(name, clusterName string, sync SourceCodeRepositoryHandlerFunc) {
s.Controller().AddClusterScopedHandler(name, clusterName, sync)
}
func (s *sourceCodeRepositoryClient) AddClusterScopedLifecycle(name, clusterName string, lifecycle SourceCodeRepositoryLifecycle) {
sync := NewSourceCodeRepositoryLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.AddClusterScopedHandler(name, clusterName, sync)
}

View File

@@ -0,0 +1,51 @@
package v3
import (
"github.com/rancher/norman/lifecycle"
"k8s.io/apimachinery/pkg/runtime"
)
type SourceCodeRepositoryLifecycle interface {
Create(obj *SourceCodeRepository) (*SourceCodeRepository, error)
Remove(obj *SourceCodeRepository) (*SourceCodeRepository, error)
Updated(obj *SourceCodeRepository) (*SourceCodeRepository, error)
}
type sourceCodeRepositoryLifecycleAdapter struct {
lifecycle SourceCodeRepositoryLifecycle
}
func (w *sourceCodeRepositoryLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*SourceCodeRepository))
if o == nil {
return nil, err
}
return o, err
}
func (w *sourceCodeRepositoryLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*SourceCodeRepository))
if o == nil {
return nil, err
}
return o, err
}
func (w *sourceCodeRepositoryLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*SourceCodeRepository))
if o == nil {
return nil, err
}
return o, err
}
func NewSourceCodeRepositoryLifecycleAdapter(name string, clusterScoped bool, client SourceCodeRepositoryInterface, l SourceCodeRepositoryLifecycle) SourceCodeRepositoryHandlerFunc {
adapter := &sourceCodeRepositoryLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *SourceCodeRepository) error {
if obj == nil {
return syncFn(key, nil)
}
return syncFn(key, obj)
}
}