Documentation ¶
Index ¶
- func CheckPermission(ctx context.Context, client client.Client, ...) (bool, error)
- func GetConfigMap(context context.Context, client k8sclient.Reader, name string, ...) (*corev1.ConfigMap, error)
- func GetSecret(context context.Context, client k8sclient.Reader, name string, ...) (*corev1.Secret, error)
- func IsAPIResourceInstalled(c client.Client, groupVersion string, kind string) (bool, error)
- func IsUnknownAPIError(err error) bool
- func JSONToYAML(src []byte) ([]byte, error)
- func LoadRawResourceFromYaml(data string) (ctrl.Object, error)
- func LoadResourceFromYaml(scheme *runtime.Scheme, data string) (ctrl.Object, error)
- func ReplaceResource(ctx context.Context, c client.Client, res ctrl.Object) error
- func ReplaceResources(ctx context.Context, c client.Client, objects []ctrl.Object) error
- func SanitizeFileName(name string) string
- func SanitizeLabel(name string) string
- func SanitizeName(name string) string
- func ToJSON(value runtime.Object) ([]byte, error)
- func ToYAML(value runtime.Object) ([]byte, error)
- func WaitCondition(ctx context.Context, c client.Client, obj ctrl.Object, ...) error
- type Collection
- func (c *Collection) Add(resource ctrl.Object)
- func (c *Collection) AddAll(resource []ctrl.Object)
- func (c *Collection) AsKubernetesList() *corev1.List
- func (c *Collection) GetConfigMap(filter func(*corev1.ConfigMap) bool) *corev1.ConfigMap
- func (c *Collection) GetDeployment(filter func(*appsv1.Deployment) bool) *appsv1.Deployment
- func (c *Collection) GetService(filter func(*corev1.Service) bool) *corev1.Service
- func (c *Collection) HasDeployment(filter func(*appsv1.Deployment) bool) bool
- func (c *Collection) Items() []ctrl.Object
- func (c *Collection) Remove(selector func(ctrl.Object) bool) ctrl.Object
- func (c *Collection) RemoveConfigMap(filter func(*corev1.ConfigMap) bool) *corev1.ConfigMap
- func (c *Collection) RemoveDeployment(filter func(*appsv1.Deployment) bool) *appsv1.Deployment
- func (c *Collection) Size() int
- func (c *Collection) Visit(visitor func(ctrl.Object))
- func (c *Collection) VisitConfigMap(visitor func(*corev1.ConfigMap))
- func (c *Collection) VisitContainer(visitor func(container *corev1.Container))
- func (c *Collection) VisitDeployment(visitor func(*appsv1.Deployment))
- func (c *Collection) VisitMetaObject(visitor func(metav1.Object))
- func (c *Collection) VisitService(visitor func(*corev1.Service))
- type ResourceCheckFunction
- type ResourceRetrieveFunction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPermission ¶ added in v0.1.0
func CheckPermission(ctx context.Context, client client.Client, group, resource, namespace, name, verb string) (bool, error)
CheckPermission can be used to check if the current user/service-account is allowed to execute a given operation in the cluster. E.g. checkPermission(client, olmv1alpha1.GroupName, "clusterserviceversions", namespace, "yaks", "get")
nolint:unparam
func GetConfigMap ¶ added in v0.1.0
func GetConfigMap(context context.Context, client k8sclient.Reader, name string, namespace string) (*corev1.ConfigMap, error)
GetConfigMap --
func GetSecret ¶ added in v0.1.0
func GetSecret(context context.Context, client k8sclient.Reader, name string, namespace string) (*corev1.Secret, error)
GetSecret --
func IsAPIResourceInstalled ¶ added in v0.4.0
func IsUnknownAPIError ¶ added in v0.1.0
IsUnknownAPIError checks if the given error is due to some missing APIs in the cluster. Apparently there's no such method in Kubernetes Go API.
func LoadRawResourceFromYaml ¶
LoadRawResourceFromYaml loads a k8s resource from a yaml definition without making assumptions on the underlying type
func LoadResourceFromYaml ¶
LoadResourceFromYaml loads a k8s resource from a yaml definition
func ReplaceResource ¶
ReplaceResource allows to completely replace a resource on Kubernetes, taking care of immutable fields and resource versions
func ReplaceResources ¶
ReplaceResources allows to completely replace a list of resources on Kubernetes, taking care of immutable fields and resource versions
func SanitizeFileName ¶
func SanitizeLabel ¶
SanitizeLabel sanitizes the given name to be compatible with k8s
func SanitizeName ¶
SanitizeName sanitizes the given name to be compatible with k8s
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
A Collection is a container of Kubernetes resources
func NewCollection ¶
func NewCollection(objects ...ctrl.Object) *Collection
NewCollection creates a new empty collection
func (*Collection) Add ¶
func (c *Collection) Add(resource ctrl.Object)
Add adds a resource to the collection
func (*Collection) AddAll ¶
func (c *Collection) AddAll(resource []ctrl.Object)
AddAll adds all resources to the collection
func (*Collection) AsKubernetesList ¶
func (c *Collection) AsKubernetesList() *corev1.List
AsKubernetesList returns all resources wrapped in a Kubernetes list
func (*Collection) GetConfigMap ¶
GetConfigMap returns a ConfigMap that matches the given function
func (*Collection) GetDeployment ¶
func (c *Collection) GetDeployment(filter func(*appsv1.Deployment) bool) *appsv1.Deployment
GetDeployment returns a Deployment that matches the given function
func (*Collection) GetService ¶
GetService returns a Service that matches the given function
func (*Collection) HasDeployment ¶
func (c *Collection) HasDeployment(filter func(*appsv1.Deployment) bool) bool
HasDeployment returns true if a deployment matching the given condition is present
func (*Collection) Items ¶
func (c *Collection) Items() []ctrl.Object
Items returns all resources belonging to the collection
func (*Collection) RemoveConfigMap ¶
RemoveConfigMap removes and returns a ConfigMap that matches the given function
func (*Collection) RemoveDeployment ¶
func (c *Collection) RemoveDeployment(filter func(*appsv1.Deployment) bool) *appsv1.Deployment
RemoveDeployment removes and returns a Deployment that matches the given function
func (*Collection) Size ¶
func (c *Collection) Size() int
Size returns the number of resources belonging to the collection
func (*Collection) Visit ¶
func (c *Collection) Visit(visitor func(ctrl.Object))
Visit executes the visitor function on all resources
func (*Collection) VisitConfigMap ¶
func (c *Collection) VisitConfigMap(visitor func(*corev1.ConfigMap))
VisitConfigMap executes the visitor function on all ConfigMap resources
func (*Collection) VisitContainer ¶
func (c *Collection) VisitContainer(visitor func(container *corev1.Container))
VisitContainer executes the visitor function on all Containers inside deployments or other resources
func (*Collection) VisitDeployment ¶
func (c *Collection) VisitDeployment(visitor func(*appsv1.Deployment))
VisitDeployment executes the visitor function on all Deployment resources
func (*Collection) VisitMetaObject ¶
func (c *Collection) VisitMetaObject(visitor func(metav1.Object))
VisitMetaObject executes the visitor function on all meta.Object resources
func (*Collection) VisitService ¶
func (c *Collection) VisitService(visitor func(*corev1.Service))
VisitService executes the visitor function on all Service resources
type ResourceCheckFunction ¶
ResourceCheckFunction --
type ResourceRetrieveFunction ¶
type ResourceRetrieveFunction func() (interface{}, error)
ResourceRetrieveFunction --