manifest

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GroupResources    = "resources"
	GroupResourceRuns = "resourceruns"
)
View Source
const (
	FieldResourceRunID = "resourceRunID"
)

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 GetResourceRun added in v0.6.0

func GetResourceRun(sc *config.Config, obj Object, getOpt *api.Operation, runID string) (*model.ResourceRunOutput, error)

GetResourceRun send get resource run request.

func ListResourceRuns added in v0.6.0

func ListResourceRuns(sc *config.Config, obj Object, listOpt *api.Operation, st string) (*collectionGetResourceRun, error)

ListResourceRuns send list resource runs 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 ApplyOption added in v0.6.0

type ApplyOption struct {
	CommonOption

	// ChangeComment.
	ChangeComment string `json:"changeComment,omitempty"`
}

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

func (*ApplyOption) AddFlags added in v0.6.0

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

type CommonOption added in v0.6.0

type CommonOption 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"`
}

CommonOption is a type that represents the options for the manifest operation.

func (*CommonOption) AddFlags added in v0.6.0

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

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, runLabels map[string]string) 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) GetValue added in v0.6.0

func (o Object) GetValue(key string) any

GetValue gets the value of object's field.

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.

func (Object) RunLabelQuery added in v0.6.0

func (o Object) RunLabelQuery() []string

RunLabelQuery returns the query of runLabels.

func (Object) SetValue added in v0.6.0

func (o Object) SetValue(key string, val any)

SetValue sets the value of object's field.

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 ApplyResourceRuns added in v0.6.0

func ApplyResourceRuns(sc *config.Config, objs ObjectByScope) (success ObjectSet, err error)

ApplyResourceRuns send preview apply request for the object's last planned run.

func BatchCreateObjects

func BatchCreateObjects(sc *config.Config, group string, objs ObjectByScope, ebps extraBodyParams) (
	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, ebps extraBodyParams) (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, comment string) Operator

DefaultApplyOperator returns an apply Operator.

func DefaultDeleteOperator

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

DefaultDeleteOperator returns a delete Operator.

func DefaultPreviewApplyOperator added in v0.6.0

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

DefaultPreviewApplyOperator returns preview apply Operator.

func DefaultPreviewOperator added in v0.6.0

func DefaultPreviewOperator(sc *config.Config, wait bool, comment string, runLabels map[string]string) Operator

DefaultPreviewOperator returns preview Operator.

type PreviewApplyOperator added in v0.6.0

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

PreviewApplyOperator is a type that represents preview apply operator.

func (*PreviewApplyOperator) Operate added in v0.6.0

Operate apply previews of the provided ObjectSet.

func (*PreviewApplyOperator) PrintResult added in v0.6.0

func (o *PreviewApplyOperator) PrintResult(r OperateResult)

type PreviewApplyWaiter added in v0.6.0

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

PreviewApplyWaiter is a type that represents preview apply waiter.

func DefaultPreviewApplyWaiter added in v0.6.0

func DefaultPreviewApplyWaiter(sc *config.Config, timeoutSecond int) *PreviewApplyWaiter

DefaultPreviewApplyWaiter wait for preview apply finished.

func (*PreviewApplyWaiter) Wait added in v0.6.0

func (o *PreviewApplyWaiter) Wait(ctx context.Context, _ ObjectSet, setChan chan ObjectSet) (bool, error)

Wait waits for the preview applied and print the error.

type PreviewOperator added in v0.6.0

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

PreviewOperator is a type that represents preview operator.

func (*PreviewOperator) Operate added in v0.6.0

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

Operate generate preview changes of the provided ObjectSet.

func (*PreviewOperator) PrintResult added in v0.6.0

func (o *PreviewOperator) PrintResult(r OperateResult)

type PreviewOption added in v0.6.0

type PreviewOption struct {
	CommonOption

	// Apply.
	Apply bool `json:"apply,omitempty"`
	// ChangeComment.
	ChangeComment string `json:"changeComment,omitempty"`
	// RunLabels.
	RunLabels map[string]string `json:"runLabels,omitempty"`
}

PreviewOption is a type that represents the options for the manifest preview.

func (*PreviewOption) AddFlags added in v0.6.0

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

type PreviewWaiter added in v0.6.0

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

PreviewWaiter is a type that represents preview object waiter.

func DefaultPreviewWaiter added in v0.6.0

func DefaultPreviewWaiter(sc *config.Config, timeoutSecond int) *PreviewWaiter

DefaultPreviewWaiter wait for preview planned.

func (*PreviewWaiter) Wait added in v0.6.0

func (o *PreviewWaiter) Wait(ctx context.Context, set ObjectSet, _ chan ObjectSet) (bool, error)

Wait waits for the preview planned and print the error.

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