Documentation
¶
Overview ¶
Package runtime manages the reflection of Timoni's instances on Kubernetes clusters.
Index ¶
- func ApplyOptions(force bool, wait time.Duration) ssa.ApplyOptions
- func DeleteOptions(name, namespace string) ssa.DeleteOptions
- func NewCustomJobStatusReader(mapper meta.RESTMapper) engine.StatusReader
- func NewResourceManager(rcg genericclioptions.RESTClientGetter, readers ...StatusReaderFactory) (*ssa.ResourceManager, error)
- func SelectObjectsFromSet(set *ssa.ChangeSet, action ssa.Action) []*unstructured.Unstructured
- func ServerVersion(rcg genericclioptions.RESTClientGetter) (string, error)
- func TakeOwnership(ctx context.Context, kubeClient client.Client, ...) error
- func ToUnstructured(obj apiruntime.Object) (*unstructured.Unstructured, error)
- type InstanceManager
- func (m *InstanceManager) AddObjects(objects []*unstructured.Unstructured) error
- func (m *InstanceManager) Diff(target *apiv1.ResourceInventory) ([]*unstructured.Unstructured, error)
- func (m *InstanceManager) ListMeta() (object.ObjMetadataSet, error)
- func (m *InstanceManager) ListObjects() ([]*unstructured.Unstructured, error)
- func (m *InstanceManager) VersionOf(objMetadata object.ObjMetadata) string
- type ResourceReader
- type StatusReaderFactory
- type StorageManager
- func (s *StorageManager) Apply(ctx context.Context, instance *apiv1.Instance, createNamespace bool) error
- func (s *StorageManager) Delete(ctx context.Context, name, namespace string) error
- func (s *StorageManager) Get(ctx context.Context, name, namespace string) (*apiv1.Instance, error)
- func (s *StorageManager) GetStaleObjects(ctx context.Context, i *apiv1.Instance) ([]*unstructured.Unstructured, error)
- func (s *StorageManager) List(ctx context.Context, namespace, bundle string) ([]*apiv1.Instance, error)
- func (s *StorageManager) ListNamespaces(ctx context.Context) ([]string, error)
- func (s *StorageManager) NamespaceExists(ctx context.Context, name string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyOptions ¶ added in v0.0.2
func ApplyOptions(force bool, wait time.Duration) ssa.ApplyOptions
ApplyOptions returns the default options for server-side apply operations. The cleanup options transfer the ownership of objects managed with kubectl or Helm to Timoni, and remove their tracking metadata.
func DeleteOptions ¶ added in v0.0.2
func DeleteOptions(name, namespace string) ssa.DeleteOptions
DeleteOptions returns the default options for delete operations.
func NewCustomJobStatusReader ¶ added in v0.15.0
func NewCustomJobStatusReader(mapper meta.RESTMapper) engine.StatusReader
NewCustomJobStatusReader creates a reader that asserts a Job completion status.
func NewResourceManager ¶
func NewResourceManager(rcg genericclioptions.RESTClientGetter, readers ...StatusReaderFactory) (*ssa.ResourceManager, error)
NewResourceManager creates a ResourceManager for the given cluster. The manager's client and status poller share a dynamic RESTMapper that discovers kinds registered by CRDs applied during the current run. The optional factories add custom kstatus readers to the status poller, next to the built-in Kubernetes Job one.
func SelectObjectsFromSet ¶ added in v0.0.2
func SelectObjectsFromSet(set *ssa.ChangeSet, action ssa.Action) []*unstructured.Unstructured
SelectObjectsFromSet returns a list of Kubernetes objects from the given changeset filtered by action.
func ServerVersion ¶ added in v0.12.0
func ServerVersion(rcg genericclioptions.RESTClientGetter) (string, error)
ServerVersion retrieves and parses the Kubernetes server's version.
func TakeOwnership ¶ added in v0.31.0
func TakeOwnership(ctx context.Context, kubeClient client.Client, objects []*unstructured.Unstructured) error
TakeOwnership transfers the ownership of the given objects' fields from kubectl and Helm to Timoni's field manager before server-side applying them, so that the apply replaces the fields set with these tools instead of merging with them. Objects not found on the cluster, without matching field managers, or annotated with the if-not-present action are skipped.
func ToUnstructured ¶ added in v0.15.0
func ToUnstructured(obj apiruntime.Object) (*unstructured.Unstructured, error)
ToUnstructured converts a runtime.Object into an Unstructured object.
Types ¶
type InstanceManager ¶
InstanceManager performs operations on the instance's inventory.
func NewInstanceManager ¶
func NewInstanceManager(name, namespace, values string, moduleRef apiv1.ModuleReference) *InstanceManager
NewInstanceManager creates an InstanceManager for the given module.
func (*InstanceManager) AddObjects ¶
func (m *InstanceManager) AddObjects(objects []*unstructured.Unstructured) error
AddObjects extracts the metadata from the given objects and adds it to the instance inventory.
func (*InstanceManager) Diff ¶
func (m *InstanceManager) Diff(target *apiv1.ResourceInventory) ([]*unstructured.Unstructured, error)
Diff returns the slice of objects that do not exist in the target inventory.
func (*InstanceManager) ListMeta ¶
func (m *InstanceManager) ListMeta() (object.ObjMetadataSet, error)
ListMeta returns the inventory entries as object.ObjMetadata objects.
func (*InstanceManager) ListObjects ¶
func (m *InstanceManager) ListObjects() ([]*unstructured.Unstructured, error)
ListObjects returns the inventory entries as unstructured.Unstructured objects.
func (*InstanceManager) VersionOf ¶
func (m *InstanceManager) VersionOf(objMetadata object.ObjMetadata) string
VersionOf returns the API version of the given object if found in this instance.
type ResourceReader ¶ added in v0.13.0
type ResourceReader struct {
// contains filtered or unexported fields
}
ResourceReader fetches resources from the cluster and extract field values.
func NewResourceReader ¶ added in v0.13.0
func NewResourceReader(resManager *ssa.ResourceManager) *ResourceReader
NewResourceReader creates a resource reader for the given cluster.
func (*ResourceReader) Read ¶ added in v0.13.0
func (r *ResourceReader) Read(ctx context.Context, refs []apiv1.RuntimeResourceRef) (map[string]string, error)
Read fetches the resources from the cluster and runs the CUE expressions to select the desired values.
type StatusReaderFactory ¶ added in v0.29.0
type StatusReaderFactory func(mapper meta.RESTMapper) pollingEngine.StatusReader
StatusReaderFactory creates a kstatus StatusReader for the given REST mapper.
func NewCustomHealthStatusReader ¶ added in v0.29.0
func NewCustomHealthStatusReader(checks []*engine.HealthCheck) StatusReaderFactory
NewCustomHealthStatusReader returns a factory for a status reader that evaluates the module-defined CUE health checks on the live objects matching their GroupKind. A check with an exact GroupKind match takes precedence over a group-wide one (empty Kind).
type StorageManager ¶
type StorageManager struct {
// contains filtered or unexported fields
}
StorageManager manages the inventory in-cluster storage.
func NewStorageManager ¶
func NewStorageManager(resManager *ssa.ResourceManager) *StorageManager
NewStorageManager creates a storage manager for the given cluster.
func (*StorageManager) Apply ¶
func (s *StorageManager) Apply(ctx context.Context, instance *apiv1.Instance, createNamespace bool) error
Apply creates or updates the storage object for the given instance.
func (*StorageManager) Delete ¶
func (s *StorageManager) Delete(ctx context.Context, name, namespace string) error
Delete removes the storage for the given instance name and namespace.
func (*StorageManager) GetStaleObjects ¶
func (s *StorageManager) GetStaleObjects(ctx context.Context, i *apiv1.Instance) ([]*unstructured.Unstructured, error)
GetStaleObjects returns the list of objects metadata subject to pruning.
func (*StorageManager) List ¶
func (s *StorageManager) List(ctx context.Context, namespace, bundle string) ([]*apiv1.Instance, error)
List returns the instances found in the given namespace.
func (*StorageManager) ListNamespaces ¶ added in v0.11.0
func (s *StorageManager) ListNamespaces(ctx context.Context) ([]string, error)
func (*StorageManager) NamespaceExists ¶ added in v0.0.2
NamespaceExists returns false if the namespace is not found.