Documentation
¶
Index ¶
- Variables
- func AddToschema(schema *runtime.Scheme)
- func Apply[T client.Object](ctx context.Context, config *rest.Config, resources []T, options ...Option) error
- func AutoClientConfig() (*rest.Config, error)
- func CreateByYamlOrJson(ctx context.Context, cfg *rest.Config, yamlOrJson []byte) error
- func CreatePatchContent(origin, modified interface{}) ([]byte, error)
- func DefaultClientConfig() clientcmd.ClientConfig
- func DeleteByYamlOrJson(ctx context.Context, cfg *rest.Config, yamlOrJson []byte) error
- func FieldIndexName(field string) string
- func FillGVK(object client.Object, scheme *runtime.Scheme) error
- func GetKubeClient(kubeconfig []byte) (*rest.Config, *kubernetes.Clientset, error)
- func GetKubeRestConfig(kubeconfig []byte) (*rest.Config, error)
- func GetKubeconfigInfos(kubeconfig []byte) (apiserver string, cert, key, ca []byte, err error)
- func GetScheme() *runtime.Scheme
- func KeyToNamespacedKey(ns string, baseKey string) string
- func LocalNamespaceOrDefault(def string) string
- func NewCacheReaderFor(ctx context.Context, cli client.Client, gvk schema.GroupVersionKind, ...) (client.Reader, error)
- func NewClient(config *rest.Config) (client.Client, error)
- func NewListOf(gvk schema.GroupVersionKind, scheme *runtime.Scheme) client.ObjectList
- func NewLocalClient() (client.WithWatch, error)
- func ParseResource(raw []byte) ([]*unstructured.Unstructured, error)
- func PortForward(ctx context.Context, config *rest.Config, namespace string, ...) (int, error)
- func Remove[T client.Object](ctx context.Context, config *rest.Config, resources []T, options ...Option) error
- func RequiresExactMatch(sel fields.Selector) (field, val string, required bool)
- type CacheClient
- type CacheReader
- type JsonPatchType
- type NoopClient
- func (NoopClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (NoopClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
- func (NoopClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
- func (NoopClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error
- func (NoopClient) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- func (NoopClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (NoopClient) RESTMapper() meta.RESTMapper
- func (NoopClient) Scheme() *runtime.Scheme
- func (c NoopClient) Status() client.StatusWriter
- func (NoopClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
- type Option
- type Options
Constants ¶
This section is empty.
Variables ¶
var DefaultResyncTime = 10 * time.Hour
Functions ¶
func AddToschema ¶
func AddToschema(schema *runtime.Scheme)
func Apply ¶
func Apply[T client.Object](ctx context.Context, config *rest.Config, resources []T, options ...Option) error
func AutoClientConfig ¶
func AutoClientConfig() (*rest.Config, error)
AutoClientConfig 自动获取当前环境 restConfig
func CreateByYamlOrJson ¶
func CreateByYamlOrJson(ctx context.Context, cfg *rest.Config, yamlOrJson []byte) error
func CreatePatchContent ¶
func CreatePatchContent(origin, modified interface{}) ([]byte, error)
func DefaultClientConfig ¶ added in v1.23.0
func DefaultClientConfig() clientcmd.ClientConfig
DefaultClientConfig read config from kubeconfig or incluster config as fallback It read config from KUBECONFIG environment file or default kubeconfig file or in cluster config. https://github.com/kubernetes/client-go/blob/cab7ba1d4a523956b6395dcbe38620159ac43fef/tools/clientcmd/loader.go#L143-L152
func DeleteByYamlOrJson ¶
func DeleteByYamlOrJson(ctx context.Context, cfg *rest.Config, yamlOrJson []byte) error
func FieldIndexName ¶ added in v1.23.8
func FieldIndexName(field string) string
FieldIndexName constructs the name of the index over the given field, for use with an indexer.
func GetKubeClient ¶
func GetKubeClient(kubeconfig []byte) (*rest.Config, *kubernetes.Clientset, error)
func GetKubeRestConfig ¶
func GetKubeRestConfig(kubeconfig []byte) (*rest.Config, error)
func GetKubeconfigInfos ¶
func GetKubeconfigInfos(kubeconfig []byte) (apiserver string, cert, key, ca []byte, err error)
func KeyToNamespacedKey ¶ added in v1.23.8
func KeyToNamespacedKey(ns string, baseKey string) string
KeyToNamespacedKey prefixes the given index key with a namespace for use in field selector indexes.
func LocalNamespaceOrDefault ¶ added in v1.23.0
func LocalNamespaceOrDefault(def string) string
LocalNamespace return namespace of default namespace of the kubeconfig or current pod namespace Out of cluster: It read from kubeconfig default context namespace. On cluster: It read from POD_NAMESPACE environment or the serviceaccount namespace file. https://github.com/kubernetes/client-go/blob/cab7ba1d4a523956b6395dcbe38620159ac43fef/tools/clientcmd/client_config.go#L581-L596
func NewCacheReaderFor ¶ added in v1.23.8
func NewCacheReaderFor(ctx context.Context, cli client.Client,
gvk schema.GroupVersionKind, eventhandler cache.ResourceEventHandler,
listoptions ...client.ListOption,
) (client.Reader, error)
func NewListOf ¶ added in v1.23.8
func NewListOf(gvk schema.GroupVersionKind, scheme *runtime.Scheme) client.ObjectList
func NewLocalClient ¶ added in v1.23.0
func NewLocalClient() (client.WithWatch, error)
func ParseResource ¶
func ParseResource(raw []byte) ([]*unstructured.Unstructured, error)
func PortForward ¶ added in v1.23.0
func PortForward(ctx context.Context, config *rest.Config, namespace string, podLabelSelector string, targetPort int) (int, error)
func Remove ¶
func Remove[T client.Object](ctx context.Context, config *rest.Config, resources []T, options ...Option) error
func RequiresExactMatch ¶ added in v1.23.8
func RequiresExactMatch(sel fields.Selector) (field, val string, required bool)
RequiresExactMatch checks if the given field selector is of the form `k=v` or `k==v`.
Types ¶
type CacheClient ¶ added in v1.23.8
type CacheClient struct {
client.Client
// contains filtered or unexported fields
}
func NewCachedClient ¶ added in v1.23.8
func NewCachedClient(ctx context.Context, cli client.Client, eventhandler cache.ResourceEventHandler) *CacheClient
type CacheReader ¶ added in v1.23.8
type CacheReader struct {
// contains filtered or unexported fields
}
CacheReader is a Reader that reads from a informer cache. See: https://github.com/kubernetes-sigs/controller-runtime/blob/9489eb5b6c7733d1755ed18330876c3a8e364058/pkg/cache/internal/cache_reader.go#L39 CacheReader wraps a cache.Index to implement the client.CacheReader interface for a single type.
func NewCacheReader ¶ added in v1.23.8
func NewCacheReader(indexer cache.Indexer, gvk schema.GroupVersionKind, scopeName apimeta.RESTScopeName, disableDeepCopy bool) *CacheReader
type JsonPatchType ¶
type JsonPatchType struct {
From client.Object
}
type NoopClient ¶ added in v1.22.0
type NoopClient struct{}
func (NoopClient) Create ¶ added in v1.22.0
func (NoopClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
Create saves the object obj in the Kubernetes cluster.
func (NoopClient) Delete ¶ added in v1.22.0
func (NoopClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
Delete deletes the given obj from Kubernetes cluster.
func (NoopClient) DeleteAllOf ¶ added in v1.22.0
func (NoopClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
DeleteAllOf deletes all objects of the given type matching the given options.
func (NoopClient) Get ¶ added in v1.22.0
func (NoopClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error
Get retrieves an obj for the given object key from the Kubernetes Cluster. obj must be a struct pointer so that obj can be updated with the response returned by the Server.
func (NoopClient) List ¶ added in v1.22.0
func (NoopClient) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
List retrieves list of objects for a given namespace and list options. On a successful call, Items field in the list will be populated with the result returned from the server.
func (NoopClient) Patch ¶ added in v1.22.0
func (NoopClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
Patch patches the given obj in the Kubernetes cluster. obj must be a struct pointer so that obj can be updated with the content returned by the Server.
func (NoopClient) RESTMapper ¶ added in v1.22.0
func (NoopClient) RESTMapper() meta.RESTMapper
RESTMapper returns the rest this client is using.
type Option ¶
type Option func(*Options)
func WithCreateNamespace ¶
func WithCreateNamespace() Option