Skip to content

Commit

Permalink
refactor backend (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
SparkYuan committed Aug 10, 2022
1 parent de1a82a commit 080d643
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
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

0 comments on commit 080d643

Please sign in to comment.