synk

package
v0.0.0-...-9c93095 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package synk contains functionality to synchronize a batch of resources with a cluster while correctly handling CRDs and deletions.

Index

Constants

View Source
const (
	StatusSuccess = "success"
	StatusFailure = "failure"
)

Variables

This section is empty.

Functions

func IsTransientErr

func IsTransientErr(err error) bool

IsTransientErr returns true if the error may resolve by retrying the operation.

Types

type ApplyOptions

type ApplyOptions struct {

	// Namespace that's set for all namespaced resources that have no
	// other namespace set yet.
	Namespace string
	// EnforceNamespace causes apply to fail if a resource has a namespace set
	// that's different from Namespace.
	EnforceNamespace bool

	// Log functions to report progress and failures while applying resources.
	Log func(r *unstructured.Unstructured, a apps.ResourceAction, status, msg string)
	// contains filtered or unexported fields
}

TODO: determine options that allow us to be semantically compatible with vanilla kubectl apply.

type Interface

type Interface interface {
	Init() error
	Delete(ctx context.Context, name string) error
	Apply(ctx context.Context, name string, opts *ApplyOptions, resources ...*unstructured.Unstructured) (*apps.ResourceSet, error)
}

type Synk

type Synk struct {
	// contains filtered or unexported fields
}

Synk allows to synchronize sets of resources with a fixed cluster.

func New

New returns a new Synk object that acts against the cluster for the given configuration.

func NewForConfig

func NewForConfig(cfg *rest.Config) (*Synk, error)

func (*Synk) Apply

func (s *Synk) Apply(
	ctx context.Context,
	name string,
	opts *ApplyOptions,
	resources ...*unstructured.Unstructured,
) (*apps.ResourceSet, error)

Apply installs or updates the ResourceSet specified by 'name'.

func (*Synk) Delete

func (s *Synk) Delete(ctx context.Context, name string) error

Delete removes the resources that are part of the ResourceSet specified by 'name'. It uses so-called "foreground cascading deletion", which means that:

- it returns after marking the ResourceSet for deletion, but before the

resources have been deleted

- the ResourceSet will not be deleted until all resources have been deleted

This ensures that if a new ResourceSet is created before all resources have been deleted, it will have a higher version number.

func (*Synk) Init

func (s *Synk) Init() error

Init installs the ResourceSet CRD into the cluster and waits for it to become available. It does not need to be called before each use of Synk.

Jump to

Keyboard shortcuts

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