inventory

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

inventory package contains structures and functions for generating an "inventory" of resource managed by the tool. This inventory can keep track of what has been deployed before and what is not deployed anymore to do a smart pruning of old objects to keep the remote server in sync with the local manifests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	Inventory Store
	// contains filtered or unexported fields
}

Manager will save and manage the current state of objects for

func NewManager

func NewManager(inventory Store, startingObjects []*unstructured.Unstructured) *Manager

NewManager create a new instace of a manger for the given inventory Store

func (*Manager) DeleteRemoteInventoryIfPossible

func (m *Manager) DeleteRemoteInventoryIfPossible(ctx context.Context, dryRun bool) error

DeleteRemoteInventoryIfPossible calling this method will remove the remote invetory storage if possible. If any object has been marked as failed to delete for any reason, we cannot remove

func (*Manager) IsFailedApply added in v0.3.0

func (m *Manager) IsFailedApply(obj *unstructured.Unstructured) bool

IsFailedApply return if the passed in object has been marked as failed to apply from the manager

func (*Manager) IsSkipped added in v0.3.0

func (m *Manager) IsSkipped(obj *unstructured.Unstructured) bool

IsSkipped return if the passed in object has been marked as skipped from the manager

func (*Manager) SaveCurrentInventoryState

func (m *Manager) SaveCurrentInventoryState(ctx context.Context, dryRun bool) error

SaveCurrentInventoryState will use the current tracked objects statuses for creating a new inventory status and persist it to the remote server

func (*Manager) SetFailedApply

func (m *Manager) SetFailedApply(obj *unstructured.Unstructured)

SetFailedApply keep track of the passed objs as failed to apply

func (*Manager) SetFailedDelete

func (m *Manager) SetFailedDelete(obj *unstructured.Unstructured)

SetFailedDelete keep track of the passed objs as failed to delete

func (*Manager) SetSkipped added in v0.3.0

func (m *Manager) SetSkipped(obj *unstructured.Unstructured)

SetSkipped keep track of the passed objs as skipped

func (*Manager) SetSuccessfullApply

func (m *Manager) SetSuccessfullApply(obj *unstructured.Unstructured)

SetSuccessfullApply keep track of the passed objs as successfully applied

func (*Manager) SetSuccessfullDelete

func (m *Manager) SetSuccessfullDelete(obj *unstructured.Unstructured)

SetSuccessfullDelete keep track of the passed objs as successfully deleted

type Store

type Store interface {
	// Load will read the inventory data from the remote storage of the inventory
	Load(ctx context.Context) (sets.Set[resource.ObjectMetadata], error)

	// Save will persist the underling in memory inventory data for access on subsequent interaction
	Save(ctx context.Context, dryRun bool) error

	// Delete will remove remote storage of the inventory
	Delete(ctx context.Context, dryRun bool) error

	// SetObjects will replace the current in memory objects inventory data
	SetObjects(objects sets.Set[*unstructured.Unstructured])
}

Store define an interface for working with an inventory of deployed resources, without knowning the underling technology that is used for persisting the data

func NewConfigMapStore

func NewConfigMapStore(factory util.ClientFactory, name, namespace, fieldManager string) (Store, error)

NewConfigMapStore return a new Store instance configured with the provided factory that will persist data via a ConfigMap resource. The namespace is where the backing ConfigMap will be read and saved.

Directories

Path Synopsis
fake package provide a fake implementation of an inventory Store for using during tests.
fake package provide a fake implementation of an inventory Store for using during tests.

Jump to

Keyboard shortcuts

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