v2

package
v0.0.0-...-0fb437b Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	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"
)
View Source
const (
	EventRecorderDefault    = "declarative.kyma-project.io/events"
	DefaultInMemoryParseTTL = 24 * time.Hour
)
View Source
const (
	ManifestFilePrefix = "manifest"
)
View Source
const (
	SyncedOCIRefAnnotation = "sync-oci-ref"
)

Variables

View Source
var (
	ErrManagerInErrorState            = errors.New("manager is in error state")
	ErrResourceSyncDiffInSameOCILayer = errors.New("resource syncTarget diff detected but in " +
		"same oci layer, prevent sync resource to be deleted")
)
View Source
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 ManagedByOwnedBy

func ManagedByOwnedBy(_ context.Context, obj Object, resources []*unstructured.Unstructured) error

func NewClientProxy

func NewClientProxy(config *rest.Config, mapper meta.RESTMapper) (client.Client, error)

NewClientProxy returns a new instance of ProxyClient.

Types

type ClientCache

type ClientCache interface {
	GetClient(key string) Client
	AddClient(key string, client Client)
	DeleteClient(key string)
}

type ClientCacheKeyFn

type ClientCacheKeyFn func(ctx context.Context, obj Object) (string, bool)

type ClusterFn

type ClusterFn func(context.Context, Object) (*ClusterInfo, error)

type ClusterInfo

type ClusterInfo struct {
	Config *rest.Config
	Client client.Client
}

ClusterInfo describes client and config for a cluster.

func (ClusterInfo) IsEmpty

func (r ClusterInfo) IsEmpty() bool

IsEmpty indicates if ClusterInfo is empty.

type ExistsStateCheck

type ExistsStateCheck struct{}

func NewExistsStateCheck

func NewExistsStateCheck() *ExistsStateCheck

func (*ExistsStateCheck) GetState

func (c *ExistsStateCheck) GetState(
	ctx context.Context,
	clnt client.Client,
	resources []*resource.Info,
) (shared.State, error)

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

type ManagedByLabelRemoval

type ManagedByLabelRemoval interface {
	RemoveManagedByLabel(ctx context.Context,
		manifest *v1beta2.Manifest,
		skrClient client.Client,
	) error
}

type ManifestAPIClient

type ManifestAPIClient interface {
	UpdateManifest(ctx context.Context, manifest *v1beta2.Manifest) error
	PatchStatusIfDiffExist(ctx context.Context, manifest *v1beta2.Manifest,
		previousStatus shared.Status) error
	SsaSpec(ctx context.Context, obj client.Object) error
}

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 Object

type Object interface {
	client.Object
	GetStatus() shared.Status
	SetStatus(status shared.Status)
}

type ObjectTransform

type ObjectTransform = func(context.Context, Object, []*unstructured.Unstructured) error

type Option

type Option interface {
	Apply(options *Options)
}

type Options

type Options struct {
	record.EventRecorder
	Config *rest.Config
	client.Client
	TargetCluster ClusterFn

	ClientCache
	ClientCacheKeyFn
	ManifestParser
	ManifestCache
	CustomStateCheck StateCheck

	PostRenderTransforms []ObjectTransform
}

func DefaultOptions

func DefaultOptions() *Options

func (*Options) Apply

func (o *Options) Apply(options ...Option) *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 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 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, requeueIntervals queue.RequeueIntervals, metrics *metrics.ManifestMetrics,
	mandatoryModulesMetrics *metrics.MandatoryModulesMetrics, manifestAPIClient ManifestAPIClient,
	specResolver SpecResolver, options ...Option,
) *Reconciler

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

type ResourceList

type ResourceList []*resource.Info

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 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 Spec

type Spec struct {
	ManifestName string
	Path         string
	OCIRef       string
}

type SpecResolver

type SpecResolver interface {
	GetSpec(ctx context.Context, manifest *v1beta2.Manifest) (*Spec, error)
}

type StateCheck

type StateCheck interface {
	GetState(ctx context.Context, clnt client.Client, resources []*resource.Info) (shared.State, error)
}

type WithClientCacheKeyOption

type WithClientCacheKeyOption struct {
	ClientCacheKeyFn
}

func (WithClientCacheKeyOption) Apply

func (o WithClientCacheKeyOption) Apply(options *Options)

type WithCustomResourceLabels

type WithCustomResourceLabels k8slabels.Set

func (WithCustomResourceLabels) Apply

func (o WithCustomResourceLabels) Apply(options *Options)

type WithCustomStateCheckOption

type WithCustomStateCheckOption struct {
	StateCheck
}

func WithCustomStateCheck

func WithCustomStateCheck(check StateCheck) WithCustomStateCheckOption

func (WithCustomStateCheckOption) Apply

func (o WithCustomStateCheckOption) Apply(options *Options)

type WithManagerOption

type WithManagerOption struct {
	manager.Manager
}

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 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)

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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