Documentation ¶
Overview ¶
Package states contains code for all storage medium supported by Kusion.
Index ¶
Constants ¶
const KusionState = "kusion_state.json"
Variables ¶
var Backends = make(map[string]func() StateStorage)
var ErrOSSNoExist = errors.New("oss: key not exist")
var ErrS3NoExist = errors.New("s3: key not exist")
Functions ¶
func AddToBackends ¶
func AddToBackends(name string, storage func() StateStorage)
Types ¶
type DBState ¶
func (*DBState) ConfigSchema ¶
func (*DBState) GetLatestState ¶
func (s *DBState) GetLatestState(q *StateQuery) (*State, error)
type FileSystemState ¶
type FileSystemState struct { // state Path is in the same dir where command line is invoked Path string }
func (*FileSystemState) Apply ¶
func (f *FileSystemState) Apply(state *State) error
func (*FileSystemState) ConfigSchema ¶
func (f *FileSystemState) ConfigSchema() cty.Type
func (*FileSystemState) Delete ¶
func (f *FileSystemState) Delete(id string) error
func (*FileSystemState) GetLatestState ¶
func (f *FileSystemState) GetLatestState(query *StateQuery) (*State, error)
type OssState ¶
type OssState struct {
// contains filtered or unexported fields
}
func NewOSSState ¶
func (*OssState) ConfigSchema ¶ added in v0.4.4
ConfigSchema returns a description of the expected configuration structure for the receiving backend.
func (*OssState) Configure ¶ added in v0.4.4
Configure uses the provided configuration to set configuration fields within the OssState backend.
func (*OssState) GetLatestState ¶
func (s *OssState) GetLatestState(query *StateQuery) (*State, error)
type S3State ¶
type S3State struct {
// contains filtered or unexported fields
}
func NewS3State ¶
func (*S3State) ConfigSchema ¶ added in v0.4.4
ConfigSchema returns a description of the expected configuration structure for the receiving backend.
func (*S3State) Configure ¶ added in v0.4.4
Configure uses the provided configuration to set configuration fields within the S3State backend.
func (*S3State) GetLatestState ¶
func (s *S3State) GetLatestState(query *StateQuery) (*State, error)
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.
type StateQuery ¶
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
func NewDBState ¶
func NewDBState() StateStorage
func NewFileSystemState ¶
func NewFileSystemState() StateStorage