operatorclient

package
v0.21.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 29 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIServiceClient

type APIServiceClient interface {
	CreateAPIService(*apiregistrationv1.APIService) (*apiregistrationv1.APIService, error)
	GetAPIService(name string) (*apiregistrationv1.APIService, error)
	UpdateAPIService(modified *apiregistrationv1.APIService) (*apiregistrationv1.APIService, error)
	DeleteAPIService(name string, options *metav1.DeleteOptions) error
}

APIServiceClient contains methods for manipulating APIServiceBindings.

type Client

type Client struct {
	kubernetes.Interface
	// contains filtered or unexported fields
}

Client is a kubernetes client that can talk to the API server.

func (*Client) ApiextensionsInterface

func (c *Client) ApiextensionsInterface() apiextensions.Interface

ApiextensionsInterface returns the API extension interface.

func (*Client) ApiregistrationV1Interface

func (c *Client) ApiregistrationV1Interface() apiregistration.Interface

ApiregistrationV1Interface returns the API registration (aggregated apiserver) interface

func (*Client) AtomicModifyCustomResource

func (c *Client) AtomicModifyCustomResource(apiGroup, version, namespace, resourcePlural, resourceName string, f CustomResourceModifier, data interface{}) error

AtomicModifyCustomResource gets the custom resource, modifies it and writes it back. If it's modified by other writers, we will retry until it succeeds.

func (*Client) CreateAPIService

CreateAPIService creates the APIService.

func (*Client) CreateClusterRole

func (c *Client) CreateClusterRole(r *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error)

CreateClusterRole creates the ClusterRole.

func (*Client) CreateClusterRoleBinding

func (c *Client) CreateClusterRoleBinding(ig *rbacv1.ClusterRoleBinding) (*rbacv1.ClusterRoleBinding, error)

CreateRoleBinding creates the roleBinding.

func (*Client) CreateConfigMap

func (c *Client) CreateConfigMap(ig *corev1.ConfigMap) (*corev1.ConfigMap, error)

CreateConfigMap creates the ConfigMap.

func (*Client) CreateCustomResource

func (c *Client) CreateCustomResource(item *unstructured.Unstructured) error

CreateCustomResource creates the custom resource.

func (*Client) CreateCustomResourceRaw

func (c *Client) CreateCustomResourceRaw(apiGroup, version, namespace, kind string, data []byte) error

CreateCustomResourceRaw creates the raw bytes of the custom resource.

func (*Client) CreateCustomResourceRawIfNotFound

func (c *Client) CreateCustomResourceRawIfNotFound(apiGroup, version, namespace, kind, name string, data []byte) (bool, error)

CreateCustomResourceRawIfNotFound creates the raw bytes of the custom resource if it doesn't exist. It also returns a boolean to indicate whether a new custom resource is created.

func (*Client) CreateDeployment

func (c *Client) CreateDeployment(dep *appsv1.Deployment) (*appsv1.Deployment, error)

CreateDeployment creates the Deployment object.

func (*Client) CreateOrRollingUpdateDeployment

func (c *Client) CreateOrRollingUpdateDeployment(dep *appsv1.Deployment) (*appsv1.Deployment, bool, error)

CreateOrRollingUpdateDeployment creates the Deployment if it doesn't exist. If the Deployment already exists, it will update the Deployment and wait for it to rollout. Returns true if the Deployment was created or updated, false if there was no update.

func (*Client) CreateOrUpdateCustomeResourceRaw

func (c *Client) CreateOrUpdateCustomeResourceRaw(apiGroup, version, namespace, resourcePlural, resourceName string, data []byte) error

CreateOrUpdateCustomeResourceRaw creates the custom resource if it doesn't exist. If the custom resource exists, it updates the existing one.

func (*Client) CreateRole

func (c *Client) CreateRole(r *rbacv1.Role) (*rbacv1.Role, error)

CreateRole creates the role.

func (*Client) CreateRoleBinding

func (c *Client) CreateRoleBinding(ig *rbacv1.RoleBinding) (*rbacv1.RoleBinding, error)

CreateRoleBinding creates the roleBinding.

func (*Client) CreateSecret

func (c *Client) CreateSecret(ig *v1.Secret) (*v1.Secret, error)

CreateSecret creates the Secret.

func (*Client) CreateService

func (c *Client) CreateService(ig *v1.Service) (*v1.Service, error)

CreateService creates the Service.

func (*Client) CreateServiceAccount

func (c *Client) CreateServiceAccount(ig *v1.ServiceAccount) (*v1.ServiceAccount, error)

