manifest

package
v0.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GroupResources = "resources"
)

Variables

View Source
var GroupSequence = []string{
	GroupResources,
}

GroupSequence defines the sequence of group to create.

Functions

func DeleteObjects

func DeleteObjects(sc *config.Config, group string, objs ObjectByScope) (*ObjectSet, *ObjectSet, error)

DeleteObjects send delete objects request.

func GetObjects

func GetObjects(sc *config.Config, group string, objs ObjectByScope, detectChange bool) (
	unchanged ObjectSet,
	notFound ObjectSet,
	changed ObjectSet,
	err error,
)

GetObjects send get objects request.

func WaitForDelete

func WaitForDelete(typ string, e EventItem, group, name string) bool

WaitForDelete waits for the object to be deleted.

func WaitForStatusReadyOrError

func WaitForStatusReadyOrError(_ string, e EventItem, group, name string) bool

WaitForStatusReadyOrError waits for the object to be ready or error.

func WatchObjects

func WatchObjects(
	ctx context.Context,
	sc *config.Config,
	set ObjectSet,
	waitConds map[string]WaitFor,
	finishedChan chan ObjectSet,
) (bool, error)

WatchObjects send watch objects request.

Types

type ApplyOperator

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

ApplyOperator is a type that represents an apply operator.

func (*ApplyOperator) Operate

func (o *ApplyOperator) Operate(set ObjectSet) (OperateResult, error)

Operate applies the provided ObjectSet.

func (*ApplyOperator) PrintResult

func (o *ApplyOperator) PrintResult(r OperateResult)

PrintResult prints the result of an operation.

type DeleteOperator

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

DeleteOperator is a type that represents an delete operator.

func (*DeleteOperator) Operate

func (o *DeleteOperator) Operate(set ObjectSet) (OperateResult, error)

Operate deletes the provided ObjectSet.

func (*DeleteOperator) PrintResult

func (o *DeleteOperator) PrintResult(r OperateResult)

PrintResult prints the result of an operation.

type Event

type Event struct {
	Type  string      `json:"type"`
	Items []EventItem `json:"items"`
}

type EventItem

type EventItem struct {
	ID     string        `json:"id"`
	Name   string        `json:"name"`
	Status status.Status `json:"status"`
}

type IDName

type IDName struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

IDName represents an object with an ID and a name.

type Loader

type Loader interface {
	LoadFromFiles(filePaths []string, recursive bool) (ObjectSet, error)
	LoadFromByte(b []byte) (ObjectSet, error)
}

Loader is an interface that defines methods for loading objects from various sources. Objects are loaded either from a list of file paths or from a byte slice.

func DefaultLoader

func DefaultLoader(sc *config.Config, validateParametersSet bool) Loader

DefaultLoader creates a Loader with default configurations.

type Object

type Object struct {
	ObjectScope
	IDName

	Group  string
	Value  map[string]any
	Status ObjectStatus
}

Object represents an object with a name, group, and value.

func (Object) Key

func (o Object) Key() string

Key returns the key of Object.

func (Object) MarshalJSON

func (o Object) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of Object.

type ObjectByGK

type ObjectByGK map[string]map[ObjectScope]ObjectList

ObjectByGK represents a map of group to a map of ObjectScope to a slice of Object.

type ObjectByScope

type ObjectByScope map[ObjectScope]ObjectList

ObjectByScope represents a map of ObjectScope to a slice of Object.

func (*ObjectByScope) All

func (s *ObjectByScope) All() ObjectList

All returns all objects in the ObjectByScope.

type ObjectList

type ObjectList []Object

ObjectList is the list of object.

func (ObjectList) IDNameMap

func (l ObjectList) IDNameMap() map[string]string

IDNameMap returns a map of ID to name.

func (ObjectList) Names

func (l ObjectList) Names() sets.Set[string]

type ObjectLoader

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

ObjectLoader is a type that represents an object loader.

func (*ObjectLoader) LoadFromByte

func (l *ObjectLoader) LoadFromByte(b []byte) (ObjectSet, error)

LoadFromByte parses the provided YAML byte slice `b` and returns an `ObjectSet` and an error.

func (*ObjectLoader) LoadFromFile

func (l *ObjectLoader) LoadFromFile(filePath string) (ObjectSet, error)

LoadFromFile reads the contents of the file at the given path and loads it as a YAML object set.

func (*ObjectLoader) LoadFromFiles

func (l *ObjectLoader) LoadFromFiles(filePaths []string, recursive bool) (ObjectSet, error)

