Skip to content

Commit 7b80adb

Browse files
committed
Split interfaces
1 parent 8191f19 commit 7b80adb

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

internal/command/workdir/backend_config_state.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import (
1414
"github.com/hashicorp/terraform/internal/plans"
1515
)
1616

17-
var _ ConfigState[BackendConfigState] = &BackendConfigState{}
17+
var _ ConfigState = &BackendConfigState{}
18+
var _ DeepCopier[BackendConfigState] = &BackendConfigState{}
1819
var _ Planner[plans.Backend] = &BackendConfigState{}
1920

2021
// BackendConfigState describes the physical storage format for the backend state

internal/command/workdir/config_state.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@ import (
99
)
1010

1111
// ConfigState describes a configuration block, and is used to make that config block stateful.
12-
type ConfigState[T any] interface {
12+
type ConfigState interface {
1313
Empty() bool
1414
Config(*configschema.Block) (cty.Value, error)
1515
SetConfig(cty.Value, *configschema.Block) error
16+
}
17+
18+
// DeepCopier implementations can return deep copies of themselves for use elsewhere
19+
// without mutating the original value.
20+
type DeepCopier[T any] interface {
1621
DeepCopy() *T
1722
}
1823

24+
// Planner implementations can return a representation of their data that's
25+
// appropriate for storing in a plan file.
1926
type Planner[T any] interface {
2027
Plan(*configschema.Block, string) (*T, error)
2128
}

internal/command/workdir/statestore_config_state.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import (
1515
ctyjson "github.com/zclconf/go-cty/cty/json"
1616
)
1717

18-
var _ ConfigState[StateStoreConfigState] = &StateStoreConfigState{}
18+
var _ ConfigState = &StateStoreConfigState{}
19+
var _ DeepCopier[StateStoreConfigState] = &StateStoreConfigState{}
1920
var _ Planner[plans.StateStore] = &StateStoreConfigState{}
2021

2122
// StateStoreConfigState describes the physical storage format for the state store

0 commit comments

Comments
 (0)