CreateServiceAccount creates the serviceAccount.

func (*Client) DeleteAPIService

func (c *Client) DeleteAPIService(name string, options *metav1.DeleteOptions) error

DeleteAPIService deletes the APIService.

func (*Client) DeleteClusterRole

func (c *Client) DeleteClusterRole(name string, options *metav1.DeleteOptions) error

DeleteClusterRole deletes the ClusterRole

func (*Client) DeleteClusterRoleBinding

func (c *Client) DeleteClusterRoleBinding(name string, options *metav1.DeleteOptions) error

DeleteRoleBinding deletes the roleBinding.

func (*Client) DeleteConfigMap

func (c *Client) DeleteConfigMap(namespace, name string, options *metav1.DeleteOptions) error

DeleteConfigMap deletes the ConfigMap.

func (*Client) DeleteCustomResource

func (c *Client) DeleteCustomResource(apiGroup, version, namespace, resourcePlural, resourceName string) error

DeleteCustomResource deletes the with the given name.

func (*Client) DeleteDeployment

func (c *Client) DeleteDeployment(namespace, name string, options *metav1.DeleteOptions) error

DeleteDeployment deletes the Deployment object.

func (*Client) DeleteRole

func (c *Client) DeleteRole(namespace, name string, options *metav1.DeleteOptions) error

DeleteRole deletes the role.

func (*Client) DeleteRoleBinding

func (c *Client) DeleteRoleBinding(namespace, name string, options *metav1.DeleteOptions) error

DeleteRoleBinding deletes the roleBinding.

func (*Client) DeleteSecret

func (c *Client) DeleteSecret(namespace, name string, options *metav1.DeleteOptions) error

DeleteSecret deletes the Secret.

func (*Client) DeleteService

func (c *Client) DeleteService(namespace, name string, options *metav1.DeleteOptions) error

DeleteService deletes the Service.

func (*Client) DeleteServiceAccount

func (c *Client) DeleteServiceAccount(namespace, name string, options *metav1.DeleteOptions) error

DeleteServiceAccount deletes the serviceAccount.

func (*Client) GetAPIService

func (c *Client) GetAPIService(name string) (*apiregistrationv1.APIService, error)

GetAPIService returns the existing APIService.

func (*Client) GetClusterRole

func (c *Client) GetClusterRole(name string) (*rbacv1.ClusterRole, error)

GetClusterRole returns the existing ClusterRole.

func (*Client) GetClusterRoleBinding

func (c *Client) GetClusterRoleBinding(name string) (*rbacv1.ClusterRoleBinding, error)

GetRoleBinding returns the existing roleBinding.

func (*Client) GetConfigMap

func (c *Client) GetConfigMap(namespace, name string) (*corev1.ConfigMap, error)

GetConfigMap returns the existing ConfigMap.

func (*Client) GetCustomResource

func (c *Client) GetCustomResource(apiGroup, version, namespace, resourcePlural, resourceName string) (*unstructured.Unstructured, error)

GetCustomResource returns the custom resource as *unstructured.Unstructured by the given name.

func (*Client) GetCustomResourceRaw

func (c *Client) GetCustomResourceRaw(apiGroup, version, namespace, resourcePlural, resourceName string) ([]byte, error)

GetCustomResourceRaw returns the custom resource's raw body data by the given name.

func (*Client) GetDeployment

func (c *Client) GetDeployment(namespace, name string) (*appsv1.Deployment, error)

GetDeployment returns the Deployment object for the given namespace and name.

func (*Client) GetRole

func (c *Client) GetRole(namespace, name string) (*rbacv1.Role, error)

GetRole returns the existing role.

func (*Client) GetRoleBinding

func (c *Client) GetRoleBinding(namespace, name string) (*rbacv1.RoleBinding, error)

GetRoleBinding returns the existing roleBinding.

func (*Client) GetSecret

func (c *Client) GetSecret(namespace, name string) (*v1.Secret, error)

GetSecret returns the existing Secret.

func (*Client) GetService

func (c *Client) GetService(namespace, name string) (*v1.Service, error)

GetService returns the existing Service.

func (*Client) GetServiceAccount

func (c *Client) GetServiceAccount(namespace, name string) (*v1.ServiceAccount, error)

GetServiceAccount returns the existing serviceAccount.

func (*Client) KubernetesInterface

func (c *Client) KubernetesInterface() kubernetes.Interface

KubernetesInterface returns the Kubernetes interface.

func (*Client) ListCustomResource

