diff --git a/pkg/engine/states/backend.go b/pkg/engine/states/backend.go index 10ef2b60..8c53faf1 100644 --- a/pkg/engine/states/backend.go +++ b/pkg/engine/states/backend.go @@ -1,6 +1,18 @@ package states -// TODO: We will refactor this file with StateStorage later +import "github.com/zclconf/go-cty/cty" + +// Backend represent a medium that Kusion will operate on. +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 +} var Backends = make(map[string]func() StateStorage) diff --git a/pkg/engine/states/state.go b/pkg/engine/states/state.go index 04784dd5..0f1eab5f 100644 --- a/pkg/engine/states/state.go +++ b/pkg/engine/states/state.go @@ -5,21 +5,11 @@ import ( "kusionstack.io/kusion/pkg/engine/models" - "github.com/zclconf/go-cty/cty" - "kusionstack.io/kusion/pkg/version" ) -// StateStorage represents the set of methods required for a State backend +// StateStorage represents the set of methods to manipulate State in a specified storage 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)