mirror of
https://github.com/rancher/norman.git
synced 2025-09-01 23:36:58 +00:00
Changes to make conditions less chatty
This commit is contained in:
@@ -140,7 +140,11 @@ func (c Cond) doInternal(obj runtime.Object, f func() (runtime.Object, error)) (
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if _, ok := err.(*controller.ForgetError); !ok {
|
||||
if _, ok := err.(*controller.ForgetError); ok {
|
||||
if c.IsFalse(obj) {
|
||||
c.Unknown(obj)
|
||||
}
|
||||
} else {
|
||||
c.False(obj)
|
||||
}
|
||||
c.ReasonAndMessageFromError(obj, err)
|
||||
|
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
resyncPeriod = 5 * time.Minute
|
||||
resyncPeriod = 2 * time.Hour
|
||||
)
|
||||
|
||||
type HandlerFunc func(key string) error
|
||||
|
@@ -143,7 +143,7 @@ func writeData(c *websocket.Conn, header string, buf []byte) error {
|
||||
if _, err := messageWriter.Write([]byte(`}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return messageWriter.Close()
|
||||
}
|
||||
|
||||
func streamStore(ctx context.Context, eg *errgroup.Group, apiContext *types.APIContext, schema *types.Schema, result chan map[string]interface{}) {
|
||||
|
@@ -9,14 +9,33 @@ import (
|
||||
"github.com/rancher/norman/types/convert"
|
||||
"github.com/sirupsen/logrus"
|
||||
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
|
||||
apiextclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
|
||||
"k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type Factory struct {
|
||||
APIExtClientSet apiextclientset.Interface
|
||||
APIExtClientSet clientset.Interface
|
||||
}
|
||||
|
||||
func NewFactoryFromConfig(config rest.Config) (*Factory, error) {
|
||||
dynamicConfig := config
|
||||
if dynamicConfig.NegotiatedSerializer == nil {
|
||||
configConfig := dynamic.ContentConfig()
|
||||
dynamicConfig.NegotiatedSerializer = configConfig.NegotiatedSerializer
|
||||
}
|
||||
|
||||
apiExtClient, err := clientset.NewForConfig(&dynamicConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Factory{
|
||||
APIExtClientSet: apiExtClient,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Factory) AddSchemas(ctx context.Context, schemas ...*types.Schema) (map[*types.Schema]*apiext.CustomResourceDefinition, error) {
|
||||
|
@@ -48,7 +48,7 @@ func ToString(value interface{}) string {
|
||||
if single == nil {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprint(single)
|
||||
return strings.TrimSpace(fmt.Sprint(single))
|
||||
}
|
||||
|
||||
func ToTimestamp(value interface{}) (int64, error) {
|
||||
@@ -164,7 +164,7 @@ func ToStringSlice(data interface{}) []string {
|
||||
return v
|
||||
}
|
||||
if v, ok := data.([]interface{}); ok {
|
||||
result := []string{}
|
||||
var result []string
|
||||
for _, item := range v {
|
||||
result = append(result, ToString(item))
|
||||
}
|
||||
|
Reference in New Issue
Block a user