states

package
v0.6.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 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 Backend added in v0.6.0

type Backend interface {
	// ConfigSchema returns a set of attributes that is needed to config this backend
	ConfigSchema() cty.Type

	// Configure will config this backend with provided configuration
	Configure(obj cty.Value) error

	// StateStorage return a StateStorage to manage State
	StateStorage() StateStorage
}

Backend represent a medium that Kusion will operate on.

type State

type State struct {
	// State ID
	ID int64 `json:"id" yaml:"id"`

	// Tenant is designed for multi-tenant scenario
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty"`

	// Project name
	Project string `json:"project" yaml:"project"`

	// Stack name
	Stack string `json:"stack" yaml:"stack"`

	// Cluster is a logical concept to separate states in one stack.
	Cluster string `json:"cluster,omitempty" yaml:"cluster,omitempty"`

	// State version
	Version int `json:"version" yaml:"version"`

	// KusionVersion represents the Kusion's version when this State is created
	KusionVersion string `json:"kusionVersion" yaml:"kusionVersion"`

	// Serial is an auto-increase number that represents how many times this State is modified
	Serial uint64 `json:"serial" yaml:"serial"`

	// Operator represents the person who triggered this operation
	Operator string `json:"operator,omitempty" yaml:"operator,omitempty"`

	// Resources records all resources in this operation
	Resources models.Resources `json:"resources" yaml:"resources"`

	// CreateTime is the time State is created
	CreateTime time.Time `json:"createTime" yaml:"createTime"`

	// ModifiedTime is the time State is modified each time
	ModifiedTime time.Time `json:"modifiedTime,omitempty" yaml:"modifiedTime"`
}

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 name
	Tenant string `json:"tenant"`

	// Stack name
	Stack string `json:"stack"`

	// Project name
	Project string `json:"project"`

	// Cluster name
	Cluster string `json:"cluster,omitempty"`
}

type StateStorage

type StateStorage interface {
	// 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 to manipulate State in a specified storage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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