pipeline crd

Signed-off-by: runzexia <runzexia@yunify.com>
This commit is contained in:
runzexia
2020-03-25 10:58:39 +08:00
parent 7a00f9e3e4
commit 23c8d71a5a
28 changed files with 3031 additions and 612 deletions

View File

@@ -27,6 +27,7 @@ import (
type DevopsV1alpha3Interface interface {
RESTClient() rest.Interface
DevOpsProjectsGetter
PipelinesGetter
}
// DevopsV1alpha3Client is used to interact with features provided by the devops.kubesphere.io group.
@@ -38,6 +39,10 @@ func (c *DevopsV1alpha3Client) DevOpsProjects() DevOpsProjectInterface {
return newDevOpsProjects(c)
}
func (c *DevopsV1alpha3Client) Pipelines(namespace string) PipelineInterface {
return newPipelines(c, namespace)
}
// NewForConfig creates a new DevopsV1alpha3Client for the given config.
func NewForConfig(c *rest.Config) (*DevopsV1alpha3Client, error) {
config := *c

View File

@@ -32,6 +32,10 @@ func (c *FakeDevopsV1alpha3) DevOpsProjects() v1alpha3.DevOpsProjectInterface {
return &FakeDevOpsProjects{c}
}
func (c *FakeDevopsV1alpha3) Pipelines(namespace string) v1alpha3.PipelineInterface {
return &FakePipelines{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeDevopsV1alpha3) RESTClient() rest.Interface {

View File

@@ -0,0 +1,140 @@
/*
Copyright 2019 The KubeSphere authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
v1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"
)
// FakePipelines implements PipelineInterface
type FakePipelines struct {
Fake *FakeDevopsV1alpha3
ns string
}
var pipelinesResource = schema.GroupVersionResource{Group: "devops.kubesphere.io", Version: "v1alpha3", Resource: "pipelines"}
var pipelinesKind = schema.GroupVersionKind{Group: "devops.kubesphere.io", Version: "v1alpha3", Kind: "Pipeline"}
// Get takes name of the pipeline, and returns the corresponding pipeline object, and an error if there is any.
func (c *FakePipelines) Get(name string, options v1.GetOptions) (result *v1alpha3.Pipeline, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(pipelinesResource, c.ns, name), &v1alpha3.Pipeline{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha3.Pipeline), err
}
// List takes label and field selectors, and returns the list of Pipelines that match those selectors.
func (c *FakePipelines) List(opts v1.ListOptions) (result *v1alpha3.PipelineList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(pipelinesResource, pipelinesKind, c.ns, opts), &v1alpha3.PipelineList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha3.PipelineList{ListMeta: obj.(*v1alpha3.PipelineList).ListMeta}
for _, item := range obj.(*v1alpha3.PipelineList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested pipelines.
func (c *FakePipelines) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(pipelinesResource, c.ns, opts))
}
// Create takes the representation of a pipeline and creates it. Returns the server's representation of the pipeline, and an error, if there is any.
func (c *FakePipelines) Create(pipeline *v1alpha3.Pipeline) (result *v1alpha3.Pipeline, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(pipelinesResource, c.ns, pipeline), &v1alpha3.Pipeline{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha3.Pipeline), err
}
// Update takes the representation of a pipeline and updates it. Returns the server's representation of the pipeline, and an error, if there is any.
func (c *FakePipelines) Update(pipeline *v1alpha3.Pipeline) (result *v1alpha3.Pipeline, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(pipelinesResource, c.ns, pipeline), &v1alpha3.Pipeline{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha3.Pipeline), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakePipelines) UpdateStatus(pipeline *v1alpha3.Pipeline) (*v1alpha3.Pipeline, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(pipelinesResource, "status", c.ns, pipeline), &v1alpha3.Pipeline{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha3.Pipeline), err
}
// Delete takes name of the pipeline and deletes it. Returns an error if one occurs.
func (c *FakePipelines) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(pipelinesResource, c.ns, name), &v1alpha3.Pipeline{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakePipelines) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(pipelinesResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v1alpha3.PipelineList{})
return err
}
// Patch applies the patch and returns the patched pipeline.
func (c *FakePipelines) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.Pipeline, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(pipelinesResource, c.ns, name, pt, data, subresources...), &v1alpha3.Pipeline{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha3.Pipeline), err
}

View File

@@ -19,3 +19,5 @@ limitations under the License.
package v1alpha3
type DevOpsProjectExpansion interface{}
type PipelineExpansion interface{}

View File

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

View File

@@ -26,6 +26,8 @@ import (
type Interface interface {
// DevOpsProjects returns a DevOpsProjectInformer.
DevOpsProjects() DevOpsProjectInformer
// Pipelines returns a PipelineInformer.
Pipelines() PipelineInformer
}
type version struct {
@@ -43,3 +45,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
func (v *version) DevOpsProjects() DevOpsProjectInformer {
return &devOpsProjectInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}
// Pipelines returns a PipelineInformer.
func (v *version) Pipelines() PipelineInformer {
return &pipelineInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}

View File

@@ -0,0 +1,89 @@
/*
Copyright 2019 The KubeSphere authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha3
import (
time "time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
devopsv1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"
versioned "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces"
v1alpha3 "kubesphere.io/kubesphere/pkg/client/listers/devops/v1alpha3"
)
// PipelineInformer provides access to a shared informer and lister for
// Pipelines.
type PipelineInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha3.PipelineLister
}
type pipelineInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewPipelineInformer constructs a new informer for Pipeline type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewPipelineInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredPipelineInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredPipelineInformer constructs a new informer for Pipeline type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredPipelineInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.DevopsV1alpha3().Pipelines(namespace).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.DevopsV1alpha3().Pipelines(namespace).Watch(options)
},
},
&devopsv1alpha3.Pipeline{},
resyncPeriod,
indexers,
)
}
func (f *pipelineInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredPipelineInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *pipelineInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&devopsv1alpha3.Pipeline{}, f.defaultInformer)
}
func (f *pipelineInformer) Lister() v1alpha3.PipelineLister {
return v1alpha3.NewPipelineLister(f.Informer().GetIndexer())
}

View File

@@ -69,6 +69,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
// Group=devops.kubesphere.io, Version=v1alpha3
case v1alpha3.SchemeGroupVersion.WithResource("devopsprojects"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Devops().V1alpha3().DevOpsProjects().Informer()}, nil
case v1alpha3.SchemeGroupVersion.WithResource("pipelines"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Devops().V1alpha3().Pipelines().Informer()}, nil
// Group=network.kubesphere.io, Version=v1alpha1
case networkv1alpha1.SchemeGroupVersion.WithResource("namespacenetworkpolicies"):

View File

@@ -21,3 +21,11 @@ package v1alpha3
// DevOpsProjectListerExpansion allows custom methods to be added to
// DevOpsProjectLister.
type DevOpsProjectListerExpansion interface{}
// PipelineListerExpansion allows custom methods to be added to
// PipelineLister.
type PipelineListerExpansion interface{}
// PipelineNamespaceListerExpansion allows custom methods to be added to
// PipelineNamespaceLister.
type PipelineNamespaceListerExpansion interface{}

View File

@@ -0,0 +1,94 @@
/*
Copyright 2019 The KubeSphere authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha3
import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
v1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"
)
// PipelineLister helps list Pipelines.
type PipelineLister interface {
// List lists all Pipelines in the indexer.
List(selector labels.Selector) (ret []*v1alpha3.Pipeline, err error)
// Pipelines returns an object that can list and get Pipelines.
Pipelines(namespace string) PipelineNamespaceLister
PipelineListerExpansion
}
// pipelineLister implements the PipelineLister interface.
type pipelineLister struct {
indexer cache.Indexer
}
// NewPipelineLister returns a new PipelineLister.
func NewPipelineLister(indexer cache.Indexer) PipelineLister {
return &pipelineLister{indexer: indexer}
}
// List lists all Pipelines in the indexer.
func (s *pipelineLister) List(selector labels.Selector) (ret []*v1alpha3.Pipeline, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha3.Pipeline))
})
return ret, err
}
// Pipelines returns an object that can list and get Pipelines.
func (s *pipelineLister) Pipelines(namespace string) PipelineNamespaceLister {
return pipelineNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// PipelineNamespaceLister helps list and get Pipelines.
type PipelineNamespaceLister interface {
// List lists all Pipelines in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1alpha3.Pipeline, err error)
// Get retrieves the Pipeline from the indexer for a given namespace and name.
Get(name string) (*v1alpha3.Pipeline, error)
PipelineNamespaceListerExpansion
}
// pipelineNamespaceLister implements the PipelineNamespaceLister
// interface.
type pipelineNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all Pipelines in the indexer for a given namespace.
func (s pipelineNamespaceLister) List(selector labels.Selector) (ret []*v1alpha3.Pipeline, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha3.Pipeline))
})
return ret, err
}
// Get retrieves the Pipeline from the indexer for a given namespace and name.
func (s pipelineNamespaceLister) Get(name string) (*v1alpha3.Pipeline, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha3.Resource("pipeline"), name)
}
return obj.(*v1alpha3.Pipeline), nil
}