LoadFromFiles loads object from file paths and a recursive flag indicating whether to search files recursively.

type ObjectScope

type ObjectScope struct {
	Project     string
	Environment string
}

ObjectScope represents the scope of an object within a project and environment.

func (*ObjectScope) Map

func (o *ObjectScope) Map() map[string]any

Map returns a map of ObjectScope.

func (*ObjectScope) ScopedName

func (o *ObjectScope) ScopedName(name string) string

ScopedName generate object scoped name.

type ObjectSet

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

ObjectSet represents a set of objects.

func BatchCreateObjects

func BatchCreateObjects(sc *config.Config, group string, objs ObjectByScope) (
	success, failed ObjectSet, err error,
)

BatchCreateObjects send batch create objects request.

func NewObjectSet

func NewObjectSet(objs ...Object) *ObjectSet

NewObjectSet returns a new ObjectSet.

func PatchObjects

func PatchObjects(sc *config.Config, group string, objs ObjectByScope) (success, failed ObjectSet, err error)

PatchObjects send patches objects request.

func (*ObjectSet) Add

func (s *ObjectSet) Add(objs ...Object) *ObjectSet

Add adds objects to the ObjectSet.

func (*ObjectSet) All

func (s *ObjectSet) All() []Object

All returns all objects in the ObjectSet.

func (*ObjectSet) ByGroup

func (s *ObjectSet) ByGroup(group string) ObjectByScope

ByGroup returns a map of ObjectScope to a slice of Object for the given group.

func (*ObjectSet) Len

func (s *ObjectSet) Len() int

Len returns the number of objects in the ObjectSet.

func (*ObjectSet) ObjectByGroup

func (s *ObjectSet) ObjectByGroup() ObjectByGK

ObjectByGroup returns a map of ObjectScope to a slice of Object for the given group.

func (*ObjectSet) Remove

func (s *ObjectSet) Remove(objs ...Object) *ObjectSet

Remove removes objects from the ObjectSet.

type ObjectStatus

type ObjectStatus uint

type ObjectWaiter

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

ObjectWaiter is a type that represents an object waiter.

func DeleteWaiter

func DeleteWaiter(sc *config.Config, timeoutSecond int) *ObjectWaiter

DeleteWaiter creates a Waiter wait for delete.

func (*ObjectWaiter) Wait

func (o *ObjectWaiter) Wait(ctx context.Context, objs ObjectSet, finished chan ObjectSet) (bool, error)

Wait waits for the object to finished.

type OperateResult

type OperateResult struct {
	Success   ObjectSet
	Failed    ObjectSet
	NotFound  ObjectSet
	UnChanged ObjectSet
}

OperateResult is a type that represents the result of an operation.

type Operator

type Operator interface {
	Operate(set ObjectSet) (r OperateResult, err error)
	PrintResult(r OperateResult)
}

Operator is an interface for applying and deleting objects.

func DefaultApplyOperator

func DefaultApplyOperator(sc *config.Config, wait bool) Operator

DefaultApplyOperator returns a apply Operator.

func DefaultDeleteOperator

func DefaultDeleteOperator(sc *config.Config, wait bool) Operator

DefaultDeleteOperator returns a delete Operator.

type Option

type Option struct {
	// Context flags.
	config.ScopeContext

	// File path or folder path.
	Filenames []string `json:"filenames,omitempty"`

	// Recursive apply.
	Recursive bool `json:"recursive,omitempty"`

	// Wait for the operation to complete.
	Wait bool `json:"wait,omitempty"`

	// Timeout in seconds for the wait operation.
	Timeout int `json:"timeout,omitempty"`

	// ValidateParameterAllSet is a flag that indicates whether to validate all parameters set.
	ValidateParametersSet bool `json:"validateParametersSet,omitempty"`
}

Option is a type that represents the options for the manifest apply.

func (*Option) AddFlags

func (f *Option) AddFlags(cmd *cobra.Command)

type WaitFor

type WaitFor = func(typ string, e EventItem, group, name string) bool

WaitFor is a function that defines the condition for waiting for the object.

type Waiter

type Waiter interface {
	Wait(ctx context.Context, set ObjectSet, finished chan ObjectSet) (bool, error)
}

Waiter is an interface that defines methods for waiting for the status of objects.

func StatusWaiter

func StatusWaiter(sc *config.Config, timeoutSecond int) Waiter

StatusWaiter creates a Waiter wait for status ready or error.

Jump to

Keyboard shortcuts

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