inventory

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package inventory contains utilities for keeping a record of Kubernetes objects applied on a cluster.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	// ObjectID is the string representation of object.ObjMetadata,
	// in the format '<namespace>_<name>_<group>_<kind>'.
	ObjectID string `json:"id"`

	// ObjectVersion is the API version of this entry kind.
	ObjectVersion string `json:"ver"`
}

Entry contains the information necessary to locate the resource within a cluster.

type Inventory

type Inventory struct {
	// Name of the inventory configmap.
	Name string `json:"name"`

	// Namespace of the inventory configmap.
	Namespace string `json:"namespace"`

	// Source is the URL of the source code.
	Source string `json:"source,omitempty"`

	// Revision is the Source control revision identifier.
	Revision string `json:"revision,omitempty"`

	// Entries of Kubernetes objects metadata.
	Entries []Entry `json:"entries"`
}

Inventory is a record of objects that are applied on a cluster stored as a configmap.

func NewInventory

func NewInventory(name, namespace string) *Inventory

func (*Inventory) AddObjects

func (inv *Inventory) AddObjects(objects []*unstructured.Unstructured) error

AddObjects extracts the metadata from the given objects and adds it to the inventory.

func (*Inventory) Diff

func (inv *Inventory) Diff(target *Inventory) ([]*unstructured.Unstructured, error)

Diff returns the slice of objects that do not exist in the target inventory.

func (*Inventory) ListMeta

func (inv *Inventory) ListMeta() (object.ObjMetadataSet, error)

ListMeta returns the inventory entries as object.ObjMetadata objects.

func (*Inventory) ListObjects

func (inv *Inventory) ListObjects() ([]*unstructured.Unstructured, error)

ListObjects returns the inventory entries as unstructured.Unstructured objects.

func (*Inventory) SetSource

func (inv *Inventory) SetSource(url, revision string)

SetSource sets the source url and revision for this inventory.

func (*Inventory) VersionOf

func (inv *Inventory) VersionOf(objMetadata object.ObjMetadata) string

VersionOf returns the API version of the given object if found in this inventory.

type InventoryStorage added in v1.1.2

type InventoryStorage struct {
	Manager *ssa.ResourceManager
	Owner   ssa.Owner
}

InventoryStorage manages the Inventory ConfigMap storage.

func (*InventoryStorage) ApplyInventory added in v1.1.2

func (m *InventoryStorage) ApplyInventory(ctx context.Context, i *Inventory) error

ApplyInventory creates or updates the ConfigMap object for the given inventory.

func (*InventoryStorage) DeleteInventory added in v1.1.2

func (m *InventoryStorage) DeleteInventory(ctx context.Context, i *Inventory) error

DeleteInventory removes the ConfigMap for the given inventory name and namespace.

func (*InventoryStorage) GetInventory added in v1.1.2

func (m *InventoryStorage) GetInventory(ctx context.Context, i *Inventory) error

GetInventory retrieves the entries from the ConfigMap for the given inventory name and namespace.

func (*InventoryStorage) GetInventoryStaleObjects added in v1.1.2

func (m *InventoryStorage) GetInventoryStaleObjects(ctx context.Context, i *Inventory) ([]*unstructured.Unstructured, error)

GetInventoryStaleObjects returns the list of objects metadata subject to pruning.

Jump to

Keyboard shortcuts

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