Documentation ¶
Index ¶
- Constants
- Variables
- func DisclaimerTransform(_ context.Context, _ Object, resources []*unstructured.Unstructured) error
- func KymaComponentTransform(_ context.Context, obj Object, resources []*unstructured.Unstructured) error
- func ManagedByDeclarativeV2(_ context.Context, _ Object, resources []*unstructured.Unstructured) error
- func NewClientProxy(config *rest.Config, mapper meta.RESTMapper) (client.Client, error)
- func SkipReconcileOnDefaultLabelPresentAndTrue(ctx context.Context, object Object) bool
- type Client
- type ClientCache
- type ClientCacheKeyFn
- type ClusterFn
- type ClusterInfo
- type ConcurrentDefaultSSA
- type ConditionReason
- type ConditionType
- type CustomSpecFns
- type DefaultDeletionCheck
- type DefaultInfoToResourceConverter
- type DefaultResourceToInfoConverter
- type ExistsReadyCheck
- type Hook
- type InMemoryManifestCache
- type InfoToResourceConverter
- type ManifestCache
- type ManifestParser
- type MemoryClientCache
- type ModuleCRDeletionCheck
- type Object
- type ObjectTransform
- type Option
- type Options
- type PostRenderTransformOption
- type PostRun
- type PreDelete
- type ProxyClient
- func (p *ProxyClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (p *ProxyClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
- func (p *ProxyClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
- func (p *ProxyClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object, ...) error
- func (p *ProxyClient) GroupVersionKindFor(obj machineryruntime.Object) (schema.GroupVersionKind, error)
- func (p *ProxyClient) IsObjectNamespaced(obj machineryruntime.Object) (bool, error)
- func (p *ProxyClient) List(ctx context.Context, obj client.ObjectList, opts ...client.ListOption) error
- func (p *ProxyClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (p *ProxyClient) RESTMapper() meta.RESTMapper
- func (p *ProxyClient) Scheme() *machineryruntime.Scheme
- func (p *ProxyClient) Status() client.StatusWriter
- func (p *ProxyClient) SubResource(subResource string) client.SubResourceClient
- func (p *ProxyClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
- type ReadyCheck
- type Reconciler
- type RenderMode
- type ResourceInfoConverter
- type ResourceList
- func (r *ResourceList) Append(val *resource.Info)
- func (r ResourceList) Contains(info *resource.Info) bool
- func (r ResourceList) Difference(rs ResourceList) ResourceList
- func (r ResourceList) Filter(fn func(*resource.Info) bool) ResourceList
- func (r ResourceList) Get(info *resource.Info) *resource.Info
- func (r ResourceList) Intersect(rs ResourceList) ResourceList
- func (r ResourceList) Visit(fn resource.VisitorFunc) error
- type ResourceToInfoConverter
- type SSA
- type SingletonClients
- func (s *SingletonClients) ClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error)
- func (s *SingletonClients) OpenAPIGetter() *openapi.CachedOpenAPIGetter
- func (s *SingletonClients) OpenAPISchema() (openapi.Resources, error)
- func (s *SingletonClients) ResourceInfo(obj *unstructured.Unstructured, retryOnNoMatch bool) (*resource.Info, error)
- func (s *SingletonClients) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
- func (s *SingletonClients) ToRESTConfig() (*rest.Config, error)
- func (s *SingletonClients) ToRESTMapper() (meta.RESTMapper, error)
- func (s *SingletonClients) ToRawKubeConfigLoader() clientcmd.ClientConfig
- func (s *SingletonClients) UnstructuredClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error)
- type SkipReconcile
- type Spec
- type SpecResolver
- type SpecResolverOption
- type StateInfo
- type WithClientCacheKeyOption
- type WithCustomReadyCheckOption
- type WithCustomResourceLabels
- type WithFieldOwner
- type WithFinalizer
- type WithManagerOption
- type WithManifestCache
- type WithManifestParserOption
- type WithModuleCRDeletionCheckOption
- type WithNamespaceOption
- type WithPostRun
- type WithPreDelete
- type WithRemoteTargetClusterOption
- type WithSingletonClientCacheOption
- type WithSkipReconcileOnOption
Constants ¶
const ( OperatorName = "module-manager" ManagedByLabelValue = "declarative-v2" DisclaimerAnnotation = shared.OperatorGroup + shared.Separator + "managed-by-reconciler-disclaimer" DisclaimerAnnotationValue = "DO NOT EDIT - This resource is managed by Kyma.\n" + "Any modifications are discarded and the resource is reverted to the original state." OwnedByFormat = "%s/%s" )
const ( FinalizerDefault = "declarative.kyma-project.io/finalizer" FieldOwnerDefault = "declarative.kyma-project.io/applier" EventRecorderDefault = "declarative.kyma-project.io/events" DefaultInMemoryParseTTL = 24 * time.Hour )
const ( CustomResourceManager = "resource.kyma-project.io/finalizer" SyncedOCIRefAnnotation = "sync-oci-ref" )
const (
ManifestFilePrefix = "manifest"
)
Variables ¶
var ( ErrWarningResourceSyncStateDiff = errors.New("resource syncTarget state diff detected") ErrResourceSyncDiffInSameOCILayer = errors.New("resource syncTarget diff detected but in " + "same oci layer, prevent sync resource to be deleted") ErrInstallationConditionRequiresUpdate = errors.New("installation condition needs an update") ErrObjectHasEmptyState = errors.New("object has an empty state") ErrRequeueRequired = errors.New("requeue required") ErrAccessSecretNotFound = errors.New("access secret not found") )
var ( ErrClientObjectConversionFailed = errors.New("client object conversion failed") ErrServerSideApplyFailed = errors.New("ServerSideApply failed") )
var ErrNotValidClientObject = errors.New("object in resource info is not a valid client object")
Functions ¶
func DisclaimerTransform ¶
func DisclaimerTransform(_ context.Context, _ Object, resources []*unstructured.Unstructured) error
func KymaComponentTransform ¶
func KymaComponentTransform(_ context.Context, obj Object, resources []*unstructured.Unstructured) error
func ManagedByDeclarativeV2 ¶
func ManagedByDeclarativeV2(_ context.Context, _ Object, resources []*unstructured.Unstructured) error
func NewClientProxy ¶
NewClientProxy returns a new instance of ProxyClient.
Types ¶
type Client ¶
type Client interface { resource.RESTClientGetter ResourceInfoConverter client.Client }
type ClientCache ¶
type ClusterInfo ¶
ClusterInfo describes client and config for a cluster.
func (ClusterInfo) IsEmpty ¶
func (r ClusterInfo) IsEmpty() bool
IsEmpty indicates if ClusterInfo is empty.
type ConcurrentDefaultSSA ¶
type ConcurrentDefaultSSA struct {
// contains filtered or unexported fields
}
func ConcurrentSSA ¶
func ConcurrentSSA(clnt client.Client, owner client.FieldOwner) *ConcurrentDefaultSSA
type ConditionReason ¶
type ConditionReason string
const ( ConditionReasonResourcesAreAvailable ConditionReason = "ResourcesAvailable" ConditionReasonReady ConditionReason = "Ready" )
type ConditionType ¶
type ConditionType string
const ( ConditionTypeResources ConditionType = "Resources" ConditionTypeInstallation ConditionType = "Installation" )
type CustomSpecFns ¶
type CustomSpecFns struct { ManifestNameFn func(ctx context.Context, obj Object) string PathFn func(ctx context.Context, obj Object) string OCIRefFn func(ctx context.Context, obj Object) string ModeFn func(ctx context.Context, obj Object) RenderMode }
CustomSpecFns is a simple static resolver that always uses the same chart and values.
func DefaultSpec ¶
func DefaultSpec(path, ociref string, mode RenderMode) *CustomSpecFns
type DefaultDeletionCheck ¶
type DefaultDeletionCheck struct{}
func NewDefaultDeletionCheck ¶
func NewDefaultDeletionCheck() *DefaultDeletionCheck
NewDefaultDeletionCheck creates a check that verifies that the Resource CR in the remote cluster is deleted.
type DefaultInfoToResourceConverter ¶
type DefaultInfoToResourceConverter struct{}
func NewInfoToResourceConverter ¶
func NewInfoToResourceConverter() *DefaultInfoToResourceConverter
func (*DefaultInfoToResourceConverter) InfosToResources ¶
func (c *DefaultInfoToResourceConverter) InfosToResources(infos []*resource.Info) []shared.Resource
type DefaultResourceToInfoConverter ¶
type DefaultResourceToInfoConverter struct {
// contains filtered or unexported fields
}
func NewResourceToInfoConverter ¶
func NewResourceToInfoConverter( converter ResourceInfoConverter, defaultNamespace string, ) *DefaultResourceToInfoConverter
func (*DefaultResourceToInfoConverter) ResourcesToInfos ¶
func (*DefaultResourceToInfoConverter) UnstructuredToInfos ¶
func (c *DefaultResourceToInfoConverter) UnstructuredToInfos( resources []*unstructured.Unstructured, ) ([]*resource.Info, error)
type ExistsReadyCheck ¶
type ExistsReadyCheck struct{}
func NewExistsReadyCheck ¶
func NewExistsReadyCheck() *ExistsReadyCheck
type Hook ¶
Hook defines a Hook into the declarative reconciliation skr is the runtime cluster kcp is the control-plane cluster obj is guaranteed to be the reconciled object and also to always preside in kcp.
type InMemoryManifestCache ¶
type InMemoryManifestCache struct { TTL time.Duration *ttlcache.Cache[string, internal.ManifestResources] }
func NewInMemoryCachedManifestParser ¶
func NewInMemoryCachedManifestParser(ttl time.Duration) *InMemoryManifestCache
func (*InMemoryManifestCache) EvictCache ¶
func (c *InMemoryManifestCache) EvictCache(spec *Spec)
func (*InMemoryManifestCache) Parse ¶
func (c *InMemoryManifestCache) Parse(spec *Spec, ) (internal.ManifestResources, error)
type InfoToResourceConverter ¶
type ManifestCache ¶
type ManifestCache string
type ManifestParser ¶
type ManifestParser interface { Parse(spec *Spec) (internal.ManifestResources, error) EvictCache(spec *Spec) }
type MemoryClientCache ¶
type MemoryClientCache struct {
// contains filtered or unexported fields
}
func NewMemoryClientCache ¶
func NewMemoryClientCache() *MemoryClientCache
func (*MemoryClientCache) AddClient ¶
func (m *MemoryClientCache) AddClient(key string, value Client)
func (*MemoryClientCache) DeleteClient ¶
func (m *MemoryClientCache) DeleteClient(key string)
func (*MemoryClientCache) GetClient ¶
func (m *MemoryClientCache) GetClient(key string) Client
func (*MemoryClientCache) Size ¶
func (m *MemoryClientCache) Size() int
type ModuleCRDeletionCheck ¶
type ObjectTransform ¶
type ObjectTransform = func(context.Context, Object, []*unstructured.Unstructured) error
type Options ¶
type Options struct { record.EventRecorder Config *rest.Config client.Client TargetCluster ClusterFn SpecResolver ClientCache ClientCacheKeyFn ManifestParser ManifestCache CustomReadyCheck ReadyCheck Namespace string CreateNamespace bool Finalizer string ServerSideApply bool FieldOwner client.FieldOwner PostRenderTransforms []ObjectTransform PostRuns []PostRun PreDeletes []PreDelete DeletionCheck ModuleCRDeletionCheck DeletePrerequisites bool ShouldSkip SkipReconcile }
func DefaultOptions ¶
func DefaultOptions() *Options
type PostRenderTransformOption ¶
type PostRenderTransformOption struct {
ObjectTransforms []ObjectTransform
}
func WithPostRenderTransform ¶
func WithPostRenderTransform(transforms ...ObjectTransform) PostRenderTransformOption
func (PostRenderTransformOption) Apply ¶
func (o PostRenderTransformOption) Apply(options *Options)
type PostRun ¶
type PostRun Hook
PostRun is executed after every successful render+reconciliation of the manifest.
type PreDelete ¶
type PreDelete Hook
PreDelete is executed before any deletion of resources calculated from the status.
type ProxyClient ¶
type ProxyClient struct {
// contains filtered or unexported fields
}
ProxyClient holds information required to proxy Client requests to verify RESTMapper integrity. During the proxy, the underlying mapper verifies mapping for the calling resource. If not available and NoMatchesKind error occurs, the mappings are reset (if type meta.ResettableRESTMapper). After reset a follow-up call verifies if mappings are now available.
func (*ProxyClient) Create ¶
func (p *ProxyClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
Create implements client.Client.
func (*ProxyClient) Delete ¶
func (p *ProxyClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
Delete implements client.Client.
func (*ProxyClient) DeleteAllOf ¶
func (p *ProxyClient) DeleteAllOf( ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption, ) error
DeleteAllOf implements client.Client.
func (*ProxyClient) Get ¶
func (p *ProxyClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption, ) error
Get implements client.Client.
func (*ProxyClient) GroupVersionKindFor ¶
func (p *ProxyClient) GroupVersionKindFor(obj machineryruntime.Object) (schema.GroupVersionKind, error)
func (*ProxyClient) IsObjectNamespaced ¶
func (p *ProxyClient) IsObjectNamespaced(obj machineryruntime.Object) (bool, error)
func (*ProxyClient) List ¶
func (p *ProxyClient) List(ctx context.Context, obj client.ObjectList, opts ...client.ListOption) error
List implements client.Client.
func (*ProxyClient) Patch ¶
func (p *ProxyClient) Patch( ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption, ) error
Patch implements client.Client.
func (*ProxyClient) RESTMapper ¶
func (p *ProxyClient) RESTMapper() meta.RESTMapper
RESTMapper returns the rest mapper this client is using.
func (*ProxyClient) Scheme ¶
func (p *ProxyClient) Scheme() *machineryruntime.Scheme
Scheme returns the scheme this client is using.
func (*ProxyClient) Status ¶
func (p *ProxyClient) Status() client.StatusWriter
Status implements client.StatusClient.
func (*ProxyClient) SubResource ¶
func (p *ProxyClient) SubResource(subResource string) client.SubResourceClient
func (*ProxyClient) Update ¶
func (p *ProxyClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
Update implements client.Client.
type ReadyCheck ¶
type Reconciler ¶
type Reconciler struct { queue.RequeueIntervals *Options ManifestMetrics *metrics.ManifestMetrics MandatoryModuleMetrics *metrics.MandatoryModulesMetrics // contains filtered or unexported fields }
func NewFromManager ¶
func NewFromManager(mgr manager.Manager, prototype Object, requeueIntervals queue.RequeueIntervals, metrics *metrics.ManifestMetrics, mandatoryModulesMetrics *metrics.MandatoryModulesMetrics, options ...Option, ) *Reconciler
type ResourceInfoConverter ¶
type ResourceInfoConverter interface {
ResourceInfo(obj *unstructured.Unstructured, retryOnNoMatch bool) (*resource.Info, error)
}
type ResourceList ¶
ResourceList provides convenience methods for comparing collections of Infos. Copy from helm.sh/helm/v3/pkg/kube.
func (*ResourceList) Append ¶
func (r *ResourceList) Append(val *resource.Info)
Append adds an Info to the Result.
func (ResourceList) Contains ¶
func (r ResourceList) Contains(info *resource.Info) bool
Contains checks to see if an object exists.
func (ResourceList) Difference ¶
func (r ResourceList) Difference(rs ResourceList) ResourceList
Difference will return a new Result with objects not contained in rs.
func (ResourceList) Filter ¶
func (r ResourceList) Filter(fn func(*resource.Info) bool) ResourceList
Filter returns a new Result with Infos that satisfy the predicate fn.
func (ResourceList) Get ¶
func (r ResourceList) Get(info *resource.Info) *resource.Info
Get returns the Info from the result that matches the name and kind.
func (ResourceList) Intersect ¶
func (r ResourceList) Intersect(rs ResourceList) ResourceList
Intersect will return a new Result with objects contained in both Results.
func (ResourceList) Visit ¶
func (r ResourceList) Visit(fn resource.VisitorFunc) error
Visit implements resource.Visitor.
type ResourceToInfoConverter ¶
type ResourceToInfoConverter interface { ResourcesToInfos(resource []shared.Resource) ([]*resource.Info, error) UnstructuredToInfos(obj []*unstructured.Unstructured) ([]*resource.Info, error) }
type SingletonClients ¶
type SingletonClients struct { // controller runtime client client.Client // contains filtered or unexported fields }
SingletonClients serves as a single-minded client interface that combines all kubernetes Client APIs (Kubernetes, Client-Go) under the hood. It offers a simple initialization lifecycle during creation, but delegates all heavy-duty work to deferred discovery logic and a single http client as well as a client cache to support GV-based clients.
func NewSingletonClients ¶
func NewSingletonClients(info *ClusterInfo) (*SingletonClients, error)
func (*SingletonClients) ClientForMapping ¶
func (s *SingletonClients) ClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error)
ClientForMapping returns a RESTClient for working with the specified RESTMapping or an error. This is intended for working with arbitrary resources and is not guaranteed to point to a Kubernetes APIServer.
func (*SingletonClients) OpenAPIGetter ¶
func (s *SingletonClients) OpenAPIGetter() *openapi.CachedOpenAPIGetter
OpenAPIGetter returns a getter for the openapi schema document.
func (*SingletonClients) OpenAPISchema ¶
func (s *SingletonClients) OpenAPISchema() (openapi.Resources, error)
OpenAPISchema returns metadata and structural information about Kubernetes object definitions.
func (*SingletonClients) ResourceInfo ¶
func (s *SingletonClients) ResourceInfo(obj *unstructured.Unstructured, retryOnNoMatch bool) (*resource.Info, error)
func (*SingletonClients) ToDiscoveryClient ¶
func (s *SingletonClients) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
func (*SingletonClients) ToRESTConfig ¶
func (s *SingletonClients) ToRESTConfig() (*rest.Config, error)
func (*SingletonClients) ToRESTMapper ¶
func (s *SingletonClients) ToRESTMapper() (meta.RESTMapper, error)
func (*SingletonClients) ToRawKubeConfigLoader ¶
func (s *SingletonClients) ToRawKubeConfigLoader() clientcmd.ClientConfig
func (*SingletonClients) UnstructuredClientForMapping ¶
func (s *SingletonClients) UnstructuredClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error)
UnstructuredClientForMapping returns a RESTClient for working with Unstructured objects.
type SpecResolver ¶
type SpecResolverOption ¶
type SpecResolverOption struct {
SpecResolver
}
func WithSpecResolver ¶
func WithSpecResolver(resolver SpecResolver) SpecResolverOption
func (SpecResolverOption) Apply ¶
func (o SpecResolverOption) Apply(options *Options)
type WithClientCacheKeyOption ¶
type WithClientCacheKeyOption struct {
ClientCacheKeyFn
}
func (WithClientCacheKeyOption) Apply ¶
func (o WithClientCacheKeyOption) Apply(options *Options)
type WithCustomReadyCheckOption ¶
type WithCustomReadyCheckOption struct {
ReadyCheck
}
func WithCustomReadyCheck ¶
func WithCustomReadyCheck(check ReadyCheck) WithCustomReadyCheckOption
func (WithCustomReadyCheckOption) Apply ¶
func (o WithCustomReadyCheckOption) Apply(options *Options)
type WithCustomResourceLabels ¶
func (WithCustomResourceLabels) Apply ¶
func (o WithCustomResourceLabels) Apply(options *Options)
type WithFieldOwner ¶
type WithFieldOwner client.FieldOwner
func (WithFieldOwner) Apply ¶
func (o WithFieldOwner) Apply(options *Options)
type WithFinalizer ¶
type WithFinalizer string
func (WithFinalizer) Apply ¶
func (o WithFinalizer) Apply(options *Options)
type WithManagerOption ¶
func WithManager ¶
func WithManager(mgr manager.Manager) WithManagerOption
func (WithManagerOption) Apply ¶
func (o WithManagerOption) Apply(options *Options)
type WithManifestCache ¶
type WithManifestCache ManifestCache
func (WithManifestCache) Apply ¶
func (o WithManifestCache) Apply(options *Options)
type WithManifestParserOption ¶
type WithManifestParserOption struct {
ManifestParser
}
func WithManifestParser ¶
func WithManifestParser(parser ManifestParser) WithManifestParserOption
func (WithManifestParserOption) Apply ¶
func (o WithManifestParserOption) Apply(options *Options)
type WithModuleCRDeletionCheckOption ¶
type WithModuleCRDeletionCheckOption struct {
ModuleCRDeletionCheck
}
func WithModuleCRDeletionCheck ¶
func WithModuleCRDeletionCheck(deletionCheckFn ModuleCRDeletionCheck) WithModuleCRDeletionCheckOption
func (WithModuleCRDeletionCheckOption) Apply ¶
func (o WithModuleCRDeletionCheckOption) Apply(options *Options)
type WithNamespaceOption ¶
type WithNamespaceOption struct {
// contains filtered or unexported fields
}
func WithNamespace ¶
func WithNamespace(name string, createIfMissing bool) WithNamespaceOption
func (WithNamespaceOption) Apply ¶
func (o WithNamespaceOption) Apply(options *Options)
type WithPostRun ¶
type WithPostRun []PostRun
WithPostRun applies PostRun.
func (WithPostRun) Apply ¶
func (o WithPostRun) Apply(options *Options)
type WithPreDelete ¶
type WithPreDelete []PreDelete
WithPreDelete applies PreDelete.
func (WithPreDelete) Apply ¶
func (o WithPreDelete) Apply(options *Options)
type WithRemoteTargetClusterOption ¶
type WithRemoteTargetClusterOption struct {
ClusterFn
}
func WithRemoteTargetCluster ¶
func WithRemoteTargetCluster(configFn ClusterFn) WithRemoteTargetClusterOption
func (WithRemoteTargetClusterOption) Apply ¶
func (o WithRemoteTargetClusterOption) Apply(options *Options)
type WithSingletonClientCacheOption ¶
type WithSingletonClientCacheOption struct {
ClientCache
}
func WithSingletonClientCache ¶
func WithSingletonClientCache(cache ClientCache) WithSingletonClientCacheOption
func (WithSingletonClientCacheOption) Apply ¶
func (o WithSingletonClientCacheOption) Apply(options *Options)
type WithSkipReconcileOnOption ¶
type WithSkipReconcileOnOption struct {
// contains filtered or unexported fields
}
func WithSkipReconcileOn ¶
func WithSkipReconcileOn(skipReconcile SkipReconcile) WithSkipReconcileOnOption
func (WithSkipReconcileOnOption) Apply ¶
func (o WithSkipReconcileOnOption) Apply(options *Options)