Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor backend #116

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pkg/engine/states/backend.go
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
12 changes: 1 addition & 11 deletions pkg/engine/states/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down