func (c *Client) ListCustomResource(apiGroup, version, namespace, resourcePlural string) (*CustomResourceList, error)

ListCustomResource lists all custom resources for the given namespace.

func (*Client) ListDeploymentsWithLabels

func (c *Client) ListDeploymentsWithLabels(namespace string, labels labels.Set) (*appsv1.DeploymentList, error)

ListDeploymentsWithLabels returns a list of deployments that matches the label selector. An empty list will be returned if no such deployments is found.

func (*Client) PatchDeployment

func (c *Client) PatchDeployment(original, modified *appsv1.Deployment) (*appsv1.Deployment, bool, error)

PatchDeployment updates a Deployment object by performing a 3-way patch merge between the existing Deployment and `original` and `modified` manifests.

Returns the latest Deployment and true if it was updated, or an error.

func (*Client) RollingPatchDeployment

func (c *Client) RollingPatchDeployment(original, modified *appsv1.Deployment) (*appsv1.Deployment, bool, error)

RollingPatchDeployment performs a 3-way patch merge followed by rolling update on the given Deployment. It requires that the Deployment uses the RollingUpdateDeploymentStrategyType update strategy.

RollingPatchDeployment will run any before / after migrations that have been specified in the upgrade options.

func (*Client) RollingPatchDeploymentMigrations

func (c *Client) RollingPatchDeploymentMigrations(namespace, name string, f PatchFunction) (*appsv1.Deployment, bool, error)

RollingPatchDeploymentMigrations performs a 3-way patch merge followed by rolling update on the given Deployment. It requires that the Deployment uses the RollingUpdateDeploymentStrategyType update strategy.

RollingPatchDeploymentMigrations will run any before / after migrations that have been specified in the upgrade options.

func (*Client) RollingUpdateDeployment

func (c *Client) RollingUpdateDeployment(dep *appsv1.Deployment) (*appsv1.Deployment, bool, error)

RollingUpdateDeployment performs a rolling update on the given Deployment. It requires that the Deployment uses the RollingUpdateDeploymentStrategyType update strategy.

func (*Client) RollingUpdateDeploymentMigrations

func (c *Client) RollingUpdateDeploymentMigrations(namespace, name string, f UpdateFunction) (*appsv1.Deployment, bool, error)

RollingUpdateDeploymentMigrations performs a rolling update on the given Deployment. It requires that the Deployment uses the RollingUpdateDeploymentStrategyType update strategy.

RollingUpdateDeploymentMigrations will run any before / during / after migrations that have been specified in the upgrade options.

func (*Client) UpdateAPIService

func (c *Client) UpdateAPIService(apiService *apiregistrationv1.APIService) (*apiregistrationv1.APIService, error)

UpdateAPIService will update the given APIService resource.

func (*Client) UpdateClusterRole

func (c *Client) UpdateClusterRole(crb *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error)

UpdateClusterRole will update the given ClusterRole.

func (*Client) UpdateClusterRoleBinding

func (c *Client) UpdateClusterRoleBinding(crb *rbacv1.ClusterRoleBinding) (*rbacv1.ClusterRoleBinding, error)

UpdateRoleBinding will update the given RoleBinding resource.

func (*Client) UpdateConfigMap

func (c *Client) UpdateConfigMap(configmap *corev1.ConfigMap) (*corev1.ConfigMap, error)

UpdateConfigMap will update the given ConfigMap resource.

func (*Client) UpdateCustomResource

func (c *Client) UpdateCustomResource(item *unstructured.Unstructured) error

UpdateCustomResource updates the custom resource. To do an atomic update, use AtomicModifyCustomResource().

func (*Client) UpdateCustomResourceRaw

func (c *Client) UpdateCustomResourceRaw(apiGroup, version, namespace, resourcePlural, resourceName string, data []byte) error

UpdateCustomResourceRaw updates the thirdparty resource with the raw data.

func (*Client) UpdateDeployment

func (c *Client) UpdateDeployment(dep *appsv1.Deployment) (*appsv1.Deployment, bool, error)

UpdateDeployment updates a Deployment object by performing a 2-way patch between the existing Deployment and the result of the UpdateFunction.

Returns the latest Deployment and true if it was updated, or an error.

func (*Client) UpdateRole

func (c *Client) UpdateRole(crb *rbacv1.Role) (*rbacv1.Role, error)

UpdateRole will update the given Role resource.

func (*Client) UpdateRoleBinding

func (c *Client) UpdateRoleBinding(crb *rbacv1.RoleBinding) (*rbacv1.RoleBinding, error)

