mirror of
https://github.com/rancher/types.git
synced 2025-09-14 05:50:19 +00:00
committed by
Arvind Iyengar
parent
1acf60e1b7
commit
b0ae09903c
2
vendor/github.com/google/gofuzz/README.md
generated
vendored
2
vendor/github.com/google/gofuzz/README.md
generated
vendored
@@ -3,7 +3,7 @@ gofuzz
|
||||
|
||||
gofuzz is a library for populating go objects with random values.
|
||||
|
||||
[](https://godoc.org/github.com/google/gofuzz)
|
||||
[](https://godoc.org/github.com/google/gofuzz)
|
||||
[](https://travis-ci.org/google/gofuzz)
|
||||
|
||||
This is useful for testing:
|
||||
|
35
vendor/github.com/google/gofuzz/fuzz.go
generated
vendored
35
vendor/github.com/google/gofuzz/fuzz.go
generated
vendored
@@ -20,6 +20,7 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -28,13 +29,14 @@ type fuzzFuncMap map[reflect.Type]reflect.Value
|
||||
|
||||
// Fuzzer knows how to fill any object with random fields.
|
||||
type Fuzzer struct {
|
||||
fuzzFuncs fuzzFuncMap
|
||||
defaultFuzzFuncs fuzzFuncMap
|
||||
r *rand.Rand
|
||||
nilChance float64
|
||||
minElements int
|
||||
maxElements int
|
||||
maxDepth int
|
||||
fuzzFuncs fuzzFuncMap
|
||||
defaultFuzzFuncs fuzzFuncMap
|
||||
r *rand.Rand
|
||||
nilChance float64
|
||||
minElements int
|
||||
maxElements int
|
||||
maxDepth int
|
||||
skipFieldPatterns []*regexp.Regexp
|
||||
}
|
||||
|
||||
// New returns a new Fuzzer. Customize your Fuzzer further by calling Funcs,
|
||||
@@ -150,6 +152,13 @@ func (f *Fuzzer) MaxDepth(d int) *Fuzzer {
|
||||
return f
|
||||
}
|
||||
|
||||
// Skip fields which match the supplied pattern. Call this multiple times if needed
|
||||
// This is useful to skip XXX_ fields generated by protobuf
|
||||
func (f *Fuzzer) SkipFieldsWithPattern(pattern *regexp.Regexp) *Fuzzer {
|
||||
f.skipFieldPatterns = append(f.skipFieldPatterns, pattern)
|
||||
return f
|
||||
}
|
||||
|
||||
// Fuzz recursively fills all of obj's fields with something random. First
|
||||
// this tries to find a custom fuzz function (see Funcs). If there is no
|
||||
// custom function this tests whether the object implements fuzz.Interface and,
|
||||
@@ -274,7 +283,17 @@ func (fc *fuzzerContext) doFuzz(v reflect.Value, flags uint64) {
|
||||
v.Set(reflect.Zero(v.Type()))
|
||||
case reflect.Struct:
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
fc.doFuzz(v.Field(i), 0)
|
||||
skipField := false
|
||||
fieldName := v.Type().Field(i).Name
|
||||
for _, pattern := range fc.fuzzer.skipFieldPatterns {
|
||||
if pattern.MatchString(fieldName) {
|
||||
skipField = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !skipField {
|
||||
fc.doFuzz(v.Field(i), 0)
|
||||
}
|
||||
}
|
||||
case reflect.Chan:
|
||||
fallthrough
|
||||
|
46
vendor/github.com/rancher/norman/controller/cluster_check.go
generated
vendored
46
vendor/github.com/rancher/norman/controller/cluster_check.go
generated
vendored
@@ -1,12 +1,58 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
type ObjectClusterName interface {
|
||||
ObjClusterName() string
|
||||
}
|
||||
|
||||
func ObjectInCluster(cluster string, obj interface{}) bool {
|
||||
// Check if the object implements the interface, this is best case and
|
||||
// what objects should strive to be
|
||||
if o, ok := obj.(ObjectClusterName); ok {
|
||||
return o.ObjClusterName() == cluster
|
||||
}
|
||||
|
||||
// For types outside of rancher, attempt to check the anno, then use the namespace
|
||||
// This is much better than using the reflect hole below
|
||||
switch v := obj.(type) {
|
||||
case *corev1.Secret:
|
||||
if c, ok := v.Annotations["field.cattle.io/projectId"]; ok {
|
||||
if parts := strings.SplitN(c, ":", 2); len(parts) == 2 {
|
||||
return cluster == parts[0]
|
||||
}
|
||||
}
|
||||
return v.Namespace == cluster
|
||||
case *corev1.Namespace:
|
||||
if c, ok := v.Annotations["field.cattle.io/projectId"]; ok {
|
||||
if parts := strings.SplitN(c, ":", 2); len(parts) == 2 {
|
||||
return cluster == parts[0]
|
||||
}
|
||||
}
|
||||
return v.Namespace == cluster
|
||||
case *corev1.Node:
|
||||
if c, ok := v.Annotations["field.cattle.io/projectId"]; ok {
|
||||
if parts := strings.SplitN(c, ":", 2); len(parts) == 2 {
|
||||
return cluster == parts[0]
|
||||
}
|
||||
}
|
||||
return v.Namespace == cluster
|
||||
}
|
||||
|
||||
// Seeing this message means something needs to be done with the type, see comments above
|
||||
if dm := os.Getenv("CATTLE_DEV_MODE"); dm != "" {
|
||||
logrus.Errorf("ObjectClusterName not implemented by type %T", obj)
|
||||
}
|
||||
|
||||
var clusterName string
|
||||
|
||||
if c := getValue(obj, "ClusterName"); c.IsValid() {
|
||||
clusterName = c.String()
|
||||
}
|
||||
|
8
vendor/github.com/rancher/norman/controller/generic_controller.go
generated
vendored
8
vendor/github.com/rancher/norman/controller/generic_controller.go
generated
vendored
@@ -224,14 +224,14 @@ func (g *genericController) sync(ctx context.Context) (retErr error) {
|
||||
DeleteFunc: g.queueObject,
|
||||
})
|
||||
|
||||
logrus.Debugf("Syncing %s Controller", g.name)
|
||||
logrus.Tracef("Syncing %s Controller", g.name)
|
||||
|
||||
go g.informer.Run(ctx.Done())
|
||||
|
||||
if !cache.WaitForCacheSync(ctx.Done(), g.informer.HasSynced) {
|
||||
return fmt.Errorf("failed to sync controller %s", g.name)
|
||||
}
|
||||
logrus.Debugf("Syncing %s Controller Done", g.name)
|
||||
logrus.Tracef("Syncing %s Controller Done", g.name)
|
||||
|
||||
g.synced = true
|
||||
return nil
|
||||
@@ -300,7 +300,7 @@ func (g *genericController) processNextWorkItem() bool {
|
||||
}
|
||||
if _, ok := checkErr.(*ForgetError); err == nil || ok {
|
||||
if ok {
|
||||
logrus.Debugf("%v %v completed with dropped err: %v", g.name, key, err)
|
||||
logrus.Tracef("%v %v completed with dropped err: %v", g.name, key, err)
|
||||
}
|
||||
g.queue.Forget(key)
|
||||
return true
|
||||
@@ -381,7 +381,7 @@ func (g *genericController) syncHandler(key interface{}) (err error) {
|
||||
continue
|
||||
}
|
||||
|
||||
logrus.Debugf("%s calling handler %s %s", g.name, handler.name, s)
|
||||
logrus.Tracef("%s calling handler %s %s", g.name, handler.name, s)
|
||||
metrics.IncTotalHandlerExecution(g.name, handler.name)
|
||||
var newObj interface{}
|
||||
if newObj, err = handler.handler(s, obj); err != nil {
|
||||
|
39
vendor/github.com/rancher/norman/objectclient/object_client.go
generated
vendored
39
vendor/github.com/rancher/norman/objectclient/object_client.go
generated
vendored
@@ -1,6 +1,7 @@
|
||||
package objectclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -127,13 +128,13 @@ func (p *ObjectClient) Create(o runtime.Object) (runtime.Object, error) {
|
||||
}
|
||||
}
|
||||
result := p.Factory.Object()
|
||||
logrus.Debugf("REST CREATE %s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, ns, p.resource.Name)
|
||||
logrus.Tracef("REST CREATE %s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, ns, p.resource.Name)
|
||||
err := p.restClient.Post().
|
||||
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||
NamespaceIfScoped(ns, p.resource.Namespaced).
|
||||
Resource(p.resource.Name).
|
||||
Body(o).
|
||||
Do().
|
||||
Do(context.TODO()).
|
||||
Into(result)
|
||||
return result, err
|
||||
}
|
||||
@@ -149,9 +150,9 @@ func (p *ObjectClient) GetNamespaced(namespace, name string, opts metav1.GetOpti
|
||||
Resource(p.resource.Name).
|
||||
VersionedParams(&opts, metav1.ParameterCodec).
|
||||
Name(name).
|
||||
Do().
|
||||
Do(context.TODO()).
|
||||
Into(result)
|
||||
logrus.Debugf("REST GET %s/%s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, namespace, p.resource.Name, name)
|
||||
logrus.Tracef("REST GET %s/%s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, namespace, p.resource.Name, name)
|
||||
return result, err
|
||||
|
||||
}
|
||||
@@ -164,9 +165,9 @@ func (p *ObjectClient) Get(name string, opts metav1.GetOptions) (runtime.Object,
|
||||
Resource(p.resource.Name).
|
||||
VersionedParams(&opts, metav1.ParameterCodec).
|
||||
Name(name).
|
||||
Do().
|
||||
Do(context.TODO()).
|
||||
Into(result)
|
||||
logrus.Debugf("REST GET %s/%s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, p.ns, p.resource.Name, name)
|
||||
logrus.Tracef("REST GET %s/%s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, p.ns, p.resource.Name, name)
|
||||
return result, err
|
||||
}
|
||||
|
||||
@@ -179,14 +180,14 @@ func (p *ObjectClient) Update(name string, o runtime.Object) (runtime.Object, er
|
||||
if len(name) == 0 {
|
||||
return result, errors.New("object missing name")
|
||||
}
|
||||
logrus.Debugf("REST UPDATE %s/%s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, ns, p.resource.Name, name)
|
||||
logrus.Tracef("REST UPDATE %s/%s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, ns, p.resource.Name, name)
|
||||
err := p.restClient.Put().
|
||||
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||
NamespaceIfScoped(ns, p.resource.Namespaced).
|
||||
Resource(p.resource.Name).
|
||||
Name(name).
|
||||
Body(o).
|
||||
Do().
|
||||
Do(context.TODO()).
|
||||
Into(result)
|
||||
return result, err
|
||||
}
|
||||
@@ -197,47 +198,47 @@ func (p *ObjectClient) DeleteNamespaced(namespace, name string, opts *metav1.Del
|
||||
if namespace != "" {
|
||||
req = req.Namespace(namespace)
|
||||
}
|
||||
logrus.Debugf("REST DELETE %s/%s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, namespace, p.resource.Name, name)
|
||||
logrus.Tracef("REST DELETE %s/%s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, namespace, p.resource.Name, name)
|
||||
return req.Resource(p.resource.Name).
|
||||
Name(name).
|
||||
Body(opts).
|
||||
Do().
|
||||
Do(context.TODO()).
|
||||
Error()
|
||||
}
|
||||
|
||||
func (p *ObjectClient) Delete(name string, opts *metav1.DeleteOptions) error {
|
||||
logrus.Debugf("REST DELETE %s/%s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, p.ns, p.resource.Name, name)
|
||||
logrus.Tracef("REST DELETE %s/%s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, p.ns, p.resource.Name, name)
|
||||
return p.restClient.Delete().
|
||||
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||
Resource(p.resource.Name).
|
||||
Name(name).
|
||||
Body(opts).
|
||||
Do().
|
||||
Do(context.TODO()).
|
||||
Error()
|
||||
}
|
||||
|
||||
func (p *ObjectClient) List(opts metav1.ListOptions) (runtime.Object, error) {
|
||||
result := p.Factory.List()
|
||||
logrus.Debugf("REST LIST %s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, p.ns, p.resource.Name)
|
||||
logrus.Tracef("REST LIST %s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, p.ns, p.resource.Name)
|
||||
return result, p.restClient.Get().
|
||||
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||
Resource(p.resource.Name).
|
||||
VersionedParams(&opts, metav1.ParameterCodec).
|
||||
Do().
|
||||
Do(context.TODO()).
|
||||
Into(result)
|
||||
}
|
||||
|
||||
func (p *ObjectClient) ListNamespaced(namespace string, opts metav1.ListOptions) (runtime.Object, error) {
|
||||
result := p.Factory.List()
|
||||
logrus.Debugf("REST LIST %s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, namespace, p.resource.Name)
|
||||
logrus.Tracef("REST LIST %s/%s/%s/%s/%s", p.getAPIPrefix(), p.gvk.Group, p.gvk.Version, namespace, p.resource.Name)
|
||||
return result, p.restClient.Get().
|
||||
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||
NamespaceIfScoped(namespace, p.resource.Namespaced).
|
||||
Resource(p.resource.Name).
|
||||
VersionedParams(&opts, metav1.ParameterCodec).
|
||||
Do().
|
||||
Do(context.TODO()).
|
||||
Into(result)
|
||||
}
|
||||
|
||||
@@ -253,7 +254,7 @@ func (p *ObjectClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||
Resource(p.resource.Name).
|
||||
VersionedParams(&opts, metav1.ParameterCodec).
|
||||
Stream()
|
||||
Stream(context.TODO())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -302,7 +303,7 @@ func (p *ObjectClient) DeleteCollection(deleteOptions *metav1.DeleteOptions, lis
|
||||
Resource(p.resource.Name).
|
||||
VersionedParams(&listOptions, metav1.ParameterCodec).
|
||||
Body(deleteOptions).
|
||||
Do().
|
||||
Do(context.TODO()).
|
||||
Error()
|
||||
}
|
||||
|
||||
@@ -322,7 +323,7 @@ func (p *ObjectClient) Patch(name string, o runtime.Object, patchType types.Patc
|
||||
SubResource(subresources...).
|
||||
Name(name).
|
||||
Body(data).
|
||||
Do().
|
||||
Do(context.TODO()).
|
||||
Into(result)
|
||||
return result, err
|
||||
}
|
||||
|
17
vendor/github.com/rancher/norman/store/proxy/proxy_store.go
generated
vendored
17
vendor/github.com/rancher/norman/store/proxy/proxy_store.go
generated
vendored
@@ -128,13 +128,13 @@ func (s *Store) getUser(apiContext *types.APIContext) string {
|
||||
func (s *Store) doAuthed(apiContext *types.APIContext, request *rest.Request) rest.Result {
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
logrus.Debug("GET: ", time.Now().Sub(start), s.resourcePlural)
|
||||
logrus.Tracef("GET: %v, %v", time.Now().Sub(start), s.resourcePlural)
|
||||
}()
|
||||
|
||||
for _, header := range authHeaders {
|
||||
request.SetHeader(header, apiContext.Request.Header[http.CanonicalHeaderKey(header)]...)
|
||||
}
|
||||
return request.Do()
|
||||
return request.Do(apiContext.Request.Context())
|
||||
}
|
||||
|
||||
func (s *Store) k8sClient(apiContext *types.APIContext) (rest.Interface, error) {
|
||||
@@ -250,8 +250,8 @@ func (s *Store) retryList(namespace string, apiContext *types.APIContext) (*unst
|
||||
req := s.common(namespace, k8sClient.Get())
|
||||
start := time.Now()
|
||||
resultList = &unstructured.UnstructuredList{}
|
||||
err = req.Do().Into(resultList)
|
||||
logrus.Debugf("LIST: %v, %v", time.Now().Sub(start), s.resourcePlural)
|
||||
err = req.Do(apiContext.Request.Context()).Into(resultList)
|
||||
logrus.Tracef("LIST: %v, %v", time.Now().Sub(start), s.resourcePlural)
|
||||
if err != nil {
|
||||
if i < 2 && strings.Contains(err.Error(), "Client.Timeout exceeded") {
|
||||
logrus.Infof("Error on LIST %v: %v. Attempt: %v. Retrying", s.resourcePlural, err, i+1)
|
||||
@@ -271,6 +271,7 @@ func (s *Store) Watch(apiContext *types.APIContext, schema *types.Schema, opt *t
|
||||
}
|
||||
|
||||
return convert.Chan(c, func(data map[string]interface{}) map[string]interface{} {
|
||||
apiContext.ExpireAccessControl(schema)
|
||||
return apiContext.AccessControl.Filter(apiContext, schema, data, s.authContext)
|
||||
}), nil
|
||||
}
|
||||
@@ -295,7 +296,7 @@ func (s *Store) realWatch(apiContext *types.APIContext, schema *types.Schema, op
|
||||
ResourceVersion: "0",
|
||||
}, metav1.ParameterCodec)
|
||||
|
||||
body, err := req.Stream()
|
||||
body, err := req.Stream(apiContext.Request.Context())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -307,7 +308,7 @@ func (s *Store) realWatch(apiContext *types.APIContext, schema *types.Schema, op
|
||||
watchingContext, cancelWatchingContext := context.WithCancel(apiContext.Request.Context())
|
||||
go func() {
|
||||
<-watchingContext.Done()
|
||||
logrus.Debugf("stopping watcher for %s", schema.ID)
|
||||
logrus.Tracef("stopping watcher for %s", schema.ID)
|
||||
watcher.Stop()
|
||||
}()
|
||||
|
||||
@@ -316,7 +317,7 @@ func (s *Store) realWatch(apiContext *types.APIContext, schema *types.Schema, op
|
||||
for event := range watcher.ResultChan() {
|
||||
if data, ok := event.Object.(*metav1.Status); ok {
|
||||
// just logging it, keeping the same behavior as before
|
||||
logrus.Debugf("watcher status for %s: %s", schema.ID, data.Message)
|
||||
logrus.Tracef("watcher status for %s: %s", schema.ID, data.Message)
|
||||
} else {
|
||||
data := event.Object.(*unstructured.Unstructured)
|
||||
s.fromInternal(apiContext, schema, data.Object)
|
||||
@@ -326,7 +327,7 @@ func (s *Store) realWatch(apiContext *types.APIContext, schema *types.Schema, op
|
||||
result <- data.Object
|
||||
}
|
||||
}
|
||||
logrus.Debugf("closing watcher for %s", schema.ID)
|
||||
logrus.Tracef("closing watcher for %s", schema.ID)
|
||||
close(result)
|
||||
cancelWatchingContext()
|
||||
}()
|
||||
|
10
vendor/github.com/rancher/norman/types/reflection.go
generated
vendored
10
vendor/github.com/rancher/norman/types/reflection.go
generated
vendored
@@ -153,11 +153,11 @@ func (s *Schemas) importType(version *APIVersion, t reflect.Type, overrides ...r
|
||||
}
|
||||
|
||||
if s, ok := s.processingTypes[t]; ok {
|
||||
logrus.Debugf("Returning half built schema %s for %v", typeName, t)
|
||||
logrus.Tracef("Returning half built schema %s for %v", typeName, t)
|
||||
return s, nil
|
||||
}
|
||||
|
||||
logrus.Debugf("Inspecting schema %s for %v", typeName, t)
|
||||
logrus.Tracef("Inspecting schema %s for %v", typeName, t)
|
||||
|
||||
schema, err := s.newSchemaFromType(version, t, typeName)
|
||||
if err != nil {
|
||||
@@ -274,11 +274,11 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error {
|
||||
}
|
||||
|
||||
if blacklistNames[fieldName] {
|
||||
logrus.Debugf("Ignoring blacklisted field %s.%s for %v", schema.ID, fieldName, field)
|
||||
logrus.Tracef("Ignoring blacklisted field %s.%s for %v", schema.ID, fieldName, field)
|
||||
continue
|
||||
}
|
||||
|
||||
logrus.Debugf("Inspecting field %s.%s for %v", schema.ID, fieldName, field)
|
||||
logrus.Tracef("Inspecting field %s.%s for %v", schema.ID, fieldName, field)
|
||||
|
||||
schemaField := Field{
|
||||
Create: true,
|
||||
@@ -336,7 +336,7 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error {
|
||||
}
|
||||
}
|
||||
|
||||
logrus.Debugf("Setting field %s.%s: %#v", schema.ID, fieldName, schemaField)
|
||||
logrus.Tracef("Setting field %s.%s: %#v", schema.ID, fieldName, schemaField)
|
||||
schema.ResourceFields[fieldName] = schemaField
|
||||
}
|
||||
|
||||
|
10
vendor/github.com/rancher/norman/types/server_types.go
generated
vendored
10
vendor/github.com/rancher/norman/types/server_types.go
generated
vendored
@@ -174,6 +174,16 @@ func (r *APIContext) Filter(opts *QueryOptions, schema *Schema, obj interface{})
|
||||
return nil
|
||||
}
|
||||
|
||||
type Expire interface {
|
||||
Expire(apiContext *APIContext, schema *Schema)
|
||||
}
|
||||
|
||||
func (r *APIContext) ExpireAccessControl(schema *Schema) {
|
||||
if e, ok := r.AccessControl.(Expire); ok {
|
||||
e.Expire(r, schema)
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
ASC = SortOrder("asc")
|
||||
DESC = SortOrder("desc")
|
||||
|
17
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/clusterrole.go
generated
vendored
17
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/clusterrole.go
generated
vendored
@@ -173,31 +173,34 @@ func (c *clusterRoleController) Cache() ClusterRoleCache {
|
||||
}
|
||||
|
||||
func (c *clusterRoleController) Create(obj *v1.ClusterRole) (*v1.ClusterRole, error) {
|
||||
return c.clientGetter.ClusterRoles().Create(obj)
|
||||
return c.clientGetter.ClusterRoles().Create(context.TODO(), obj, metav1.CreateOptions{})
|
||||
}
|
||||
|
||||
func (c *clusterRoleController) Update(obj *v1.ClusterRole) (*v1.ClusterRole, error) {
|
||||
return c.clientGetter.ClusterRoles().Update(obj)
|
||||
return c.clientGetter.ClusterRoles().Update(context.TODO(), obj, metav1.UpdateOptions{})
|
||||
}
|
||||
|
||||
func (c *clusterRoleController) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return c.clientGetter.ClusterRoles().Delete(name, options)
|
||||
if options == nil {
|
||||
options = &metav1.DeleteOptions{}
|
||||
}
|
||||
return c.clientGetter.ClusterRoles().Delete(context.TODO(), name, *options)
|
||||
}
|
||||
|
||||
func (c *clusterRoleController) Get(name string, options metav1.GetOptions) (*v1.ClusterRole, error) {
|
||||
return c.clientGetter.ClusterRoles().Get(name, options)
|
||||
return c.clientGetter.ClusterRoles().Get(context.TODO(), name, options)
|
||||
}
|
||||
|
||||
func (c *clusterRoleController) List(opts metav1.ListOptions) (*v1.ClusterRoleList, error) {
|
||||
return c.clientGetter.ClusterRoles().List(opts)
|
||||
return c.clientGetter.ClusterRoles().List(context.TODO(), opts)
|
||||
}
|
||||
|
||||
func (c *clusterRoleController) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return c.clientGetter.ClusterRoles().Watch(opts)
|
||||
return c.clientGetter.ClusterRoles().Watch(context.TODO(), opts)
|
||||
}
|
||||
|
||||
func (c *clusterRoleController) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ClusterRole, err error) {
|
||||
return c.clientGetter.ClusterRoles().Patch(name, pt, data, subresources...)
|
||||
return c.clientGetter.ClusterRoles().Patch(context.TODO(), name, pt, data, metav1.PatchOptions{}, subresources...)
|
||||
}
|
||||
|
||||
type clusterRoleCache struct {
|
||||
|
@@ -173,31 +173,34 @@ func (c *clusterRoleBindingController) Cache() ClusterRoleBindingCache {
|
||||
}
|
||||
|
||||
func (c *clusterRoleBindingController) Create(obj *v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error) {
|
||||
return c.clientGetter.ClusterRoleBindings().Create(obj)
|
||||
return c.clientGetter.ClusterRoleBindings().Create(context.TODO(), obj, metav1.CreateOptions{})
|
||||
}
|
||||
|
||||
func (c *clusterRoleBindingController) Update(obj *v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error) {
|
||||
return c.clientGetter.ClusterRoleBindings().Update(obj)
|
||||
return c.clientGetter.ClusterRoleBindings().Update(context.TODO(), obj, metav1.UpdateOptions{})
|
||||
}
|
||||
|
||||
func (c *clusterRoleBindingController) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return c.clientGetter.ClusterRoleBindings().Delete(name, options)
|
||||
if options == nil {
|
||||
options = &metav1.DeleteOptions{}
|
||||
}
|
||||
return c.clientGetter.ClusterRoleBindings().Delete(context.TODO(), name, *options)
|
||||
}
|
||||
|
||||
func (c *clusterRoleBindingController) Get(name string, options metav1.GetOptions) (*v1.ClusterRoleBinding, error) {
|
||||
return c.clientGetter.ClusterRoleBindings().Get(name, options)
|
||||
return c.clientGetter.ClusterRoleBindings().Get(context.TODO(), name, options)
|
||||
}
|
||||
|
||||
func (c *clusterRoleBindingController) List(opts metav1.ListOptions) (*v1.ClusterRoleBindingList, error) {
|
||||
return c.clientGetter.ClusterRoleBindings().List(opts)
|
||||
return c.clientGetter.ClusterRoleBindings().List(context.TODO(), opts)
|
||||
}
|
||||
|
||||
func (c *clusterRoleBindingController) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return c.clientGetter.ClusterRoleBindings().Watch(opts)
|
||||
return c.clientGetter.ClusterRoleBindings().Watch(context.TODO(), opts)
|
||||
}
|
||||
|
||||
func (c *clusterRoleBindingController) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ClusterRoleBinding, err error) {
|
||||
return c.clientGetter.ClusterRoleBindings().Patch(name, pt, data, subresources...)
|
||||
return c.clientGetter.ClusterRoleBindings().Patch(context.TODO(), name, pt, data, metav1.PatchOptions{}, subresources...)
|
||||
}
|
||||
|
||||
type clusterRoleBindingCache struct {
|
||||
|
17
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/role.go
generated
vendored
17
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/role.go
generated
vendored
@@ -173,31 +173,34 @@ func (c *roleController) Cache() RoleCache {
|
||||
}
|
||||
|
||||
func (c *roleController) Create(obj *v1.Role) (*v1.Role, error) {
|
||||
return c.clientGetter.Roles(obj.Namespace).Create(obj)
|
||||
return c.clientGetter.Roles(obj.Namespace).Create(context.TODO(), obj, metav1.CreateOptions{})
|
||||
}
|
||||
|
||||
func (c *roleController) Update(obj *v1.Role) (*v1.Role, error) {
|
||||
return c.clientGetter.Roles(obj.Namespace).Update(obj)
|
||||
return c.clientGetter.Roles(obj.Namespace).Update(context.TODO(), obj, metav1.UpdateOptions{})
|
||||
}
|
||||
|
||||
func (c *roleController) Delete(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return c.clientGetter.Roles(namespace).Delete(name, options)
|
||||
if options == nil {
|
||||
options = &metav1.DeleteOptions{}
|
||||
}
|
||||
return c.clientGetter.Roles(namespace).Delete(context.TODO(), name, *options)
|
||||
}
|
||||
|
||||
func (c *roleController) Get(namespace, name string, options metav1.GetOptions) (*v1.Role, error) {
|
||||
return c.clientGetter.Roles(namespace).Get(name, options)
|
||||
return c.clientGetter.Roles(namespace).Get(context.TODO(), name, options)
|
||||
}
|
||||
|
||||
func (c *roleController) List(namespace string, opts metav1.ListOptions) (*v1.RoleList, error) {
|
||||
return c.clientGetter.Roles(namespace).List(opts)
|
||||
return c.clientGetter.Roles(namespace).List(context.TODO(), opts)
|
||||
}
|
||||
|
||||
func (c *roleController) Watch(namespace string, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return c.clientGetter.Roles(namespace).Watch(opts)
|
||||
return c.clientGetter.Roles(namespace).Watch(context.TODO(), opts)
|
||||
}
|
||||
|
||||
func (c *roleController) Patch(namespace, name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Role, err error) {
|
||||
return c.clientGetter.Roles(namespace).Patch(name, pt, data, subresources...)
|
||||
return c.clientGetter.Roles(namespace).Patch(context.TODO(), name, pt, data, metav1.PatchOptions{}, subresources...)
|
||||
}
|
||||
|
||||
type roleCache struct {
|
||||
|
17
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/rolebinding.go
generated
vendored
17
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/rolebinding.go
generated
vendored
@@ -173,31 +173,34 @@ func (c *roleBindingController) Cache() RoleBindingCache {
|
||||
}
|
||||
|
||||
func (c *roleBindingController) Create(obj *v1.RoleBinding) (*v1.RoleBinding, error) {
|
||||
return c.clientGetter.RoleBindings(obj.Namespace).Create(obj)
|
||||
return c.clientGetter.RoleBindings(obj.Namespace).Create(context.TODO(), obj, metav1.CreateOptions{})
|
||||
}
|
||||
|
||||
func (c *roleBindingController) Update(obj *v1.RoleBinding) (*v1.RoleBinding, error) {
|
||||
return c.clientGetter.RoleBindings(obj.Namespace).Update(obj)
|
||||
return c.clientGetter.RoleBindings(obj.Namespace).Update(context.TODO(), obj, metav1.UpdateOptions{})
|
||||
}
|
||||
|
||||
func (c *roleBindingController) Delete(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return c.clientGetter.RoleBindings(namespace).Delete(name, options)
|
||||
if options == nil {
|
||||
options = &metav1.DeleteOptions{}
|
||||
}
|
||||
return c.clientGetter.RoleBindings(namespace).Delete(context.TODO(), name, *options)
|
||||
}
|
||||
|
||||
func (c *roleBindingController) Get(namespace, name string, options metav1.GetOptions) (*v1.RoleBinding, error) {
|
||||
return c.clientGetter.RoleBindings(namespace).Get(name, options)
|
||||
return c.clientGetter.RoleBindings(namespace).Get(context.TODO(), name, options)
|
||||
}
|
||||
|
||||
func (c *roleBindingController) List(namespace string, opts metav1.ListOptions) (*v1.RoleBindingList, error) {
|
||||
return c.clientGetter.RoleBindings(namespace).List(opts)
|
||||
return c.clientGetter.RoleBindings(namespace).List(context.TODO(), opts)
|
||||
}
|
||||
|
||||
func (c *roleBindingController) Watch(namespace string, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return c.clientGetter.RoleBindings(namespace).Watch(opts)
|
||||
return c.clientGetter.RoleBindings(namespace).Watch(context.TODO(), opts)
|
||||
}
|
||||
|
||||
func (c *roleBindingController) Patch(namespace, name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.RoleBinding, err error) {
|
||||
return c.clientGetter.RoleBindings(namespace).Patch(name, pt, data, subresources...)
|
||||
return c.clientGetter.RoleBindings(namespace).Patch(context.TODO(), name, pt, data, metav1.PatchOptions{}, subresources...)
|
||||
}
|
||||
|
||||
type roleBindingCache struct {
|
||||
|
98
vendor/github.com/rancher/wrangler/pkg/summary/summarized.go
generated
vendored
Normal file
98
vendor/github.com/rancher/wrangler/pkg/summary/summarized.go
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
package summary
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type SummarizedObject struct {
|
||||
metav1.PartialObjectMetadata
|
||||
Summary
|
||||
}
|
||||
|
||||
type SummarizedObjectList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||
Items []SummarizedObject `json:"items" protobuf:"bytes,2,rep,name=items"`
|
||||
}
|
||||
|
||||
func Summarized(u runtime.Object) *SummarizedObject {
|
||||
if s, ok := u.(*SummarizedObject); ok {
|
||||
return s
|
||||
}
|
||||
|
||||
s := &SummarizedObject{
|
||||
Summary: Summarize(u),
|
||||
}
|
||||
s.APIVersion, s.Kind = u.GetObjectKind().GroupVersionKind().ToAPIVersionAndKind()
|
||||
|
||||
meta, err := meta.Accessor(u)
|
||||
if err == nil {
|
||||
s.Name = meta.GetName()
|
||||
s.Namespace = meta.GetNamespace()
|
||||
s.Generation = meta.GetGeneration()
|
||||
s.UID = meta.GetUID()
|
||||
s.ResourceVersion = meta.GetResourceVersion()
|
||||
s.CreationTimestamp = meta.GetCreationTimestamp()
|
||||
s.DeletionTimestamp = meta.GetDeletionTimestamp()
|
||||
s.Labels = meta.GetLabels()
|
||||
s.Annotations = meta.GetAnnotations()
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (in *SummarizedObjectList) DeepCopyInto(out *SummarizedObjectList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]SummarizedObject, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (in *SummarizedObjectList) DeepCopy() *SummarizedObjectList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(SummarizedObjectList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (in *SummarizedObjectList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (in *SummarizedObject) DeepCopyInto(out *SummarizedObject) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ObjectMeta = *in.ObjectMeta.DeepCopy()
|
||||
out.Summary = *in.Summary.DeepCopy()
|
||||
return
|
||||
}
|
||||
|
||||
func (in *SummarizedObject) DeepCopy() *SummarizedObject {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(SummarizedObject)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (in *SummarizedObject) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
1
vendor/github.com/rancher/wrangler/pkg/summary/summarizers.go
generated
vendored
1
vendor/github.com/rancher/wrangler/pkg/summary/summarizers.go
generated
vendored
@@ -50,6 +50,7 @@ var (
|
||||
"ScalingActive": "pending",
|
||||
"AbleToScale": "pending",
|
||||
"RunCompleted": "running",
|
||||
"Processed": "processed",
|
||||
}
|
||||
|
||||
// True == error
|
||||
|
69
vendor/github.com/rancher/wrangler/pkg/summary/summary.go
generated
vendored
69
vendor/github.com/rancher/wrangler/pkg/summary/summary.go
generated
vendored
@@ -3,6 +3,8 @@ package summary
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
"github.com/rancher/wrangler/pkg/data"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
)
|
||||
@@ -14,12 +16,76 @@ type Summary struct {
|
||||
Message []string
|
||||
}
|
||||
|
||||
func Summarize(unstr *unstructured.Unstructured) Summary {
|
||||
func (s Summary) String() string {
|
||||
if !s.Transitioning && !s.Error {
|
||||
return s.State
|
||||
}
|
||||
var msg string
|
||||
if s.Transitioning {
|
||||
msg = "[progressing"
|
||||
}
|
||||
if s.Error {
|
||||
if len(msg) > 0 {
|
||||
msg += ",error]"
|
||||
} else {
|
||||
msg = "error]"
|
||||
}
|
||||
} else {
|
||||
msg += "]"
|
||||
}
|
||||
if len(s.Message) > 0 {
|
||||
msg = msg + " " + s.Message[0]
|
||||
}
|
||||
return msg
|
||||
}
|
||||
|
||||
func (s Summary) IsReady() bool {
|
||||
return !s.Error && !s.Transitioning
|
||||
}
|
||||
|
||||
func (s *Summary) DeepCopy() *Summary {
|
||||
v := *s
|
||||
return &v
|
||||
}
|
||||
|
||||
func (s *Summary) DeepCopyInto(v *Summary) {
|
||||
*v = *s
|
||||
}
|
||||
|
||||
func dedupMessage(messages []string) []string {
|
||||
if len(messages) <= 1 {
|
||||
return messages
|
||||
}
|
||||
|
||||
seen := map[string]bool{}
|
||||
var result []string
|
||||
|
||||
for _, message := range messages {
|
||||
if seen[message] {
|
||||
continue
|
||||
}
|
||||
seen[message] = true
|
||||
result = append(result, message)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func Summarize(runtimeObj runtime.Object) Summary {
|
||||
var (
|
||||
obj data.Object
|
||||
summary Summary
|
||||
)
|
||||
|
||||
if s, ok := runtimeObj.(*SummarizedObject); ok {
|
||||
return s.Summary
|
||||
}
|
||||
|
||||
unstr, ok := runtimeObj.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
return summary
|
||||
}
|
||||
|
||||
if unstr != nil {
|
||||
obj = unstr.Object
|
||||
}
|
||||
@@ -35,5 +101,6 @@ func Summarize(unstr *unstructured.Unstructured) Summary {
|
||||
}
|
||||
|
||||
summary.State = strings.ToLower(summary.State)
|
||||
summary.Message = dedupMessage(summary.Message)
|
||||
return summary
|
||||
}
|
||||
|
Reference in New Issue
Block a user