feat: add rbdplugin type

This commit is contained in:
yangk 2022-12-20 10:40:00 +08:00
parent be18a8e6cf
commit cf07d089e4
21 changed files with 856 additions and 27 deletions

View File

@ -0,0 +1,63 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
name: rbdplugins.rainbond.io
spec:
group: rainbond.io
names:
kind: RBDPlugin
listKind: RBDPluginList
plural: rbdplugins
singular: rbdplugin
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: RBDPlugin is the Schema for the rbdplugins API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: RBDPluginSpec defines the desired state of RBDPlugin
properties:
author:
description: Foo is an example field of RBDPlugin. Edit rbdplugin_types.go
to remove/update
type: string
description:
type: string
icon:
type: string
version:
type: string
type: object
status:
description: RBDPluginStatus defines the observed state of RBDPlugin
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

1
go.mod
View File

@ -32,7 +32,6 @@ require (
github.com/go-chi/chi v4.1.2+incompatible
github.com/go-chi/render v1.0.1
github.com/go-kit/kit v0.10.0
github.com/go-playground/assert/v2 v2.0.1
github.com/go-playground/validator/v10 v10.9.0
github.com/go-sql-driver/mysql v1.6.0
github.com/godbus/dbus v4.1.0+incompatible // indirect

View File

@ -0,0 +1,70 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2022-2022 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// RBDPluginSpec defines the desired state of RBDPlugin
type RBDPluginSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// Foo is an example field of RBDPlugin. Edit rbdplugin_types.go to remove/update
Author string `json:"author,omitempty"`
Version string `json:"version,omitempty"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
}
// RBDPluginStatus defines the observed state of RBDPlugin
type RBDPluginStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}
// +genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// RBDPlugin is the Schema for the rbdplugins API
type RBDPlugin struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec RBDPluginSpec `json:"spec,omitempty"`
Status RBDPluginStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// RBDPluginList contains a list of RBDPlugin
type RBDPluginList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []RBDPlugin `json:"items"`
}
func init() {
SchemeBuilder.Register(&RBDPlugin{}, &RBDPluginList{})
}

View File

@ -1,3 +1,4 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
// RAINBOND, Application Management Platform
@ -394,6 +395,95 @@ func (in *Probe) DeepCopy() *Probe {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RBDPlugin) DeepCopyInto(out *RBDPlugin) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
out.Status = in.Status
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RBDPlugin.
func (in *RBDPlugin) DeepCopy() *RBDPlugin {
if in == nil {
return nil
}
out := new(RBDPlugin)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *RBDPlugin) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RBDPluginList) DeepCopyInto(out *RBDPluginList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]RBDPlugin, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RBDPluginList.
func (in *RBDPluginList) DeepCopy() *RBDPluginList {
if in == nil {
return nil
}
out := new(RBDPluginList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *RBDPluginList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RBDPluginSpec) DeepCopyInto(out *RBDPluginSpec) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RBDPluginSpec.
func (in *RBDPluginSpec) DeepCopy() *RBDPluginSpec {
if in == nil {
return nil
}
out := new(RBDPluginSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RBDPluginStatus) DeepCopyInto(out *RBDPluginStatus) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RBDPluginStatus.
func (in *RBDPluginStatus) DeepCopy() *RBDPluginStatus {
if in == nil {
return nil
}
out := new(RBDPluginStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Schematic) DeepCopyInto(out *Schematic) {
*out = *in

View File

@ -22,6 +22,7 @@ package versioned
import (
"fmt"
"net/http"
rainbondv1alpha1 "github.com/goodrain/rainbond/pkg/generated/clientset/versioned/typed/rainbond/v1alpha1"
discovery "k8s.io/client-go/discovery"
@ -57,22 +58,45 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface {
// NewForConfig creates a new Clientset for the given config.
// If config's RateLimiter is not set and QPS and Burst are acceptable,
// NewForConfig will generate a rate-limiter in configShallowCopy.
// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
// where httpClient was generated with rest.HTTPClientFor(c).
func NewForConfig(c *rest.Config) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.UserAgent == "" {
configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent()
}
// share the transport between all clients
httpClient, err := rest.HTTPClientFor(&configShallowCopy)
if err != nil {
return nil, err
}
return NewForConfigAndClient(&configShallowCopy, httpClient)
}
// NewForConfigAndClient creates a new Clientset for the given config and http client.
// Note the http client provided takes precedence over the configured transport values.
// If config's RateLimiter is not set and QPS and Burst are acceptable,
// NewForConfigAndClient will generate a rate-limiter in configShallowCopy.
func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
if configShallowCopy.Burst <= 0 {
return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0")
}
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
}
var cs Clientset
var err error
cs.rainbondV1alpha1, err = rainbondv1alpha1.NewForConfig(&configShallowCopy)
cs.rainbondV1alpha1, err = rainbondv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient)
if err != nil {
return nil, err
}
@ -82,11 +106,11 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
// NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset
cs.rainbondV1alpha1 = rainbondv1alpha1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
cs, err := NewForConfig(c)
if err != nil {
panic(err)
}
return cs
}
// New creates a new Clientset for the given RESTClient.

View File

@ -76,7 +76,10 @@ func (c *Clientset) Tracker() testing.ObjectTracker {
return c.tracker
}
var _ clientset.Interface = &Clientset{}
var (
_ clientset.Interface = &Clientset{}
_ testing.FakeClient = &Clientset{}
)
// RainbondV1alpha1 retrieves the RainbondV1alpha1Client
func (c *Clientset) RainbondV1alpha1() rainbondv1alpha1.RainbondV1alpha1Interface {

View File

@ -39,14 +39,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
// of clientsets, like in:
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.

View File

@ -39,14 +39,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
// of clientsets, like in:
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.

View File

@ -119,7 +119,7 @@ func (c *FakeComponentDefinitions) UpdateStatus(ctx context.Context, componentDe
// Delete takes name of the componentDefinition and deletes it. Returns an error if one occurs.
func (c *FakeComponentDefinitions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(componentdefinitionsResource, c.ns, name), &v1alpha1.ComponentDefinition{})
Invokes(testing.NewDeleteActionWithOptions(componentdefinitionsResource, c.ns, name, opts), &v1alpha1.ComponentDefinition{})
return err
}

View File

@ -119,7 +119,7 @@ func (c *FakeHelmApps) UpdateStatus(ctx context.Context, helmApp *v1alpha1.HelmA
// Delete takes name of the helmApp and deletes it. Returns an error if one occurs.
func (c *FakeHelmApps) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(helmappsResource, c.ns, name), &v1alpha1.HelmApp{})
Invokes(testing.NewDeleteActionWithOptions(helmappsResource, c.ns, name, opts), &v1alpha1.HelmApp{})
return err
}

View File

@ -38,6 +38,10 @@ func (c *FakeRainbondV1alpha1) HelmApps(namespace string) v1alpha1.HelmAppInterf
return &FakeHelmApps{c, namespace}
}
func (c *FakeRainbondV1alpha1) RBDPlugins(namespace string) v1alpha1.RBDPluginInterface {
return &FakeRBDPlugins{c, namespace}
}
func (c *FakeRainbondV1alpha1) ThirdComponents(namespace string) v1alpha1.ThirdComponentInterface {
return &FakeThirdComponents{c, namespace}
}

View File

@ -0,0 +1,144 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
"context"
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
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"
)
// FakeRBDPlugins implements RBDPluginInterface
type FakeRBDPlugins struct {
Fake *FakeRainbondV1alpha1
ns string
}
var rbdpluginsResource = schema.GroupVersionResource{Group: "rainbond.io", Version: "v1alpha1", Resource: "rbdplugins"}
var rbdpluginsKind = schema.GroupVersionKind{Group: "rainbond.io", Version: "v1alpha1", Kind: "RBDPlugin"}
// Get takes name of the rBDPlugin, and returns the corresponding rBDPlugin object, and an error if there is any.
func (c *FakeRBDPlugins) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.RBDPlugin, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(rbdpluginsResource, c.ns, name), &v1alpha1.RBDPlugin{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.RBDPlugin), err
}
// List takes label and field selectors, and returns the list of RBDPlugins that match those selectors.
func (c *FakeRBDPlugins) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RBDPluginList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(rbdpluginsResource, rbdpluginsKind, c.ns, opts), &v1alpha1.RBDPluginList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.RBDPluginList{ListMeta: obj.(*v1alpha1.RBDPluginList).ListMeta}
for _, item := range obj.(*v1alpha1.RBDPluginList).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 rBDPlugins.
func (c *FakeRBDPlugins) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(rbdpluginsResource, c.ns, opts))
}
// Create takes the representation of a rBDPlugin and creates it. Returns the server's representation of the rBDPlugin, and an error, if there is any.
func (c *FakeRBDPlugins) Create(ctx context.Context, rBDPlugin *v1alpha1.RBDPlugin, opts v1.CreateOptions) (result *v1alpha1.RBDPlugin, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(rbdpluginsResource, c.ns, rBDPlugin), &v1alpha1.RBDPlugin{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.RBDPlugin), err
}
// Update takes the representation of a rBDPlugin and updates it. Returns the server's representation of the rBDPlugin, and an error, if there is any.
func (c *FakeRBDPlugins) Update(ctx context.Context, rBDPlugin *v1alpha1.RBDPlugin, opts v1.UpdateOptions) (result *v1alpha1.RBDPlugin, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(rbdpluginsResource, c.ns, rBDPlugin), &v1alpha1.RBDPlugin{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.RBDPlugin), 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 *FakeRBDPlugins) UpdateStatus(ctx context.Context, rBDPlugin *v1alpha1.RBDPlugin, opts v1.UpdateOptions) (*v1alpha1.RBDPlugin, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(rbdpluginsResource, "status", c.ns, rBDPlugin), &v1alpha1.RBDPlugin{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.RBDPlugin), err
}
// Delete takes name of the rBDPlugin and deletes it. Returns an error if one occurs.
func (c *FakeRBDPlugins) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteActionWithOptions(rbdpluginsResource, c.ns, name, opts), &v1alpha1.RBDPlugin{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeRBDPlugins) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(rbdpluginsResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha1.RBDPluginList{})
return err
}
// Patch applies the patch and returns the patched rBDPlugin.
func (c *FakeRBDPlugins) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.RBDPlugin, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(rbdpluginsResource, c.ns, name, pt, data, subresources...), &v1alpha1.RBDPlugin{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.RBDPlugin), err
}

View File

@ -119,7 +119,7 @@ func (c *FakeThirdComponents) UpdateStatus(ctx context.Context, thirdComponent *
// Delete takes name of the thirdComponent and deletes it. Returns an error if one occurs.
func (c *FakeThirdComponents) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(thirdcomponentsResource, c.ns, name), &v1alpha1.ThirdComponent{})
Invokes(testing.NewDeleteActionWithOptions(thirdcomponentsResource, c.ns, name, opts), &v1alpha1.ThirdComponent{})
return err
}

View File

@ -24,4 +24,6 @@ type ComponentDefinitionExpansion interface{}
type HelmAppExpansion interface{}
type RBDPluginExpansion interface{}
type ThirdComponentExpansion interface{}

View File

@ -21,6 +21,8 @@
package v1alpha1
import (
"net/http"
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
"github.com/goodrain/rainbond/pkg/generated/clientset/versioned/scheme"
rest "k8s.io/client-go/rest"
@ -30,6 +32,7 @@ type RainbondV1alpha1Interface interface {
RESTClient() rest.Interface
ComponentDefinitionsGetter
HelmAppsGetter
RBDPluginsGetter
ThirdComponentsGetter
}
@ -46,17 +49,37 @@ func (c *RainbondV1alpha1Client) HelmApps(namespace string) HelmAppInterface {
return newHelmApps(c, namespace)
}
func (c *RainbondV1alpha1Client) RBDPlugins(namespace string) RBDPluginInterface {
return newRBDPlugins(c, namespace)
}
func (c *RainbondV1alpha1Client) ThirdComponents(namespace string) ThirdComponentInterface {
return newThirdComponents(c, namespace)
}
// NewForConfig creates a new RainbondV1alpha1Client for the given config.
// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
// where httpClient was generated with rest.HTTPClientFor(c).
func NewForConfig(c *rest.Config) (*RainbondV1alpha1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
httpClient, err := rest.HTTPClientFor(&config)
if err != nil {
return nil, err
}
return NewForConfigAndClient(&config, httpClient)
}
// NewForConfigAndClient creates a new RainbondV1alpha1Client for the given config and http client.
// Note the http client provided takes precedence over the configured transport values.
func NewForConfigAndClient(c *rest.Config, h *http.Client) (*RainbondV1alpha1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientForConfigAndClient(&config, h)
if err != nil {
return nil, err
}

View File

@ -0,0 +1,197 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
"time"
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
scheme "github.com/goodrain/rainbond/pkg/generated/clientset/versioned/scheme"
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"
)
// RBDPluginsGetter has a method to return a RBDPluginInterface.
// A group's client should implement this interface.
type RBDPluginsGetter interface {
RBDPlugins(namespace string) RBDPluginInterface
}
// RBDPluginInterface has methods to work with RBDPlugin resources.
type RBDPluginInterface interface {
Create(ctx context.Context, rBDPlugin *v1alpha1.RBDPlugin, opts v1.CreateOptions) (*v1alpha1.RBDPlugin, error)
Update(ctx context.Context, rBDPlugin *v1alpha1.RBDPlugin, opts v1.UpdateOptions) (*v1alpha1.RBDPlugin, error)
UpdateStatus(ctx context.Context, rBDPlugin *v1alpha1.RBDPlugin, opts v1.UpdateOptions) (*v1alpha1.RBDPlugin, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.RBDPlugin, error)
List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.RBDPluginList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.RBDPlugin, err error)
RBDPluginExpansion
}
// rBDPlugins implements RBDPluginInterface
type rBDPlugins struct {
client rest.Interface
ns string
}
// newRBDPlugins returns a RBDPlugins
func newRBDPlugins(c *RainbondV1alpha1Client, namespace string) *rBDPlugins {
return &rBDPlugins{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the rBDPlugin, and returns the corresponding rBDPlugin object, and an error if there is any.
func (c *rBDPlugins) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.RBDPlugin, err error) {
result = &v1alpha1.RBDPlugin{}
err = c.client.Get().
Namespace(c.ns).
Resource("rbdplugins").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of RBDPlugins that match those selectors.
func (c *rBDPlugins) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RBDPluginList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.RBDPluginList{}
err = c.client.Get().
Namespace(c.ns).
Resource("rbdplugins").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested rBDPlugins.
func (c *rBDPlugins) Watch(ctx context.Context, 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("rbdplugins").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a rBDPlugin and creates it. Returns the server's representation of the rBDPlugin, and an error, if there is any.
func (c *rBDPlugins) Create(ctx context.Context, rBDPlugin *v1alpha1.RBDPlugin, opts v1.CreateOptions) (result *v1alpha1.RBDPlugin, err error) {
result = &v1alpha1.RBDPlugin{}
err = c.client.Post().
Namespace(c.ns).
Resource("rbdplugins").
VersionedParams(&opts, scheme.ParameterCodec).
Body(rBDPlugin).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a rBDPlugin and updates it. Returns the server's representation of the rBDPlugin, and an error, if there is any.
func (c *rBDPlugins) Update(ctx context.Context, rBDPlugin *v1alpha1.RBDPlugin, opts v1.UpdateOptions) (result *v1alpha1.RBDPlugin, err error) {
result = &v1alpha1.RBDPlugin{}
err = c.client.Put().
Namespace(c.ns).
Resource("rbdplugins").
Name(rBDPlugin.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(rBDPlugin).
Do(ctx).
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 *rBDPlugins) UpdateStatus(ctx context.Context, rBDPlugin *v1alpha1.RBDPlugin, opts v1.UpdateOptions) (result *v1alpha1.RBDPlugin, err error) {
result = &v1alpha1.RBDPlugin{}
err = c.client.Put().
Namespace(c.ns).
Resource("rbdplugins").
Name(rBDPlugin.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(rBDPlugin).
Do(ctx).
Into(result)
return
}
// Delete takes name of the rBDPlugin and deletes it. Returns an error if one occurs.
func (c *rBDPlugins) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("rbdplugins").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *rBDPlugins) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("rbdplugins").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched rBDPlugin.
func (c *rBDPlugins) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.RBDPlugin, err error) {
result = &v1alpha1.RBDPlugin{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("rbdplugins").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@ -59,6 +59,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
return &genericInformer{resource: resource.GroupResource(), informer: f.Rainbond().V1alpha1().ComponentDefinitions().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("helmapps"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Rainbond().V1alpha1().HelmApps().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("rbdplugins"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Rainbond().V1alpha1().RBDPlugins().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("thirdcomponents"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Rainbond().V1alpha1().ThirdComponents().Informer()}, nil

View File

@ -30,6 +30,8 @@ type Interface interface {
ComponentDefinitions() ComponentDefinitionInformer
// HelmApps returns a HelmAppInformer.
HelmApps() HelmAppInformer
// RBDPlugins returns a RBDPluginInformer.
RBDPlugins() RBDPluginInformer
// ThirdComponents returns a ThirdComponentInformer.
ThirdComponents() ThirdComponentInformer
}
@ -55,6 +57,11 @@ func (v *version) HelmApps() HelmAppInformer {
return &helmAppInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// RBDPlugins returns a RBDPluginInformer.
func (v *version) RBDPlugins() RBDPluginInformer {
return &rBDPluginInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// ThirdComponents returns a ThirdComponentInformer.
func (v *version) ThirdComponents() ThirdComponentInformer {
return &thirdComponentInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}

View File

@ -0,0 +1,92 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by informer-gen. DO NOT EDIT.
package v1alpha1
import (
"context"
time "time"
rainbondv1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
versioned "github.com/goodrain/rainbond/pkg/generated/clientset/versioned"
internalinterfaces "github.com/goodrain/rainbond/pkg/generated/informers/externalversions/internalinterfaces"
v1alpha1 "github.com/goodrain/rainbond/pkg/generated/listers/rainbond/v1alpha1"
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"
)
// RBDPluginInformer provides access to a shared informer and lister for
// RBDPlugins.
type RBDPluginInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha1.RBDPluginLister
}
type rBDPluginInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewRBDPluginInformer constructs a new informer for RBDPlugin 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 NewRBDPluginInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredRBDPluginInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredRBDPluginInformer constructs a new informer for RBDPlugin 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 NewFilteredRBDPluginInformer(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.RainbondV1alpha1().RBDPlugins(namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.RainbondV1alpha1().RBDPlugins(namespace).Watch(context.TODO(), options)
},
},
&rainbondv1alpha1.RBDPlugin{},
resyncPeriod,
indexers,
)
}
func (f *rBDPluginInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredRBDPluginInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *rBDPluginInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&rainbondv1alpha1.RBDPlugin{}, f.defaultInformer)
}
func (f *rBDPluginInformer) Lister() v1alpha1.RBDPluginLister {
return v1alpha1.NewRBDPluginLister(f.Informer().GetIndexer())
}

View File

@ -36,6 +36,14 @@ type HelmAppListerExpansion interface{}
// HelmAppNamespaceLister.
type HelmAppNamespaceListerExpansion interface{}
// RBDPluginListerExpansion allows custom methods to be added to
// RBDPluginLister.
type RBDPluginListerExpansion interface{}
// RBDPluginNamespaceListerExpansion allows custom methods to be added to
// RBDPluginNamespaceLister.
type RBDPluginNamespaceListerExpansion interface{}
// ThirdComponentListerExpansion allows custom methods to be added to
// ThirdComponentLister.
type ThirdComponentListerExpansion interface{}

View File

@ -0,0 +1,101 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2021 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Code generated by lister-gen. DO NOT EDIT.
package v1alpha1
import (
v1alpha1 "github.com/goodrain/rainbond/pkg/apis/rainbond/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// RBDPluginLister helps list RBDPlugins.
// All objects returned here must be treated as read-only.
type RBDPluginLister interface {
// List lists all RBDPlugins in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.RBDPlugin, err error)
// RBDPlugins returns an object that can list and get RBDPlugins.
RBDPlugins(namespace string) RBDPluginNamespaceLister
RBDPluginListerExpansion
}
// rBDPluginLister implements the RBDPluginLister interface.
type rBDPluginLister struct {
indexer cache.Indexer
}
// NewRBDPluginLister returns a new RBDPluginLister.
func NewRBDPluginLister(indexer cache.Indexer) RBDPluginLister {
return &rBDPluginLister{indexer: indexer}
}
// List lists all RBDPlugins in the indexer.
func (s *rBDPluginLister) List(selector labels.Selector) (ret []*v1alpha1.RBDPlugin, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.RBDPlugin))
})
return ret, err
}
// RBDPlugins returns an object that can list and get RBDPlugins.
func (s *rBDPluginLister) RBDPlugins(namespace string) RBDPluginNamespaceLister {
return rBDPluginNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// RBDPluginNamespaceLister helps list and get RBDPlugins.
// All objects returned here must be treated as read-only.
type RBDPluginNamespaceLister interface {
// List lists all RBDPlugins in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha1.RBDPlugin, err error)
// Get retrieves the RBDPlugin from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*v1alpha1.RBDPlugin, error)
RBDPluginNamespaceListerExpansion
}
// rBDPluginNamespaceLister implements the RBDPluginNamespaceLister
// interface.
type rBDPluginNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all RBDPlugins in the indexer for a given namespace.
func (s rBDPluginNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.RBDPlugin, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.RBDPlugin))
})
return ret, err
}
// Get retrieves the RBDPlugin from the indexer for a given namespace and name.
func (s rBDPluginNamespaceLister) Get(name string) (*v1alpha1.RBDPlugin, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("rbdplugin"), name)
}
return obj.(*v1alpha1.RBDPlugin), nil
}