UpdateRoleBinding will update the given RoleBinding resource.

func (*Client) UpdateSecret

func (c *Client) UpdateSecret(secret *v1.Secret) (*v1.Secret, error)

UpdateSecret will update the given Secret resource.

func (*Client) UpdateService

func (c *Client) UpdateService(service *v1.Service) (*v1.Service, error)

UpdateService will update the given Service resource.

func (*Client) UpdateServiceAccount

func (c *Client) UpdateServiceAccount(sa *v1.ServiceAccount) (*v1.ServiceAccount, error)

UpdateServiceAccount will update the given ServiceAccount resource.

type ClientInterface

func NewClient

func NewClient(k8sClient kubernetes.Interface, extclient apiextensions.Interface, regclient apiregistration.Interface) ClientInterface

NewClient creates a kubernetes client

func NewClientFromConfig

func NewClientFromConfig(kubeconfig string, logger *logrus.Logger) ClientInterface

NewClient creates a kubernetes client or bails out on on failures.

func NewClientFromRestConfig

func NewClientFromRestConfig(config *rest.Config) (client ClientInterface, err error)

type ClusterRoleBindingClient

type ClusterRoleBindingClient interface {
	CreateClusterRoleBinding(*rbacv1.ClusterRoleBinding) (*rbacv1.ClusterRoleBinding, error)
	GetClusterRoleBinding(name string) (*rbacv1.ClusterRoleBinding, error)
	UpdateClusterRoleBinding(modified *rbacv1.ClusterRoleBinding) (*rbacv1.ClusterRoleBinding, error)
	DeleteClusterRoleBinding(name string, options *metav1.DeleteOptions) error
}

ClusterRoleBindingClient contains methods for manipulating ClusterRoleBindings.

type ClusterRoleClient

type ClusterRoleClient interface {
	CreateClusterRole(*rbacv1.ClusterRole) (*rbacv1.ClusterRole, error)
	GetClusterRole(name string) (*rbacv1.ClusterRole, error)
	UpdateClusterRole(modified *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error)
	DeleteClusterRole(name string, options *metav1.DeleteOptions) error
}

ClusterRoleClient contains methods for manipulating ClusterRoleBindings.

type ConfigMapClient

type ConfigMapClient interface {
	CreateConfigMap(*v1.ConfigMap) (*v1.ConfigMap, error)
	GetConfigMap(namespace, name string) (*v1.ConfigMap, error)
	UpdateConfigMap(modified *v1.ConfigMap) (*v1.ConfigMap, error)
	DeleteConfigMap(namespace, name string, options *metav1.DeleteOptions) error
}

ConfigMapClient contains methods for the ConfigMap resource

type CustomResourceClient

type CustomResourceClient interface {
	GetCustomResource(apiGroup, version, namespace, resourceKind, resourceName string) (*unstructured.Unstructured, error)
	GetCustomResourceRaw(apiGroup, version, namespace, resourceKind, resourceName string) ([]byte, error)
	CreateCustomResource(item *unstructured.Unstructured) error
	CreateCustomResourceRaw(apiGroup, version, namespace, kind string, data []byte) error
	CreateCustomResourceRawIfNotFound(apiGroup, version, namespace, kind, name string, data []byte) (bool, error)
	UpdateCustomResource(item *unstructured.Unstructured) error
	UpdateCustomResourceRaw(apiGroup, version, namespace, resourceKind, resourceName string, data []byte) error
	CreateOrUpdateCustomeResourceRaw(apiGroup, version, namespace, resourceKind, resourceName string, data []byte) error
	DeleteCustomResource(apiGroup, version, namespace, resourceKind, resourceName string) error
	AtomicModifyCustomResource(apiGroup, version, namespace, resourceKind, resourceName string, f CustomResourceModifier, data interface{}) error
	ListCustomResource(apiGroup, version, namespace, resourceKind string) (*CustomResourceList, error)
}

CustomResourceClient contains methods for the Custom Resource.

type CustomResourceList

type CustomResourceList struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata"`

	Items []*unstructured.Unstructured `json:"items"`
}

CustomResourceList represents a list of custom resource objects that will be returned from a List() operation.

type CustomResourceModifier

type CustomResourceModifier func(*unstructured.Unstructured, interface{}) error

CustomResourceModifier takes the custom resource object, and modifies it in-place.

type DeploymentClient

