Documentation
¶
Index ¶
- Constants
- Variables
- func Abbreviate(str string, maxLength uint32) string
- func AddAndUpdateFinalizer(client client.Client, obj client.Object, finalizer string) error
- func Any[T any](items []T, predicate func(*T) bool) bool
- func DeleteAnnotation(patchType types.PatchType, key string) client.Patch
- func Escape(key string) string
- func Filter[T any](items []T, predicate func(*T) bool) []T
- func Find[T any](items []T, predicate func(*T) bool) (*T, bool)
- func GetMapValue(m map[string]string, key string) (string, bool)
- func GetMapValueByDefault(m map[string]string, key, def string) string
- func ObjectKeyString(obj client.Object) string
- func RemoveAndUpdateFinalizer(client client.Client, obj client.Object, finalizer string) error
- func SlowStartBatch(count int, initialBatchSize int, shortCircuit bool, fn func(int, error) error) (int, error)
- func UpdateOnConflict(ctx context.Context, reader client.Reader, writer UpdateWriter, ...) (controllerutil.OperationResult, error)
- type ClientConfig
- type ClientManager
- type UpdateWriter
Constants ¶
const (
SlowStartInitialBatchSize = 1
)
Variables ¶
var ClientManagerSingleton = NewClientManager()
Functions ¶
func Abbreviate ¶
Abbreviate abbreviates a string using ellipses
func AddAndUpdateFinalizer ¶
func ObjectKeyString ¶
func SlowStartBatch ¶
func SlowStartBatch(count int, initialBatchSize int, shortCircuit bool, fn func(int, error) error) (int, error)
SlowStartBatch tries to call the provided function a total of 'count' times, starting slow to check for errors, then speeding up if calls succeed.
It groups the calls into batches, starting with a group of initialBatchSize. Within each batch, it may call the function multiple times concurrently.
If a whole batch succeeds, the next batch may get exponentially larger. If there are any failures in a batch, all remaining batches are skipped after waiting for the current batch to complete.
It returns the number of successful calls to the function.
func UpdateOnConflict ¶
func UpdateOnConflict(ctx context.Context, reader client.Reader, writer UpdateWriter, obj client.Object, mutateFn controllerutil.MutateFn) (controllerutil.OperationResult, error)
reader is used to get freshest object writer can be client.Writer or client.StatusWriter
Types ¶
type ClientConfig ¶
type ClientConfig struct {
CABundle []byte
}
type ClientManager ¶
func NewClientManager ¶
func NewClientManager() *ClientManager
NewClientManager construct ClientManager
func (*ClientManager) Client ¶
func (cm *ClientManager) Client(cc *ClientConfig) (c *http.Client, err error)
Client get HttpClient from cache if present or new instance if not present
type UpdateWriter ¶
type UpdateWriter interface {
// Update updates the fields corresponding to the status subresource for the
// given obj. obj must be a struct pointer so that obj can be updated
// with the content returned by the Server.
Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
// Patch patches the given object's subresource. obj must be a struct
// pointer so that obj can be updated with the content returned by the
// Server.
Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
}