states

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package states contains code for all storage medium supported by Kusion.

Index

Constants

This section is empty.

Variables

View Source
var Backends = make(map[string]func() StateStorage)

Functions

func AddToBackends

func AddToBackends(name string, storage func() StateStorage)

Types

type State

type State struct {
	// State ID
	ID int64 `json:"id"`
	// Tenant is designed for multi-tenant scenario
	Tenant string `json:"tenant,omitempty"`
	// Stack name
	Stack string `json:"stack"`
	// Project name
	Project string `json:"project"`
	// State version
	Version int `json:"version"`
	// KusionVersion represents the Kusion's version when this State is created
	KusionVersion string `json:"kusionVersion"`
	// Serial is an auto-increase number that represents how many times this State is modified
	Serial uint64 `json:"serial"`
	// Operator represents the person who triggered this operation
	Operator string `json:"operator,omitempty"`
	// Resources records all resources in this operation
	Resources models.Resources `json:"resources"`
	// CreatTime is the time State is created
	CreatTime time.Time `json:"creatTime"`
	// ModifiedTime is the time State is modified each time
	ModifiedTime time.Time `json:"modifiedTime,omitempty"`
}

State is a record of an operation's result. It is a mapping between resources in KCL and the actual infra resource and often used as a datasource for 3-way merge/diff in operations like Apply or Preview.

func NewState

func NewState() *State

type StateQuery

type StateQuery struct {
	Tenant  string `json:"tenant"`
	Stack   string `json:"stack"`
	Project string `json:"project"`
}

type StateStorage

type StateStorage interface {
	// ConfigSchema returns a description of the expected configuration
	// structure for the receiving backend.
	ConfigSchema() cty.Type
	// Configure uses the provided configuration to set configuration fields
	// within the backend.
	Configure(obj cty.Value) error
	// GetLatestState return nil if state not exists
	GetLatestState(query *StateQuery) (*State, error)
	// Apply means update this state if it already exists or create a new one
	Apply(state *State) error
	// Delete State by id
	Delete(id string) error
}

StateStorage represents the set of methods required for a State backend

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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