type DeploymentClient interface {
	GetDeployment(namespace, name string) (*appsv1.Deployment, error)
	CreateDeployment(*appsv1.Deployment) (*appsv1.Deployment, error)
	DeleteDeployment(namespace, name string, options *metav1.DeleteOptions) error
	UpdateDeployment(*appsv1.Deployment) (*appsv1.Deployment, bool, error)
	PatchDeployment(*appsv1.Deployment, *appsv1.Deployment) (*appsv1.Deployment, bool, error)
	RollingUpdateDeployment(*appsv1.Deployment) (*appsv1.Deployment, bool, error)
	RollingPatchDeployment(*appsv1.Deployment, *appsv1.Deployment) (*appsv1.Deployment, bool, error)
	RollingUpdateDeploymentMigrations(namespace, name string, f UpdateFunction) (*appsv1.Deployment, bool, error)
	RollingPatchDeploymentMigrations(namespace, name string, f PatchFunction) (*appsv1.Deployment, bool, error)
	CreateOrRollingUpdateDeployment(*appsv1.Deployment) (*appsv1.Deployment, bool, error)
	ListDeploymentsWithLabels(namespace string, labels labels.Set) (*appsv1.DeploymentList, error)
}

DeploymentClient contains methods for the Deployment resource.

type PatchFunction

type PatchFunction func(current metav1.Object) (metav1.Object, metav1.Object, error)

PatchFunction defines a function that is used to provide patch objects for a 3-way merge. The function provides the current instance of the object retrieved from the apiserver. The function should return the "original" and "modified" objects (in that order) for 3-way patch computation.

func Patch

func Patch(original metav1.Object, modified metav1.Object) PatchFunction

Patch returns a default PatchFunction implementation that passes its arguments through to the patcher directly, ignoring the current object.

Example usage:

client.PatchDaemonSet(namespace, name, types.Patch(original, current))

type RoleBindingClient

type RoleBindingClient interface {
	CreateRoleBinding(*rbacv1.RoleBinding) (*rbacv1.RoleBinding, error)
	GetRoleBinding(namespace, name string) (*rbacv1.RoleBinding, error)
	UpdateRoleBinding(modified *rbacv1.RoleBinding) (*rbacv1.RoleBinding, error)
	DeleteRoleBinding(namespace, name string, options *metav1.DeleteOptions) error
}

RoleBindingClient contains methods for manipulating RoleBindings.

type RoleClient

type RoleClient interface {
	CreateRole(*rbacv1.Role) (*rbacv1.Role, error)
	GetRole(namespace, name string) (*rbacv1.Role, error)
	UpdateRole(modified *rbacv1.Role) (*rbacv1.Role, error)
	DeleteRole(namespace, name string, options *metav1.DeleteOptions) error
}

RoleClient contains methods for manipulating Roles.

type SecretClient

type SecretClient interface {
	CreateSecret(*v1.Secret) (*v1.Secret, error)
	GetSecret(namespace, name string) (*v1.Secret, error)
	UpdateSecret(modified *v1.Secret) (*v1.Secret, error)
	DeleteSecret(namespace, name string, options *metav1.DeleteOptions) error
}

SecretClient contains methods for manipulating Secrets

type ServiceAccountClient

type ServiceAccountClient interface {
	CreateServiceAccount(*v1.ServiceAccount) (*v1.ServiceAccount, error)
	GetServiceAccount(namespace, name string) (*v1.ServiceAccount, error)
	UpdateServiceAccount(modified *v1.ServiceAccount) (*v1.ServiceAccount, error)
	DeleteServiceAccount(namespace, name string, options *metav1.DeleteOptions) error
}

ServiceAccountClient contains methods for manipulating ServiceAccounts.

type ServiceClient

type ServiceClient interface {
	CreateService(*v1.Service) (*v1.Service, error)
	GetService(namespace, name string) (*v1.Service, error)
	UpdateService(modified *v1.Service) (*v1.Service, error)
	DeleteService(namespace, name string, options *metav1.DeleteOptions) error
}

ServiceClient contains methods for manipulating Services

type UpdateFunction

type UpdateFunction func(current metav1.Object) (metav1.Object, error)

UpdateFunction defines a function that updates an object in an Update* function. The function provides the current instance of the object retrieved from the apiserver. The function should return the updated object to be applied.

func Update

func Update(obj metav1.Object) UpdateFunction

Update returns a default UpdateFunction implementation that passes its argument through to the Update* function directly, ignoring the current object.

Example usage:

client.UpdateDaemonSet(namespace, name, types.Update(obj))

Directories

Path Synopsis
Package operatorclientmocks is a generated GoMock package.
Package operatorclientmocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL