Skip to content

Commit 080d643

Browse files
authored
refactor backend (#116)
1 parent de1a82a commit 080d643

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

pkg/engine/states/backend.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
package states
22

3-
// TODO: We will refactor this file with StateStorage later
3+
import "github.com/zclconf/go-cty/cty"
4+
5+
// Backend represent a medium that Kusion will operate on.
6+
type Backend interface {
7+
// ConfigSchema returns a set of attributes that is needed to config this backend
8+
ConfigSchema() cty.Type
9+
10+
// Configure will config this backend with provided configuration
11+
Configure(obj cty.Value) error
12+
13+
// StateStorage return a StateStorage to manage State
14+
StateStorage() StateStorage
15+
}
416

517
var Backends = make(map[string]func() StateStorage)
618

pkg/engine/states/state.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,11 @@ import (
55

66
"kusionstack.io/kusion/pkg/engine/models"
77

8-
"github.com/zclconf/go-cty/cty"
9-
108
"kusionstack.io/kusion/pkg/version"
119
)
1210

13-
// StateStorage represents the set of methods required for a State backend
11+
// StateStorage represents the set of methods to manipulate State in a specified storage
1412
type StateStorage interface {
15-
// ConfigSchema returns a description of the expected configuration
16-
// structure for the receiving backend.
17-
ConfigSchema() cty.Type
18-
19-
// Configure uses the provided configuration to set configuration fields
20-
// within the backend.
21-
Configure(obj cty.Value) error
22-
2313
// GetLatestState return nil if state not exists
2414
GetLatestState(query *StateQuery) (*State, error)
2515

0 commit comments

Comments
 (0)