1
0
mirror of https://github.com/rancher/types.git synced 2025-09-19 08:52:46 +00:00

go generate changes

This commit is contained in:
Murali Paluru
2019-06-24 13:48:42 -07:00
committed by Alena Prokharchyk
parent cefb190927
commit 67c773940a
13 changed files with 2204 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,452 @@
package v3
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
"github.com/rancher/norman/resource"
"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/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
ClusterScanGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "ClusterScan",
}
ClusterScanResource = metav1.APIResource{
Name: "clusterscans",
SingularName: "clusterscan",
Namespaced: true,
Kind: ClusterScanGroupVersionKind.Kind,
}
ClusterScanGroupVersionResource = schema.GroupVersionResource{
Group: GroupName,
Version: Version,
Resource: "clusterscans",
}
)
func init() {
resource.Put(ClusterScanGroupVersionResource)
}
func NewClusterScan(namespace, name string, obj ClusterScan) *ClusterScan {
obj.APIVersion, obj.Kind = ClusterScanGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type ClusterScanList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterScan `json:"items"`
}
type ClusterScanHandlerFunc func(key string, obj *ClusterScan) (runtime.Object, error)
type ClusterScanChangeHandlerFunc func(obj *ClusterScan) (runtime.Object, error)
type ClusterScanLister interface {
List(namespace string, selector labels.Selector) (ret []*ClusterScan, err error)
Get(namespace, name string) (*ClusterScan, error)
}
type ClusterScanController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() ClusterScanLister
AddHandler(ctx context.Context, name string, handler ClusterScanHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler ClusterScanHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type ClusterScanInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*ClusterScan) (*ClusterScan, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*ClusterScan, error)
Get(name string, opts metav1.GetOptions) (*ClusterScan, error)
Update(*ClusterScan) (*ClusterScan, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*ClusterScanList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() ClusterScanController
AddHandler(ctx context.Context, name string, sync ClusterScanHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle ClusterScanLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ClusterScanHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ClusterScanLifecycle)
}
type clusterScanLister struct {
controller *clusterScanController
}
func (l *clusterScanLister) List(namespace string, selector labels.Selector) (ret []*ClusterScan, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*ClusterScan))
})
return
}
func (l *clusterScanLister) Get(namespace, name string) (*ClusterScan, 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: ClusterScanGroupVersionKind.Group,
Resource: "clusterScan",
}, key)
}
return obj.(*ClusterScan), nil
}
type clusterScanController struct {
controller.GenericController
}
func (c *clusterScanController) Generic() controller.GenericController {
return c.GenericController
}
func (c *clusterScanController) Lister() ClusterScanLister {
return &clusterScanLister{
controller: c,
}
}
func (c *clusterScanController) AddHandler(ctx context.Context, name string, handler ClusterScanHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*ClusterScan); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *clusterScanController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler ClusterScanHandlerFunc) {
resource.PutClusterScoped(ClusterScanGroupVersionResource)
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*ClusterScan); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type clusterScanFactory struct {
}
func (c clusterScanFactory) Object() runtime.Object {
return &ClusterScan{}
}
func (c clusterScanFactory) List() runtime.Object {
return &ClusterScanList{}
}
func (s *clusterScanClient) Controller() ClusterScanController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.clusterScanControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(ClusterScanGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &clusterScanController{
GenericController: genericController,
}
s.client.clusterScanControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type clusterScanClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller ClusterScanController
}
func (s *clusterScanClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *clusterScanClient) Create(o *ClusterScan) (*ClusterScan, error) {
obj, err := s.objectClient.Create(o)
return obj.(*ClusterScan), err
}
func (s *clusterScanClient) Get(name string, opts metav1.GetOptions) (*ClusterScan, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*ClusterScan), err
}
func (s *clusterScanClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*ClusterScan, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*ClusterScan), err
}
func (s *clusterScanClient) Update(o *ClusterScan) (*ClusterScan, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*ClusterScan), err
}
func (s *clusterScanClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *clusterScanClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *clusterScanClient) List(opts metav1.ListOptions) (*ClusterScanList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*ClusterScanList), err
}
func (s *clusterScanClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *clusterScanClient) Patch(o *ClusterScan, patchType types.PatchType, data []byte, subresources ...string) (*ClusterScan, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*ClusterScan), err
}
func (s *clusterScanClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *clusterScanClient) AddHandler(ctx context.Context, name string, sync ClusterScanHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *clusterScanClient) AddLifecycle(ctx context.Context, name string, lifecycle ClusterScanLifecycle) {
sync := NewClusterScanLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *clusterScanClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ClusterScanHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *clusterScanClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ClusterScanLifecycle) {
sync := NewClusterScanLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type ClusterScanIndexer func(obj *ClusterScan) ([]string, error)
type ClusterScanClientCache interface {
Get(namespace, name string) (*ClusterScan, error)
List(namespace string, selector labels.Selector) ([]*ClusterScan, error)
Index(name string, indexer ClusterScanIndexer)
GetIndexed(name, key string) ([]*ClusterScan, error)
}
type ClusterScanClient interface {
Create(*ClusterScan) (*ClusterScan, error)
Get(namespace, name string, opts metav1.GetOptions) (*ClusterScan, error)
Update(*ClusterScan) (*ClusterScan, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*ClusterScanList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() ClusterScanClientCache
OnCreate(ctx context.Context, name string, sync ClusterScanChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync ClusterScanChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync ClusterScanChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() ClusterScanInterface
}
type clusterScanClientCache struct {
client *clusterScanClient2
}
type clusterScanClient2 struct {
iface ClusterScanInterface
controller ClusterScanController
}
func (n *clusterScanClient2) Interface() ClusterScanInterface {
return n.iface
}
func (n *clusterScanClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *clusterScanClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *clusterScanClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *clusterScanClient2) Create(obj *ClusterScan) (*ClusterScan, error) {
return n.iface.Create(obj)
}
func (n *clusterScanClient2) Get(namespace, name string, opts metav1.GetOptions) (*ClusterScan, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *clusterScanClient2) Update(obj *ClusterScan) (*ClusterScan, error) {
return n.iface.Update(obj)
}
func (n *clusterScanClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *clusterScanClient2) List(namespace string, opts metav1.ListOptions) (*ClusterScanList, error) {
return n.iface.List(opts)
}
func (n *clusterScanClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *clusterScanClientCache) Get(namespace, name string) (*ClusterScan, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *clusterScanClientCache) List(namespace string, selector labels.Selector) ([]*ClusterScan, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *clusterScanClient2) Cache() ClusterScanClientCache {
n.loadController()
return &clusterScanClientCache{
client: n,
}
}
func (n *clusterScanClient2) OnCreate(ctx context.Context, name string, sync ClusterScanChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &clusterScanLifecycleDelegate{create: sync})
}
func (n *clusterScanClient2) OnChange(ctx context.Context, name string, sync ClusterScanChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &clusterScanLifecycleDelegate{update: sync})
}
func (n *clusterScanClient2) OnRemove(ctx context.Context, name string, sync ClusterScanChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &clusterScanLifecycleDelegate{remove: sync})
}
func (n *clusterScanClientCache) Index(name string, indexer ClusterScanIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*ClusterScan); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *clusterScanClientCache) GetIndexed(name, key string) ([]*ClusterScan, error) {
var result []*ClusterScan
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*ClusterScan); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *clusterScanClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type clusterScanLifecycleDelegate struct {
create ClusterScanChangeHandlerFunc
update ClusterScanChangeHandlerFunc
remove ClusterScanChangeHandlerFunc
}
func (n *clusterScanLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *clusterScanLifecycleDelegate) Create(obj *ClusterScan) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *clusterScanLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *clusterScanLifecycleDelegate) Remove(obj *ClusterScan) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *clusterScanLifecycleDelegate) Updated(obj *ClusterScan) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@@ -0,0 +1,62 @@
package v3
import (
"github.com/rancher/norman/lifecycle"
"k8s.io/apimachinery/pkg/runtime"
)
type ClusterScanLifecycle interface {
Create(obj *ClusterScan) (runtime.Object, error)
Remove(obj *ClusterScan) (runtime.Object, error)
Updated(obj *ClusterScan) (runtime.Object, error)
}
type clusterScanLifecycleAdapter struct {
lifecycle ClusterScanLifecycle
}
func (w *clusterScanLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *clusterScanLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *clusterScanLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*ClusterScan))
if o == nil {
return nil, err
}
return o, err
}
func (w *clusterScanLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*ClusterScan))
if o == nil {
return nil, err
}
return o, err
}
func (w *clusterScanLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*ClusterScan))
if o == nil {
return nil, err
}
return o, err
}
func NewClusterScanLifecycleAdapter(name string, clusterScoped bool, client ClusterScanInterface, l ClusterScanLifecycle) ClusterScanHandlerFunc {
adapter := &clusterScanLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *ClusterScan) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@@ -1794,6 +1794,138 @@ func (in *ClusterRoleTemplateBindingList) DeepCopyObject() runtime.Object {
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterScan) DeepCopyInto(out *ClusterScan) {
*out = *in
out.Namespaced = in.Namespaced
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterScan.
func (in *ClusterScan) DeepCopy() *ClusterScan {
if in == nil {
return nil
}
out := new(ClusterScan)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ClusterScan) 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 *ClusterScanCondition) DeepCopyInto(out *ClusterScanCondition) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterScanCondition.
func (in *ClusterScanCondition) DeepCopy() *ClusterScanCondition {
if in == nil {
return nil
}
out := new(ClusterScanCondition)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterScanConfig) DeepCopyInto(out *ClusterScanConfig) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterScanConfig.
func (in *ClusterScanConfig) DeepCopy() *ClusterScanConfig {
if in == nil {
return nil
}
out := new(ClusterScanConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterScanList) DeepCopyInto(out *ClusterScanList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ClusterScan, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterScanList.
func (in *ClusterScanList) DeepCopy() *ClusterScanList {
if in == nil {
return nil
}
out := new(ClusterScanList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ClusterScanList) 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 *ClusterScanSpec) DeepCopyInto(out *ClusterScanSpec) {
*out = *in
out.ScanConfig = in.ScanConfig
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterScanSpec.
func (in *ClusterScanSpec) DeepCopy() *ClusterScanSpec {
if in == nil {
return nil
}
out := new(ClusterScanSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterScanStatus) DeepCopyInto(out *ClusterScanStatus) {
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]ClusterScanCondition, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterScanStatus.
func (in *ClusterScanStatus) DeepCopy() *ClusterScanStatus {
if in == nil {
return nil
}
out := new(ClusterScanStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) {
*out = *in

View File

@@ -71,6 +71,7 @@ type Interface interface {
GlobalDNSProvidersGetter
KontainerDriversGetter
EtcdBackupsGetter
ClusterScansGetter
MonitorMetricsGetter
ClusterMonitorGraphsGetter
ProjectMonitorGraphsGetter
@@ -133,6 +134,7 @@ type Clients struct {
GlobalDNSProvider GlobalDNSProviderClient
KontainerDriver KontainerDriverClient
EtcdBackup EtcdBackupClient
ClusterScan ClusterScanClient
MonitorMetric MonitorMetricClient
ClusterMonitorGraph ClusterMonitorGraphClient
ProjectMonitorGraph ProjectMonitorGraphClient
@@ -197,6 +199,7 @@ type Client struct {
globalDnsProviderControllers map[string]GlobalDNSProviderController
kontainerDriverControllers map[string]KontainerDriverController
etcdBackupControllers map[string]EtcdBackupController
clusterScanControllers map[string]ClusterScanController
monitorMetricControllers map[string]MonitorMetricController
clusterMonitorGraphControllers map[string]ClusterMonitorGraphController
projectMonitorGraphControllers map[string]ProjectMonitorGraphController
@@ -391,6 +394,9 @@ func NewClientsFromInterface(iface Interface) *Clients {
EtcdBackup: &etcdBackupClient2{
iface: iface.EtcdBackups(""),
},
ClusterScan: &clusterScanClient2{
iface: iface.ClusterScans(""),
},
MonitorMetric: &monitorMetricClient2{
iface: iface.MonitorMetrics(""),
},
@@ -476,6 +482,7 @@ func NewForConfig(config rest.Config) (Interface, error) {
globalDnsProviderControllers: map[string]GlobalDNSProviderController{},
kontainerDriverControllers: map[string]KontainerDriverController{},
etcdBackupControllers: map[string]EtcdBackupController{},
clusterScanControllers: map[string]ClusterScanController{},
monitorMetricControllers: map[string]MonitorMetricController{},
clusterMonitorGraphControllers: map[string]ClusterMonitorGraphController{},
projectMonitorGraphControllers: map[string]ProjectMonitorGraphController{},
@@ -1160,6 +1167,19 @@ func (c *Client) EtcdBackups(namespace string) EtcdBackupInterface {
}
}
type ClusterScansGetter interface {
ClusterScans(namespace string) ClusterScanInterface
}
func (c *Client) ClusterScans(namespace string) ClusterScanInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &ClusterScanResource, ClusterScanGroupVersionKind, clusterScanFactory{})
return &clusterScanClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}
type MonitorMetricsGetter interface {
MonitorMetrics(namespace string) MonitorMetricInterface
}

View File

@@ -135,6 +135,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&KontainerDriverList{},
&EtcdBackup{},
&EtcdBackupList{},
&ClusterScan{},
&ClusterScanList{},
&MonitorMetric{},
&MonitorMetricList{},
&ClusterMonitorGraph{},

View File

@@ -57,6 +57,7 @@ type Client struct {
GlobalDNSProvider GlobalDNSProviderOperations
KontainerDriver KontainerDriverOperations
EtcdBackup EtcdBackupOperations
ClusterScan ClusterScanOperations
MonitorMetric MonitorMetricOperations
ClusterMonitorGraph ClusterMonitorGraphOperations
ProjectMonitorGraph ProjectMonitorGraphOperations
@@ -126,6 +127,7 @@ func NewClient(opts *clientbase.ClientOpts) (*Client, error) {
client.GlobalDNSProvider = newGlobalDNSProviderClient(client)
client.KontainerDriver = newKontainerDriverClient(client)
client.EtcdBackup = newEtcdBackupClient(client)
client.ClusterScan = newClusterScanClient(client)
client.MonitorMetric = newMonitorMetricClient(client)
client.ClusterMonitorGraph = newClusterMonitorGraphClient(client)
client.ProjectMonitorGraph = newProjectMonitorGraphClient(client)

View File

@@ -142,6 +142,8 @@ type ClusterOperations interface {
ActionRotateCertificates(resource *Cluster, input *RotateCertificateInput) (*RotateCertificateOutput, error)
ActionRunSecurityScan(resource *Cluster) error
ActionViewMonitoring(resource *Cluster) (*MonitoringOutput, error)
}
@@ -245,6 +247,11 @@ func (c *ClusterClient) ActionRotateCertificates(resource *Cluster, input *Rotat
return resp, err
}
func (c *ClusterClient) ActionRunSecurityScan(resource *Cluster) error {
err := c.apiClient.Ops.DoAction(ClusterType, "runSecurityScan", &resource.Resource, nil, nil)
return err
}
func (c *ClusterClient) ActionViewMonitoring(resource *Cluster) (*MonitoringOutput, error) {
resp := &MonitoringOutput{}
err := c.apiClient.Ops.DoAction(ClusterType, "viewMonitoring", &resource.Resource, nil, resp)

View File

@@ -0,0 +1,117 @@
package client
import (
"github.com/rancher/norman/types"
)
const (
ClusterScanType = "clusterScan"
ClusterScanFieldAnnotations = "annotations"
ClusterScanFieldClusterID = "clusterId"
ClusterScanFieldCreated = "created"
ClusterScanFieldCreatorID = "creatorId"
ClusterScanFieldLabels = "labels"
ClusterScanFieldManual = "manual"
ClusterScanFieldName = "name"
ClusterScanFieldNamespaceId = "namespaceId"
ClusterScanFieldOwnerReferences = "ownerReferences"
ClusterScanFieldRemoved = "removed"
ClusterScanFieldScanConfig = "scanConfig"
ClusterScanFieldScanType = "scanType"
ClusterScanFieldState = "state"
ClusterScanFieldStatus = "status"
ClusterScanFieldTransitioning = "transitioning"
ClusterScanFieldTransitioningMessage = "transitioningMessage"
ClusterScanFieldUUID = "uuid"
)
type ClusterScan struct {
types.Resource
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
ClusterID string `json:"clusterId,omitempty" yaml:"clusterId,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
CreatorID string `json:"creatorId,omitempty" yaml:"creatorId,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
Manual bool `json:"manual,omitempty" yaml:"manual,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
NamespaceId string `json:"namespaceId,omitempty" yaml:"namespaceId,omitempty"`
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty" yaml:"ownerReferences,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
ScanConfig *ClusterScanConfig `json:"scanConfig,omitempty" yaml:"scanConfig,omitempty"`
ScanType string `json:"scanType,omitempty" yaml:"scanType,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Status *ClusterScanStatus `json:"status,omitempty" yaml:"status,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioningMessage,omitempty"`
UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ClusterScanCollection struct {
types.Collection
Data []ClusterScan `json:"data,omitempty"`
client *ClusterScanClient
}
type ClusterScanClient struct {
apiClient *Client
}
type ClusterScanOperations interface {
List(opts *types.ListOpts) (*ClusterScanCollection, error)
Create(opts *ClusterScan) (*ClusterScan, error)
Update(existing *ClusterScan, updates interface{}) (*ClusterScan, error)
Replace(existing *ClusterScan) (*ClusterScan, error)
ByID(id string) (*ClusterScan, error)
Delete(container *ClusterScan) error
}
func newClusterScanClient(apiClient *Client) *ClusterScanClient {
return &ClusterScanClient{
apiClient: apiClient,
}
}
func (c *ClusterScanClient) Create(container *ClusterScan) (*ClusterScan, error) {
resp := &ClusterScan{}
err := c.apiClient.Ops.DoCreate(ClusterScanType, container, resp)
return resp, err
}
func (c *ClusterScanClient) Update(existing *ClusterScan, updates interface{}) (*ClusterScan, error) {
resp := &ClusterScan{}
err := c.apiClient.Ops.DoUpdate(ClusterScanType, &existing.Resource, updates, resp)
return resp, err
}
func (c *ClusterScanClient) Replace(obj *ClusterScan) (*ClusterScan, error) {
resp := &ClusterScan{}
err := c.apiClient.Ops.DoReplace(ClusterScanType, &obj.Resource, obj, resp)
return resp, err
}
func (c *ClusterScanClient) List(opts *types.ListOpts) (*ClusterScanCollection, error) {
resp := &ClusterScanCollection{}
err := c.apiClient.Ops.DoList(ClusterScanType, opts, resp)
resp.client = c
return resp, err
}
func (cc *ClusterScanCollection) Next() (*ClusterScanCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ClusterScanCollection{}
err := cc.client.apiClient.Ops.DoNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ClusterScanClient) ByID(id string) (*ClusterScan, error) {
resp := &ClusterScan{}
err := c.apiClient.Ops.DoByID(ClusterScanType, id, resp)
return resp, err
}
func (c *ClusterScanClient) Delete(container *ClusterScan) error {
return c.apiClient.Ops.DoResourceDelete(ClusterScanType, &container.Resource)
}

View File

@@ -0,0 +1,20 @@
package client
const (
ClusterScanConditionType = "clusterScanCondition"
ClusterScanConditionFieldLastTransitionTime = "lastTransitionTime"
ClusterScanConditionFieldLastUpdateTime = "lastUpdateTime"
ClusterScanConditionFieldMessage = "message"
ClusterScanConditionFieldReason = "reason"
ClusterScanConditionFieldStatus = "status"
ClusterScanConditionFieldType = "type"
)
type ClusterScanCondition struct {
LastTransitionTime string `json:"lastTransitionTime,omitempty" yaml:"lastTransitionTime,omitempty"`
LastUpdateTime string `json:"lastUpdateTime,omitempty" yaml:"lastUpdateTime,omitempty"`
Message string `json:"message,omitempty" yaml:"message,omitempty"`
Reason string `json:"reason,omitempty" yaml:"reason,omitempty"`
Status string `json:"status,omitempty" yaml:"status,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
}

View File

@@ -0,0 +1,8 @@
package client
const (
ClusterScanConfigType = "clusterScanConfig"
)
type ClusterScanConfig struct {
}

View File

@@ -0,0 +1,16 @@
package client
const (
ClusterScanSpecType = "clusterScanSpec"
ClusterScanSpecFieldClusterID = "clusterId"
ClusterScanSpecFieldManual = "manual"
ClusterScanSpecFieldScanConfig = "scanConfig"
ClusterScanSpecFieldScanType = "scanType"
)
type ClusterScanSpec struct {
ClusterID string `json:"clusterId,omitempty" yaml:"clusterId,omitempty"`
Manual bool `json:"manual,omitempty" yaml:"manual,omitempty"`
ScanConfig *ClusterScanConfig `json:"scanConfig,omitempty" yaml:"scanConfig,omitempty"`
ScanType string `json:"scanType,omitempty" yaml:"scanType,omitempty"`
}

View File

@@ -0,0 +1,10 @@
package client
const (
ClusterScanStatusType = "clusterScanStatus"
ClusterScanStatusFieldConditions = "conditions"
)
type ClusterScanStatus struct {
Conditions []ClusterScanCondition `json:"conditions,omitempty" yaml:"conditions,omitempty"`
}