kubeinstall

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Attempt to create, return any error
	CreationPolicy_ReturnErrors = iota
	// Attempt to create, ignore  AlreadyExists error
	CreationPolicy_IgnoreOnExists
	// Attempt to create, fall back to Update on AlreadyExists error
	CreationPolicy_UpdateOnExists
	// Attempt to create, fall back to Update on AlreadyExists error, fall back to Destroy&Recreate on ImmutableField error
	CreationPolicy_ForceUpdateOnExists
)

Variables

View Source
var DefaultFilters = []kuberesource.FilterResource{
	func(resource schema.GroupVersionResource) bool {
		for _, ignoredType := range ignoreTypesForInstall {
			if resource.String() == ignoredType.String() {
				return true
			}
		}
		return false
	},
}

to speed up the cache init, filter out resource types

Functions

func ListAllCachedValues

func ListAllCachedValues(ctx context.Context, labelKey string, installer Installer) []string

Types

type Cache

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

Contains a snapshot of all installed resources Starts with a snapshot of everytihng in cluster Warning: takes about 30-45s (in testing) to initialize this cache

func NewCache

func NewCache() *Cache

starts locked, requires Init() to be unlocked

func (*Cache) Delete

func (c *Cache) Delete(obj *unstructured.Unstructured)

func (*Cache) Get

func (*Cache) Init

func (c *Cache) Init(ctx context.Context, cfg *rest.Config, filterFuncs ...kuberesource.FilterResource) error

Initialize the cache with the snapshot of the current cluster

func (*Cache) List

func (*Cache) Refresh added in v0.10.24

func (c *Cache) Refresh(ctx context.Context, cfg *rest.Config, filterFuncs ...kuberesource.FilterResource) error

Refresh the cache with the snapshot of the current cluster

func (*Cache) Set

func (c *Cache) Set(obj *unstructured.Unstructured)

type CallbackOption

type CallbackOption struct {
	OnPreInstall  func() error
	OnPostInstall func() error
	OnPreCreate   func(res *unstructured.Unstructured) error
	OnPostCreate  func(res *unstructured.Unstructured) error
	OnPreUpdate   func(res *unstructured.Unstructured) error
	OnPostUpdate  func(res *unstructured.Unstructured) error
	OnPreDelete   func(res *unstructured.Unstructured) error
	OnPostDelete  func(res *unstructured.Unstructured) error
}

func (*CallbackOption) PostCreate

func (cb *CallbackOption) PostCreate(res *unstructured.Unstructured) error

func (*CallbackOption) PostDelete

func (cb *CallbackOption) PostDelete(res *unstructured.Unstructured) error

func (*CallbackOption) PostInstall

func (cb *CallbackOption) PostInstall() error

func (*CallbackOption) PostUpdate

func (cb *CallbackOption) PostUpdate(res *unstructured.Unstructured) error

func (*CallbackOption) PreCreate

func (cb *CallbackOption) PreCreate(res *unstructured.Unstructured) error

func (*CallbackOption) PreDelete

func (cb *CallbackOption) PreDelete(res *unstructured.Unstructured) error

func (*CallbackOption) PreInstall

func (cb *CallbackOption) PreInstall() error

func (*CallbackOption) PreUpdate

func (cb *CallbackOption) PreUpdate(res *unstructured.Unstructured) error

type CallbackOptions

type CallbackOptions interface {
	PreInstall() error
	PostInstall() error
	PreCreate(res *unstructured.Unstructured) error
	PostCreate(res *unstructured.Unstructured) error
	PreUpdate(res *unstructured.Unstructured) error
	PostUpdate(res *unstructured.Unstructured) error
	PreDelete(res *unstructured.Unstructured) error
	PostDelete(res *unstructured.Unstructured) error
}

type CreationPolicy added in v0.9.19

type CreationPolicy int

policies for how to handle resource creation specifies behavior when resource creation fails

type Installer

type Installer interface {
	ReconcileResources(ctx context.Context, params ReconcileParams) error
	PurgeResources(ctx context.Context, withLabels map[string]string) error
	ListAllResources(ctx context.Context) kuberesource.UnstructuredResources
}

an interface allowing these methods to be mocked

type KubeInstaller

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

func NewKubeInstaller

func NewKubeInstaller(cfg *rest.Config, cache *Cache, opts *KubeInstallerOptions) (*KubeInstaller, error)

NewKubeInstaller does not initialize the cache. Should be one once globally

func (*KubeInstaller) ListAllResources

func (*KubeInstaller) PurgeResources

func (r *KubeInstaller) PurgeResources(ctx context.Context, withLabels map[string]string) error

func (*KubeInstaller) ReconcileResources

func (r *KubeInstaller) ReconcileResources(ctx context.Context, params ReconcileParams) error

type KubeInstallerOptions

type KubeInstallerOptions struct {
	Callbacks    []CallbackOptions
	RetryOptions []retry.Option
	// define how to handle AlreadyExist errors on resource creation
	CreationPolicy CreationPolicy
}

type ReconcileParams added in v0.9.21

type ReconcileParams struct {
	InstallNamespace string
	Resources        kuberesource.UnstructuredResources
	OwnerLabels      map[string]string
	// respect hard-coded namespaces inside of manifests
	RespectManifestNamespaces bool
}

func NewReconcileParams added in v0.9.21

func NewReconcileParams(installNamespace string, resources kuberesource.UnstructuredResources, ownerLabels map[string]string, respectManifestNamespaces bool) ReconcileParams

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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