Rename internal/legacy/terraform to internal/legacy/opentf

This commit is contained in:
RLRabinowitz 2023-08-27 15:56:06 +03:00
parent 816c801fb2
commit 19239936a4
73 changed files with 1558 additions and 1558 deletions

View File

@ -5,7 +5,7 @@ package cloud
import ( import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs"
legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
// Most of the logic for migrating into and out of "cloud mode" actually lives // Most of the logic for migrating into and out of "cloud mode" actually lives

View File

@ -7,7 +7,7 @@ import (
"testing" "testing"
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs"
legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
func TestDetectConfigChangeType(t *testing.T) { func TestDetectConfigChangeType(t *testing.T) {

View File

@ -15,7 +15,7 @@ import (
"time" "time"
multierror "github.com/hashicorp/go-multierror" multierror "github.com/hashicorp/go-multierror"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statemgr" "github.com/placeholderplaceholderplaceholder/opentf/internal/states/statemgr"
) )
@ -42,13 +42,13 @@ type LocalState struct {
// hurt to remove file we never wrote to. // hurt to remove file we never wrote to.
created bool created bool
state *terraform.State state *opentf.State
readState *terraform.State readState *opentf.State
written bool written bool
} }
// SetState will force a specific state in-memory for this local state. // SetState will force a specific state in-memory for this local state.
func (s *LocalState) SetState(state *terraform.State) { func (s *LocalState) SetState(state *opentf.State) {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
@ -57,7 +57,7 @@ func (s *LocalState) SetState(state *terraform.State) {
} }
// StateReader impl. // StateReader impl.
func (s *LocalState) State() *terraform.State { func (s *LocalState) State() *opentf.State {
return s.state.DeepCopy() return s.state.DeepCopy()
} }
@ -67,7 +67,7 @@ func (s *LocalState) State() *terraform.State {
// the original. // the original.
// //
// StateWriter impl. // StateWriter impl.
func (s *LocalState) WriteState(state *terraform.State) error { func (s *LocalState) WriteState(state *opentf.State) error {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
@ -103,7 +103,7 @@ func (s *LocalState) WriteState(state *terraform.State) error {
s.state.Serial++ s.state.Serial++
} }
if err := terraform.WriteState(s.state, s.stateFileOut); err != nil { if err := opentf.WriteState(s.state, s.stateFileOut); err != nil {
return err return err
} }
@ -164,9 +164,9 @@ func (s *LocalState) RefreshState() error {
reader = s.stateFileOut reader = s.stateFileOut
} }
state, err := terraform.ReadState(reader) state, err := opentf.ReadState(reader)
// if there's no state we just assign the nil return value // if there's no state we just assign the nil return value
if err != nil && err != terraform.ErrNoState { if err != nil && err != opentf.ErrNoState {
return err return err
} }

View File

@ -40,7 +40,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/depsfile" "github.com/placeholderplaceholderplaceholder/opentf/internal/depsfile"
"github.com/placeholderplaceholderplaceholder/opentf/internal/getproviders" "github.com/placeholderplaceholderplaceholder/opentf/internal/getproviders"
"github.com/placeholderplaceholderplaceholder/opentf/internal/initwd" "github.com/placeholderplaceholderplaceholder/opentf/internal/initwd"
legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
_ "github.com/placeholderplaceholderplaceholder/opentf/internal/logging" _ "github.com/placeholderplaceholderplaceholder/opentf/internal/logging"
"github.com/placeholderplaceholderplaceholder/opentf/internal/plans" "github.com/placeholderplaceholderplaceholder/opentf/internal/plans"
"github.com/placeholderplaceholderplaceholder/opentf/internal/plans/planfile" "github.com/placeholderplaceholderplaceholder/opentf/internal/plans/planfile"

View File

@ -33,7 +33,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs"
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configload" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configload"
"github.com/placeholderplaceholderplaceholder/opentf/internal/getproviders" "github.com/placeholderplaceholderplaceholder/opentf/internal/getproviders"
legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
"github.com/placeholderplaceholderplaceholder/opentf/internal/providers" "github.com/placeholderplaceholderplaceholder/opentf/internal/providers"
"github.com/placeholderplaceholderplaceholder/opentf/internal/provisioners" "github.com/placeholderplaceholderplaceholder/opentf/internal/provisioners"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states" "github.com/placeholderplaceholderplaceholder/opentf/internal/states"

View File

@ -35,7 +35,7 @@ import (
backendInit "github.com/placeholderplaceholderplaceholder/opentf/internal/backend/init" backendInit "github.com/placeholderplaceholderplaceholder/opentf/internal/backend/init"
backendLocal "github.com/placeholderplaceholderplaceholder/opentf/internal/backend/local" backendLocal "github.com/placeholderplaceholderplaceholder/opentf/internal/backend/local"
legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
// BackendOpts are the options used to initialize a backend.Backend. // BackendOpts are the options used to initialize a backend.Backend.

View File

@ -10,7 +10,7 @@ import (
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
"github.com/placeholderplaceholderplaceholder/opentf/internal/backend/remote-state/inmem" "github.com/placeholderplaceholderplaceholder/opentf/internal/backend/remote-state/inmem"
legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
// Since we can't unlock a local state file, just test that calling unlock // Since we can't unlock a local state file, just test that calling unlock

View File

@ -14,7 +14,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/states" "github.com/placeholderplaceholderplaceholder/opentf/internal/states"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/terraform"
legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
func TestCountHook_impl(t *testing.T) { func TestCountHook_impl(t *testing.T) {

View File

@ -18,7 +18,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/states" "github.com/placeholderplaceholderplaceholder/opentf/internal/states"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statemgr" "github.com/placeholderplaceholderplaceholder/opentf/internal/states/statemgr"
legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" legacy "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
func TestWorkspace_createAndChange(t *testing.T) { func TestWorkspace_createAndChange(t *testing.T) {

View File

@ -32,7 +32,7 @@ const UnknownVariableValue = "74D93920-ED26-11E3-AC10-0800200C9A66"
// function will panic or produce incorrect results. // function will panic or produce incorrect results.
// //
// This is primarily useful for the final transition from new-style values to // This is primarily useful for the final transition from new-style values to
// terraform.ResourceConfig before calling to a legacy provider, since // opentf.ResourceConfig before calling to a legacy provider, since
// helper/schema (the old provider SDK) is particularly sensitive to these // helper/schema (the old provider SDK) is particularly sensitive to these
// subtle differences within its validation code. // subtle differences within its validation code.
func ConfigValueFromHCL2Block(v cty.Value, schema *configschema.Block) map[string]interface{} { func ConfigValueFromHCL2Block(v cty.Value, schema *configschema.Block) map[string]interface{} {

View File

@ -12,7 +12,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema"
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/hcl2shim" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/hcl2shim"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
ctyconvert "github.com/zclconf/go-cty/cty/convert" ctyconvert "github.com/zclconf/go-cty/cty/convert"
) )
@ -181,16 +181,16 @@ func (b *Backend) Configure(obj cty.Value) tfdiags.Diagnostics {
} }
// shimConfig turns a new-style cty.Value configuration (which must be of // shimConfig turns a new-style cty.Value configuration (which must be of
// an object type) into a minimal old-style *terraform.ResourceConfig object // an object type) into a minimal old-style *opentf.ResourceConfig object
// that should be populated enough to appease the not-yet-updated functionality // that should be populated enough to appease the not-yet-updated functionality
// in this package. This should be removed once everything is updated. // in this package. This should be removed once everything is updated.
func (b *Backend) shimConfig(obj cty.Value) *terraform.ResourceConfig { func (b *Backend) shimConfig(obj cty.Value) *opentf.ResourceConfig {
shimMap, ok := hcl2shim.ConfigValueFromHCL2(obj).(map[string]interface{}) shimMap, ok := hcl2shim.ConfigValueFromHCL2(obj).(map[string]interface{})
if !ok { if !ok {
// If the configVal was nil, we still want a non-nil map here. // If the configVal was nil, we still want a non-nil map here.
shimMap = map[string]interface{}{} shimMap = map[string]interface{}{}
} }
return &terraform.ResourceConfig{ return &opentf.ResourceConfig{
Config: shimMap, Config: shimMap,
Raw: shimMap, Raw: shimMap,
} }

View File

@ -11,7 +11,7 @@ import (
"sync" "sync"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
// ConfigFieldReader reads fields out of an untyped map[string]string to the // ConfigFieldReader reads fields out of an untyped map[string]string to the
@ -19,7 +19,7 @@ import (
// field readers do not need default handling because they source fully // field readers do not need default handling because they source fully
// populated data structures.) // populated data structures.)
type ConfigFieldReader struct { type ConfigFieldReader struct {
Config *terraform.ResourceConfig Config *opentf.ResourceConfig
Schema map[string]*Schema Schema map[string]*Schema
indexMaps map[string]map[string]int indexMaps map[string]map[string]int

View File

@ -11,7 +11,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/hcl2shim" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/hcl2shim"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/helper/hashcode" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/helper/hashcode"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
func TestConfigFieldReader_impl(t *testing.T) { func TestConfigFieldReader_impl(t *testing.T) {
@ -80,7 +80,7 @@ func TestConfigFieldReader_custom(t *testing.T) {
cases := map[string]struct { cases := map[string]struct {
Addr []string Addr []string
Result FieldReadResult Result FieldReadResult
Config *terraform.ResourceConfig Config *opentf.ResourceConfig
Err bool Err bool
}{ }{
"basic": { "basic": {
@ -146,7 +146,7 @@ func TestConfigFieldReader_DefaultHandling(t *testing.T) {
cases := map[string]struct { cases := map[string]struct {
Addr []string Addr []string
Result FieldReadResult Result FieldReadResult
Config *terraform.ResourceConfig Config *opentf.ResourceConfig
Err bool Err bool
}{ }{
"gets default value when no config set": { "gets default value when no config set": {
@ -236,7 +236,7 @@ func TestConfigFieldReader_ComputedMap(t *testing.T) {
Name string Name string
Addr []string Addr []string
Result FieldReadResult Result FieldReadResult
Config *terraform.ResourceConfig Config *opentf.ResourceConfig
Err bool Err bool
}{ }{
{ {
@ -403,7 +403,7 @@ func TestConfigFieldReader_ComputedSet(t *testing.T) {
cases := map[string]struct { cases := map[string]struct {
Addr []string Addr []string
Result FieldReadResult Result FieldReadResult
Config *terraform.ResourceConfig Config *opentf.ResourceConfig
Err bool Err bool
}{ }{
"set, normal": { "set, normal": {
@ -489,7 +489,7 @@ func TestConfigFieldReader_computedComplexSet(t *testing.T) {
cases := map[string]struct { cases := map[string]struct {
Addr []string Addr []string
Result FieldReadResult Result FieldReadResult
Config *terraform.ResourceConfig Config *opentf.ResourceConfig
Err bool Err bool
}{ }{
"set, normal": { "set, normal": {
@ -538,6 +538,6 @@ func TestConfigFieldReader_computedComplexSet(t *testing.T) {
} }
} }
func testConfig(t *testing.T, raw map[string]interface{}) *terraform.ResourceConfig { func testConfig(t *testing.T, raw map[string]interface{}) *opentf.ResourceConfig {
return terraform.NewResourceConfigRaw(raw) return opentf.NewResourceConfigRaw(raw)
} }

View File

@ -8,7 +8,7 @@ import (
"strings" "strings"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
// DiffFieldReader reads fields out of a diff structures. // DiffFieldReader reads fields out of a diff structures.
@ -29,7 +29,7 @@ import (
// It cannot be determined whether a retrieved value is composed of // It cannot be determined whether a retrieved value is composed of
// diff elements. // diff elements.
type DiffFieldReader struct { type DiffFieldReader struct {
Diff *terraform.InstanceDiff Diff *opentf.InstanceDiff
Source FieldReader Source FieldReader
Schema map[string]*Schema Schema map[string]*Schema

View File

@ -7,7 +7,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
func TestDiffFieldReader_impl(t *testing.T) { func TestDiffFieldReader_impl(t *testing.T) {
@ -61,14 +61,14 @@ func TestDiffFieldReader_NestedSetUpdate(t *testing.T) {
r := &DiffFieldReader{ r := &DiffFieldReader{
Schema: schema, Schema: schema,
Diff: &terraform.InstanceDiff{ Diff: &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"list_of_sets_1.0.nested_set.1.val": &terraform.ResourceAttrDiff{ "list_of_sets_1.0.nested_set.1.val": &opentf.ResourceAttrDiff{
Old: "1", Old: "1",
New: "0", New: "0",
NewRemoved: true, NewRemoved: true,
}, },
"list_of_sets_1.0.nested_set.2.val": &terraform.ResourceAttrDiff{ "list_of_sets_1.0.nested_set.2.val": &opentf.ResourceAttrDiff{
New: "2", New: "2",
}, },
}, },
@ -121,13 +121,13 @@ func TestDiffFieldReader_MapHandling(t *testing.T) {
} }
r := &DiffFieldReader{ r := &DiffFieldReader{
Schema: schema, Schema: schema,
Diff: &terraform.InstanceDiff{ Diff: &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"tags.%": &terraform.ResourceAttrDiff{ "tags.%": &opentf.ResourceAttrDiff{
Old: "1", Old: "1",
New: "2", New: "2",
}, },
"tags.baz": &terraform.ResourceAttrDiff{ "tags.baz": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "qux", New: "qux",
}, },
@ -217,28 +217,28 @@ func TestDiffFieldReader_extra(t *testing.T) {
r := &DiffFieldReader{ r := &DiffFieldReader{
Schema: schema, Schema: schema,
Diff: &terraform.InstanceDiff{ Diff: &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"stringComputed": &terraform.ResourceAttrDiff{ "stringComputed": &opentf.ResourceAttrDiff{
Old: "foo", Old: "foo",
New: "bar", New: "bar",
NewComputed: true, NewComputed: true,
}, },
"listMap.0.bar": &terraform.ResourceAttrDiff{ "listMap.0.bar": &opentf.ResourceAttrDiff{
NewRemoved: true, NewRemoved: true,
}, },
"mapRemove.bar": &terraform.ResourceAttrDiff{ "mapRemove.bar": &opentf.ResourceAttrDiff{
NewRemoved: true, NewRemoved: true,
}, },
"setChange.10.value": &terraform.ResourceAttrDiff{ "setChange.10.value": &opentf.ResourceAttrDiff{
Old: "50", Old: "50",
New: "80", New: "80",
}, },
"setEmpty.#": &terraform.ResourceAttrDiff{ "setEmpty.#": &opentf.ResourceAttrDiff{
Old: "2", Old: "2",
New: "0", New: "0",
}, },
@ -355,158 +355,158 @@ func TestDiffFieldReader(t *testing.T) {
testFieldReader(t, func(s map[string]*Schema) FieldReader { testFieldReader(t, func(s map[string]*Schema) FieldReader {
return &DiffFieldReader{ return &DiffFieldReader{
Schema: s, Schema: s,
Diff: &terraform.InstanceDiff{ Diff: &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"bool": &terraform.ResourceAttrDiff{ "bool": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "true", New: "true",
}, },
"int": &terraform.ResourceAttrDiff{ "int": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "42", New: "42",
}, },
"float": &terraform.ResourceAttrDiff{ "float": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "3.1415", New: "3.1415",
}, },
"string": &terraform.ResourceAttrDiff{ "string": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "string", New: "string",
}, },
"stringComputed": &terraform.ResourceAttrDiff{ "stringComputed": &opentf.ResourceAttrDiff{
Old: "foo", Old: "foo",
New: "bar", New: "bar",
NewComputed: true, NewComputed: true,
}, },
"list.#": &terraform.ResourceAttrDiff{ "list.#": &opentf.ResourceAttrDiff{
Old: "0", Old: "0",
New: "2", New: "2",
}, },
"list.0": &terraform.ResourceAttrDiff{ "list.0": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
}, },
"list.1": &terraform.ResourceAttrDiff{ "list.1": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "bar", New: "bar",
}, },
"listInt.#": &terraform.ResourceAttrDiff{ "listInt.#": &opentf.ResourceAttrDiff{
Old: "0", Old: "0",
New: "2", New: "2",
}, },
"listInt.0": &terraform.ResourceAttrDiff{ "listInt.0": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "21", New: "21",
}, },
"listInt.1": &terraform.ResourceAttrDiff{ "listInt.1": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "42", New: "42",
}, },
"map.foo": &terraform.ResourceAttrDiff{ "map.foo": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "bar", New: "bar",
}, },
"map.bar": &terraform.ResourceAttrDiff{ "map.bar": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "baz", New: "baz",
}, },
"mapInt.%": &terraform.ResourceAttrDiff{ "mapInt.%": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "2", New: "2",
}, },
"mapInt.one": &terraform.ResourceAttrDiff{ "mapInt.one": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "1", New: "1",
}, },
"mapInt.two": &terraform.ResourceAttrDiff{ "mapInt.two": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "2", New: "2",
}, },
"mapIntNestedSchema.%": &terraform.ResourceAttrDiff{ "mapIntNestedSchema.%": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "2", New: "2",
}, },
"mapIntNestedSchema.one": &terraform.ResourceAttrDiff{ "mapIntNestedSchema.one": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "1", New: "1",
}, },
"mapIntNestedSchema.two": &terraform.ResourceAttrDiff{ "mapIntNestedSchema.two": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "2", New: "2",
}, },
"mapFloat.%": &terraform.ResourceAttrDiff{ "mapFloat.%": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "1", New: "1",
}, },
"mapFloat.oneDotTwo": &terraform.ResourceAttrDiff{ "mapFloat.oneDotTwo": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "1.2", New: "1.2",
}, },
"mapBool.%": &terraform.ResourceAttrDiff{ "mapBool.%": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "2", New: "2",
}, },
"mapBool.True": &terraform.ResourceAttrDiff{ "mapBool.True": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "true", New: "true",
}, },
"mapBool.False": &terraform.ResourceAttrDiff{ "mapBool.False": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "false", New: "false",
}, },
"set.#": &terraform.ResourceAttrDiff{ "set.#": &opentf.ResourceAttrDiff{
Old: "0", Old: "0",
New: "2", New: "2",
}, },
"set.10": &terraform.ResourceAttrDiff{ "set.10": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "10", New: "10",
}, },
"set.50": &terraform.ResourceAttrDiff{ "set.50": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "50", New: "50",
}, },
"setDeep.#": &terraform.ResourceAttrDiff{ "setDeep.#": &opentf.ResourceAttrDiff{
Old: "0", Old: "0",
New: "2", New: "2",
}, },
"setDeep.10.index": &terraform.ResourceAttrDiff{ "setDeep.10.index": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "10", New: "10",
}, },
"setDeep.10.value": &terraform.ResourceAttrDiff{ "setDeep.10.value": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
}, },
"setDeep.50.index": &terraform.ResourceAttrDiff{ "setDeep.50.index": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "50", New: "50",
}, },
"setDeep.50.value": &terraform.ResourceAttrDiff{ "setDeep.50.value": &opentf.ResourceAttrDiff{
Old: "", Old: "",
New: "bar", New: "bar",
}, },

View File

@ -8,7 +8,7 @@ import (
"strconv" "strconv"
"testing" "testing"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
func TestMultiLevelFieldReaderReadFieldExact(t *testing.T) { func TestMultiLevelFieldReaderReadFieldExact(t *testing.T) {
@ -103,9 +103,9 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) {
}), }),
}, },
Diff: &terraform.InstanceDiff{ Diff: &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"availability_zone": &terraform.ResourceAttrDiff{ "availability_zone": &opentf.ResourceAttrDiff{
Old: "foo", Old: "foo",
New: "bar", New: "bar",
RequiresNew: true, RequiresNew: true,
@ -150,9 +150,9 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) {
}), }),
}, },
Diff: &terraform.InstanceDiff{ Diff: &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"availability_zone": &terraform.ResourceAttrDiff{ "availability_zone": &opentf.ResourceAttrDiff{
Old: "foo", Old: "foo",
New: "bar", New: "bar",
NewComputed: true, NewComputed: true,
@ -197,9 +197,9 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) {
}), }),
}, },
Diff: &terraform.InstanceDiff{ Diff: &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"config_vars.0.bar": &terraform.ResourceAttrDiff{ "config_vars.0.bar": &opentf.ResourceAttrDiff{
NewRemoved: true, NewRemoved: true,
}, },
}, },

View File

@ -12,7 +12,7 @@ import (
multierror "github.com/hashicorp/go-multierror" multierror "github.com/hashicorp/go-multierror"
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
var ReservedProviderFields = []string{ var ReservedProviderFields = []string{
@ -180,7 +180,7 @@ func (p *Provider) stopInit() {
p.stopCtx, p.stopCtxCancel = context.WithCancel(context.Background()) p.stopCtx, p.stopCtxCancel = context.WithCancel(context.Background())
} }
// Stop implementation of terraform.ResourceProvider interface. // Stop implementation of opentf.ResourceProvider interface.
func (p *Provider) Stop() error { func (p *Provider) Stop() error {
p.stopOnce.Do(p.stopInit) p.stopOnce.Do(p.stopInit)
@ -203,8 +203,8 @@ func (p *Provider) TestReset() error {
return nil return nil
} }
// GetSchema implementation of terraform.ResourceProvider interface // GetSchema implementation of opentf.ResourceProvider interface
func (p *Provider) GetSchema(req *terraform.ProviderSchemaRequest) (*terraform.ProviderSchema, error) { func (p *Provider) GetSchema(req *opentf.ProviderSchemaRequest) (*opentf.ProviderSchema, error) {
resourceTypes := map[string]*configschema.Block{} resourceTypes := map[string]*configschema.Block{}
dataSources := map[string]*configschema.Block{} dataSources := map[string]*configschema.Block{}
@ -219,22 +219,22 @@ func (p *Provider) GetSchema(req *terraform.ProviderSchemaRequest) (*terraform.P
} }
} }
return &terraform.ProviderSchema{ return &opentf.ProviderSchema{
Provider: schemaMap(p.Schema).CoreConfigSchema(), Provider: schemaMap(p.Schema).CoreConfigSchema(),
ResourceTypes: resourceTypes, ResourceTypes: resourceTypes,
DataSources: dataSources, DataSources: dataSources,
}, nil }, nil
} }
// Input implementation of terraform.ResourceProvider interface. // Input implementation of opentf.ResourceProvider interface.
func (p *Provider) Input( func (p *Provider) Input(
input terraform.UIInput, input opentf.UIInput,
c *terraform.ResourceConfig) (*terraform.ResourceConfig, error) { c *opentf.ResourceConfig) (*opentf.ResourceConfig, error) {
return schemaMap(p.Schema).Input(input, c) return schemaMap(p.Schema).Input(input, c)
} }
// Validate implementation of terraform.ResourceProvider interface. // Validate implementation of opentf.ResourceProvider interface.
func (p *Provider) Validate(c *terraform.ResourceConfig) ([]string, []error) { func (p *Provider) Validate(c *opentf.ResourceConfig) ([]string, []error) {
if err := p.InternalValidate(); err != nil { if err := p.InternalValidate(); err != nil {
return nil, []error{fmt.Errorf( return nil, []error{fmt.Errorf(
"Internal validation of the provider failed! This is always a bug\n"+ "Internal validation of the provider failed! This is always a bug\n"+
@ -245,9 +245,9 @@ func (p *Provider) Validate(c *terraform.ResourceConfig) ([]string, []error) {
return schemaMap(p.Schema).Validate(c) return schemaMap(p.Schema).Validate(c)
} }
// ValidateResource implementation of terraform.ResourceProvider interface. // ValidateResource implementation of opentf.ResourceProvider interface.
func (p *Provider) ValidateResource( func (p *Provider) ValidateResource(
t string, c *terraform.ResourceConfig) ([]string, []error) { t string, c *opentf.ResourceConfig) ([]string, []error) {
r, ok := p.ResourcesMap[t] r, ok := p.ResourcesMap[t]
if !ok { if !ok {
return nil, []error{fmt.Errorf( return nil, []error{fmt.Errorf(
@ -257,8 +257,8 @@ func (p *Provider) ValidateResource(
return r.Validate(c) return r.Validate(c)
} }
// Configure implementation of terraform.ResourceProvider interface. // Configure implementation of opentf.ResourceProvider interface.
func (p *Provider) Configure(c *terraform.ResourceConfig) error { func (p *Provider) Configure(c *opentf.ResourceConfig) error {
// No configuration // No configuration
if p.ConfigureFunc == nil { if p.ConfigureFunc == nil {
return nil return nil
@ -287,11 +287,11 @@ func (p *Provider) Configure(c *terraform.ResourceConfig) error {
return nil return nil
} }
// Apply implementation of terraform.ResourceProvider interface. // Apply implementation of opentf.ResourceProvider interface.
func (p *Provider) Apply( func (p *Provider) Apply(
info *terraform.InstanceInfo, info *opentf.InstanceInfo,
s *terraform.InstanceState, s *opentf.InstanceState,
d *terraform.InstanceDiff) (*terraform.InstanceState, error) { d *opentf.InstanceDiff) (*opentf.InstanceState, error) {
r, ok := p.ResourcesMap[info.Type] r, ok := p.ResourcesMap[info.Type]
if !ok { if !ok {
return nil, fmt.Errorf("unknown resource type: %s", info.Type) return nil, fmt.Errorf("unknown resource type: %s", info.Type)
@ -300,11 +300,11 @@ func (p *Provider) Apply(
return r.Apply(s, d, p.meta) return r.Apply(s, d, p.meta)
} }
// Diff implementation of terraform.ResourceProvider interface. // Diff implementation of opentf.ResourceProvider interface.
func (p *Provider) Diff( func (p *Provider) Diff(
info *terraform.InstanceInfo, info *opentf.InstanceInfo,
s *terraform.InstanceState, s *opentf.InstanceState,
c *terraform.ResourceConfig) (*terraform.InstanceDiff, error) { c *opentf.ResourceConfig) (*opentf.InstanceDiff, error) {
r, ok := p.ResourcesMap[info.Type] r, ok := p.ResourcesMap[info.Type]
if !ok { if !ok {
return nil, fmt.Errorf("unknown resource type: %s", info.Type) return nil, fmt.Errorf("unknown resource type: %s", info.Type)
@ -316,9 +316,9 @@ func (p *Provider) Diff(
// SimpleDiff is used by the new protocol wrappers to get a diff that doesn't // SimpleDiff is used by the new protocol wrappers to get a diff that doesn't
// attempt to calculate ignore_changes. // attempt to calculate ignore_changes.
func (p *Provider) SimpleDiff( func (p *Provider) SimpleDiff(
info *terraform.InstanceInfo, info *opentf.InstanceInfo,
s *terraform.InstanceState, s *opentf.InstanceState,
c *terraform.ResourceConfig) (*terraform.InstanceDiff, error) { c *opentf.ResourceConfig) (*opentf.InstanceDiff, error) {
r, ok := p.ResourcesMap[info.Type] r, ok := p.ResourcesMap[info.Type]
if !ok { if !ok {
return nil, fmt.Errorf("unknown resource type: %s", info.Type) return nil, fmt.Errorf("unknown resource type: %s", info.Type)
@ -327,10 +327,10 @@ func (p *Provider) SimpleDiff(
return r.simpleDiff(s, c, p.meta) return r.simpleDiff(s, c, p.meta)
} }
// Refresh implementation of terraform.ResourceProvider interface. // Refresh implementation of opentf.ResourceProvider interface.
func (p *Provider) Refresh( func (p *Provider) Refresh(
info *terraform.InstanceInfo, info *opentf.InstanceInfo,
s *terraform.InstanceState) (*terraform.InstanceState, error) { s *opentf.InstanceState) (*opentf.InstanceState, error) {
r, ok := p.ResourcesMap[info.Type] r, ok := p.ResourcesMap[info.Type]
if !ok { if !ok {
return nil, fmt.Errorf("unknown resource type: %s", info.Type) return nil, fmt.Errorf("unknown resource type: %s", info.Type)
@ -339,15 +339,15 @@ func (p *Provider) Refresh(
return r.Refresh(s, p.meta) return r.Refresh(s, p.meta)
} }
// Resources implementation of terraform.ResourceProvider interface. // Resources implementation of opentf.ResourceProvider interface.
func (p *Provider) Resources() []terraform.ResourceType { func (p *Provider) Resources() []opentf.ResourceType {
keys := make([]string, 0, len(p.ResourcesMap)) keys := make([]string, 0, len(p.ResourcesMap))
for k := range p.ResourcesMap { for k := range p.ResourcesMap {
keys = append(keys, k) keys = append(keys, k)
} }
sort.Strings(keys) sort.Strings(keys)
result := make([]terraform.ResourceType, 0, len(keys)) result := make([]opentf.ResourceType, 0, len(keys))
for _, k := range keys { for _, k := range keys {
resource := p.ResourcesMap[k] resource := p.ResourcesMap[k]
@ -357,7 +357,7 @@ func (p *Provider) Resources() []terraform.ResourceType {
resource = &Resource{} resource = &Resource{}
} }
result = append(result, terraform.ResourceType{ result = append(result, opentf.ResourceType{
Name: k, Name: k,
Importable: resource.Importer != nil, Importable: resource.Importer != nil,
@ -371,8 +371,8 @@ func (p *Provider) Resources() []terraform.ResourceType {
} }
func (p *Provider) ImportState( func (p *Provider) ImportState(
info *terraform.InstanceInfo, info *opentf.InstanceInfo,
id string) ([]*terraform.InstanceState, error) { id string) ([]*opentf.InstanceState, error) {
// Find the resource // Find the resource
r, ok := p.ResourcesMap[info.Type] r, ok := p.ResourcesMap[info.Type]
if !ok { if !ok {
@ -400,7 +400,7 @@ func (p *Provider) ImportState(
} }
// Convert the results to InstanceState values and return it // Convert the results to InstanceState values and return it
states := make([]*terraform.InstanceState, len(results)) states := make([]*opentf.InstanceState, len(results))
for i, r := range results { for i, r := range results {
states[i] = r.State() states[i] = r.State()
} }
@ -419,9 +419,9 @@ func (p *Provider) ImportState(
return states, nil return states, nil
} }
// ValidateDataSource implementation of terraform.ResourceProvider interface. // ValidateDataSource implementation of opentf.ResourceProvider interface.
func (p *Provider) ValidateDataSource( func (p *Provider) ValidateDataSource(
t string, c *terraform.ResourceConfig) ([]string, []error) { t string, c *opentf.ResourceConfig) ([]string, []error) {
r, ok := p.DataSourcesMap[t] r, ok := p.DataSourcesMap[t]
if !ok { if !ok {
return nil, []error{fmt.Errorf( return nil, []error{fmt.Errorf(
@ -431,10 +431,10 @@ func (p *Provider) ValidateDataSource(
return r.Validate(c) return r.Validate(c)
} }
// ReadDataDiff implementation of terraform.ResourceProvider interface. // ReadDataDiff implementation of opentf.ResourceProvider interface.
func (p *Provider) ReadDataDiff( func (p *Provider) ReadDataDiff(
info *terraform.InstanceInfo, info *opentf.InstanceInfo,
c *terraform.ResourceConfig) (*terraform.InstanceDiff, error) { c *opentf.ResourceConfig) (*opentf.InstanceDiff, error) {
r, ok := p.DataSourcesMap[info.Type] r, ok := p.DataSourcesMap[info.Type]
if !ok { if !ok {
@ -444,10 +444,10 @@ func (p *Provider) ReadDataDiff(
return r.Diff(nil, c, p.meta) return r.Diff(nil, c, p.meta)
} }
// RefreshData implementation of terraform.ResourceProvider interface. // RefreshData implementation of opentf.ResourceProvider interface.
func (p *Provider) ReadDataApply( func (p *Provider) ReadDataApply(
info *terraform.InstanceInfo, info *opentf.InstanceInfo,
d *terraform.InstanceDiff) (*terraform.InstanceState, error) { d *opentf.InstanceDiff) (*opentf.InstanceState, error) {
r, ok := p.DataSourcesMap[info.Type] r, ok := p.DataSourcesMap[info.Type]
if !ok { if !ok {
@ -457,17 +457,17 @@ func (p *Provider) ReadDataApply(
return r.ReadDataApply(d, p.meta) return r.ReadDataApply(d, p.meta)
} }
// DataSources implementation of terraform.ResourceProvider interface. // DataSources implementation of opentf.ResourceProvider interface.
func (p *Provider) DataSources() []terraform.DataSource { func (p *Provider) DataSources() []opentf.DataSource {
keys := make([]string, 0, len(p.DataSourcesMap)) keys := make([]string, 0, len(p.DataSourcesMap))
for k, _ := range p.DataSourcesMap { for k, _ := range p.DataSourcesMap {
keys = append(keys, k) keys = append(keys, k)
} }
sort.Strings(keys) sort.Strings(keys)
result := make([]terraform.DataSource, 0, len(keys)) result := make([]opentf.DataSource, 0, len(keys))
for _, k := range keys { for _, k := range keys {
result = append(result, terraform.DataSource{ result = append(result, opentf.DataSource{
Name: k, Name: k,
// Indicates that a provider is compiled against a new enough // Indicates that a provider is compiled against a new enough

View File

@ -14,11 +14,11 @@ import (
"github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty"
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
func TestProvider_impl(t *testing.T) { func TestProvider_impl(t *testing.T) {
var _ terraform.ResourceProvider = new(Provider) var _ opentf.ResourceProvider = new(Provider)
} }
func TestProviderGetSchema(t *testing.T) { func TestProviderGetSchema(t *testing.T) {
@ -53,7 +53,7 @@ func TestProviderGetSchema(t *testing.T) {
}, },
} }
want := &terraform.ProviderSchema{ want := &opentf.ProviderSchema{
Provider: &configschema.Block{ Provider: &configschema.Block{
Attributes: map[string]*configschema.Attribute{ Attributes: map[string]*configschema.Attribute{
"bar": &configschema.Attribute{ "bar": &configschema.Attribute{
@ -86,7 +86,7 @@ func TestProviderGetSchema(t *testing.T) {
}), }),
}, },
} }
got, err := p.GetSchema(&terraform.ProviderSchemaRequest{ got, err := p.GetSchema(&opentf.ProviderSchemaRequest{
ResourceTypes: []string{"foo", "bar"}, ResourceTypes: []string{"foo", "bar"},
DataSources: []string{"baz", "bar"}, DataSources: []string{"baz", "bar"},
}) })
@ -159,7 +159,7 @@ func TestProviderConfigure(t *testing.T) {
} }
for i, tc := range cases { for i, tc := range cases {
c := terraform.NewResourceConfigRaw(tc.Config) c := opentf.NewResourceConfigRaw(tc.Config)
err := tc.P.Configure(c) err := tc.P.Configure(c)
if err != nil != tc.Err { if err != nil != tc.Err {
t.Fatalf("%d: %s", i, err) t.Fatalf("%d: %s", i, err)
@ -170,11 +170,11 @@ func TestProviderConfigure(t *testing.T) {
func TestProviderResources(t *testing.T) { func TestProviderResources(t *testing.T) {
cases := []struct { cases := []struct {
P *Provider P *Provider
Result []terraform.ResourceType Result []opentf.ResourceType
}{ }{
{ {
P: &Provider{}, P: &Provider{},
Result: []terraform.ResourceType{}, Result: []opentf.ResourceType{},
}, },
{ {
@ -184,9 +184,9 @@ func TestProviderResources(t *testing.T) {
"bar": nil, "bar": nil,
}, },
}, },
Result: []terraform.ResourceType{ Result: []opentf.ResourceType{
terraform.ResourceType{Name: "bar", SchemaAvailable: true}, opentf.ResourceType{Name: "bar", SchemaAvailable: true},
terraform.ResourceType{Name: "foo", SchemaAvailable: true}, opentf.ResourceType{Name: "foo", SchemaAvailable: true},
}, },
}, },
@ -198,10 +198,10 @@ func TestProviderResources(t *testing.T) {
"baz": nil, "baz": nil,
}, },
}, },
Result: []terraform.ResourceType{ Result: []opentf.ResourceType{
terraform.ResourceType{Name: "bar", Importable: true, SchemaAvailable: true}, opentf.ResourceType{Name: "bar", Importable: true, SchemaAvailable: true},
terraform.ResourceType{Name: "baz", SchemaAvailable: true}, opentf.ResourceType{Name: "baz", SchemaAvailable: true},
terraform.ResourceType{Name: "foo", SchemaAvailable: true}, opentf.ResourceType{Name: "foo", SchemaAvailable: true},
}, },
}, },
} }
@ -217,11 +217,11 @@ func TestProviderResources(t *testing.T) {
func TestProviderDataSources(t *testing.T) { func TestProviderDataSources(t *testing.T) {
cases := []struct { cases := []struct {
P *Provider P *Provider
Result []terraform.DataSource Result []opentf.DataSource
}{ }{
{ {
P: &Provider{}, P: &Provider{},
Result: []terraform.DataSource{}, Result: []opentf.DataSource{},
}, },
{ {
@ -231,9 +231,9 @@ func TestProviderDataSources(t *testing.T) {
"bar": nil, "bar": nil,
}, },
}, },
Result: []terraform.DataSource{ Result: []opentf.DataSource{
terraform.DataSource{Name: "bar", SchemaAvailable: true}, opentf.DataSource{Name: "bar", SchemaAvailable: true},
terraform.DataSource{Name: "foo", SchemaAvailable: true}, opentf.DataSource{Name: "foo", SchemaAvailable: true},
}, },
}, },
} }
@ -264,7 +264,7 @@ func TestProviderValidate(t *testing.T) {
} }
for i, tc := range cases { for i, tc := range cases {
c := terraform.NewResourceConfigRaw(tc.Config) c := opentf.NewResourceConfigRaw(tc.Config)
_, es := tc.P.Validate(c) _, es := tc.P.Validate(c)
if len(es) > 0 != tc.Err { if len(es) > 0 != tc.Err {
t.Fatalf("%d: %#v", i, es) t.Fatalf("%d: %#v", i, es)
@ -297,9 +297,9 @@ func TestProviderDiff_legacyTimeoutType(t *testing.T) {
}, },
}, },
} }
ic := terraform.NewResourceConfigRaw(invalidCfg) ic := opentf.NewResourceConfigRaw(invalidCfg)
_, err := p.Diff( _, err := p.Diff(
&terraform.InstanceInfo{ &opentf.InstanceInfo{
Type: "blah", Type: "blah",
}, },
nil, nil,
@ -333,9 +333,9 @@ func TestProviderDiff_timeoutInvalidValue(t *testing.T) {
"create": "invalid", "create": "invalid",
}, },
} }
ic := terraform.NewResourceConfigRaw(invalidCfg) ic := opentf.NewResourceConfigRaw(invalidCfg)
_, err := p.Diff( _, err := p.Diff(
&terraform.InstanceInfo{ &opentf.InstanceInfo{
Type: "blah", Type: "blah",
}, },
nil, nil,
@ -379,7 +379,7 @@ func TestProviderValidateResource(t *testing.T) {
} }
for i, tc := range cases { for i, tc := range cases {
c := terraform.NewResourceConfigRaw(tc.Config) c := opentf.NewResourceConfigRaw(tc.Config)
_, es := tc.P.ValidateResource(tc.Type, c) _, es := tc.P.ValidateResource(tc.Type, c)
if len(es) > 0 != tc.Err { if len(es) > 0 != tc.Err {
t.Fatalf("%d: %#v", i, es) t.Fatalf("%d: %#v", i, es)
@ -396,7 +396,7 @@ func TestProviderImportState_default(t *testing.T) {
}, },
} }
states, err := p.ImportState(&terraform.InstanceInfo{ states, err := p.ImportState(&opentf.InstanceInfo{
Type: "foo", Type: "foo",
}, "bar") }, "bar")
if err != nil { if err != nil {
@ -428,7 +428,7 @@ func TestProviderImportState_setsId(t *testing.T) {
}, },
} }
_, err := p.ImportState(&terraform.InstanceInfo{ _, err := p.ImportState(&opentf.InstanceInfo{
Type: "foo", Type: "foo",
}, "bar") }, "bar")
if err != nil { if err != nil {
@ -458,7 +458,7 @@ func TestProviderImportState_setsType(t *testing.T) {
}, },
} }
_, err := p.ImportState(&terraform.InstanceInfo{ _, err := p.ImportState(&opentf.InstanceInfo{
Type: "foo", Type: "foo",
}, "bar") }, "bar")
if err != nil { if err != nil {

View File

@ -11,7 +11,7 @@ import (
"github.com/hashicorp/go-multierror" "github.com/hashicorp/go-multierror"
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
// Provisioner represents a resource provisioner in Terraform and properly // Provisioner represents a resource provisioner in Terraform and properly
@ -46,7 +46,7 @@ type Provisioner struct {
// ValidateFunc is a function for extended validation. This is optional // ValidateFunc is a function for extended validation. This is optional
// and should be used when individual field validation is not enough. // and should be used when individual field validation is not enough.
ValidateFunc func(*terraform.ResourceConfig) ([]string, []error) ValidateFunc func(*opentf.ResourceConfig) ([]string, []error)
stopCtx context.Context stopCtx context.Context
stopCtxCancel context.CancelFunc stopCtxCancel context.CancelFunc
@ -117,23 +117,23 @@ func (p *Provisioner) stopInit() {
p.stopCtx, p.stopCtxCancel = context.WithCancel(context.Background()) p.stopCtx, p.stopCtxCancel = context.WithCancel(context.Background())
} }
// Stop implementation of terraform.ResourceProvisioner interface. // Stop implementation of opentf.ResourceProvisioner interface.
func (p *Provisioner) Stop() error { func (p *Provisioner) Stop() error {
p.stopOnce.Do(p.stopInit) p.stopOnce.Do(p.stopInit)
p.stopCtxCancel() p.stopCtxCancel()
return nil return nil
} }
// GetConfigSchema implementation of terraform.ResourceProvisioner interface. // GetConfigSchema implementation of opentf.ResourceProvisioner interface.
func (p *Provisioner) GetConfigSchema() (*configschema.Block, error) { func (p *Provisioner) GetConfigSchema() (*configschema.Block, error) {
return schemaMap(p.Schema).CoreConfigSchema(), nil return schemaMap(p.Schema).CoreConfigSchema(), nil
} }
// Apply implementation of terraform.ResourceProvisioner interface. // Apply implementation of opentf.ResourceProvisioner interface.
func (p *Provisioner) Apply( func (p *Provisioner) Apply(
o terraform.UIOutput, o opentf.UIOutput,
s *terraform.InstanceState, s *opentf.InstanceState,
c *terraform.ResourceConfig) error { c *opentf.ResourceConfig) error {
var connData, configData *ResourceData var connData, configData *ResourceData
{ {
@ -148,7 +148,7 @@ func (p *Provisioner) Apply(
} }
} }
c := terraform.NewResourceConfigRaw(raw) c := opentf.NewResourceConfigRaw(raw)
sm := schemaMap(p.ConnSchema) sm := schemaMap(p.ConnSchema)
diff, err := sm.Diff(nil, c, nil, nil, true) diff, err := sm.Diff(nil, c, nil, nil, true)
if err != nil { if err != nil {
@ -183,8 +183,8 @@ func (p *Provisioner) Apply(
return p.ApplyFunc(ctx) return p.ApplyFunc(ctx)
} }
// Validate implements the terraform.ResourceProvisioner interface. // Validate implements the opentf.ResourceProvisioner interface.
func (p *Provisioner) Validate(c *terraform.ResourceConfig) (ws []string, es []error) { func (p *Provisioner) Validate(c *opentf.ResourceConfig) (ws []string, es []error) {
if err := p.InternalValidate(); err != nil { if err := p.InternalValidate(); err != nil {
return nil, []error{fmt.Errorf( return nil, []error{fmt.Errorf(
"Internal validation of the provisioner failed! This is always a bug\n"+ "Internal validation of the provisioner failed! This is always a bug\n"+

View File

@ -10,11 +10,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
func TestProvisioner_impl(t *testing.T) { func TestProvisioner_impl(t *testing.T) {
var _ terraform.ResourceProvisioner = new(Provisioner) var _ opentf.ResourceProvisioner = new(Provisioner)
} }
func noopApply(ctx context.Context) error { func noopApply(ctx context.Context) error {
@ -114,7 +114,7 @@ func TestProvisionerValidate(t *testing.T) {
P: &Provisioner{ P: &Provisioner{
Schema: nil, Schema: nil,
ApplyFunc: noopApply, ApplyFunc: noopApply,
ValidateFunc: func(*terraform.ResourceConfig) (ws []string, errors []error) { ValidateFunc: func(*opentf.ResourceConfig) (ws []string, errors []error) {
ws = append(ws, "Simple warning from provisioner ValidateFunc") ws = append(ws, "Simple warning from provisioner ValidateFunc")
return return
}, },
@ -127,7 +127,7 @@ func TestProvisionerValidate(t *testing.T) {
for i, tc := range cases { for i, tc := range cases {
t.Run(fmt.Sprintf("%d-%s", i, tc.Name), func(t *testing.T) { t.Run(fmt.Sprintf("%d-%s", i, tc.Name), func(t *testing.T) {
c := terraform.NewResourceConfigRaw(tc.Config) c := opentf.NewResourceConfigRaw(tc.Config)
ws, es := tc.P.Validate(c) ws, es := tc.P.Validate(c)
if len(es) > 0 != tc.Err { if len(es) > 0 != tc.Err {
t.Fatalf("%d: %#v %s", i, es, es) t.Fatalf("%d: %#v %s", i, es, es)
@ -189,10 +189,10 @@ func TestProvisionerApply(t *testing.T) {
for i, tc := range cases { for i, tc := range cases {
t.Run(fmt.Sprintf("%d-%s", i, tc.Name), func(t *testing.T) { t.Run(fmt.Sprintf("%d-%s", i, tc.Name), func(t *testing.T) {
c := terraform.NewResourceConfigRaw(tc.Config) c := opentf.NewResourceConfigRaw(tc.Config)
state := &terraform.InstanceState{ state := &opentf.InstanceState{
Ephemeral: terraform.EphemeralState{ Ephemeral: opentf.EphemeralState{
ConnInfo: tc.Conn, ConnInfo: tc.Conn,
}, },
} }
@ -230,7 +230,7 @@ func TestProvisionerApply_nilState(t *testing.T) {
"foo": 42, "foo": 42,
} }
c := terraform.NewResourceConfigRaw(conf) c := opentf.NewResourceConfigRaw(conf)
err := p.Apply(nil, nil, c) err := p.Apply(nil, nil, c)
if err != nil { if err != nil {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
@ -290,9 +290,9 @@ func TestProvisionerStop_apply(t *testing.T) {
"foo": 42, "foo": 42,
} }
c := terraform.NewResourceConfigRaw(conf) c := opentf.NewResourceConfigRaw(conf)
state := &terraform.InstanceState{ state := &opentf.InstanceState{
Ephemeral: terraform.EphemeralState{ Ephemeral: opentf.EphemeralState{
ConnInfo: conn, ConnInfo: conn,
}, },
} }

View File

@ -9,7 +9,7 @@ import (
"log" "log"
"strconv" "strconv"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
"github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty"
) )
@ -178,11 +178,11 @@ type Resource struct {
} }
// ShimInstanceStateFromValue converts a cty.Value to a // ShimInstanceStateFromValue converts a cty.Value to a
// terraform.InstanceState. // opentf.InstanceState.
func (r *Resource) ShimInstanceStateFromValue(state cty.Value) (*terraform.InstanceState, error) { func (r *Resource) ShimInstanceStateFromValue(state cty.Value) (*opentf.InstanceState, error) {
// Get the raw shimmed value. While this is correct, the set hashes don't // Get the raw shimmed value. While this is correct, the set hashes don't
// match those from the Schema. // match those from the Schema.
s := terraform.NewInstanceStateShimmedFromValue(state, r.SchemaVersion) s := opentf.NewInstanceStateShimmedFromValue(state, r.SchemaVersion)
// We now rebuild the state through the ResourceData, so that the set indexes // We now rebuild the state through the ResourceData, so that the set indexes
// match what helper/schema expects. // match what helper/schema expects.
@ -193,7 +193,7 @@ func (r *Resource) ShimInstanceStateFromValue(state cty.Value) (*terraform.Insta
s = data.State() s = data.State()
if s == nil { if s == nil {
s = &terraform.InstanceState{} s = &opentf.InstanceState{}
} }
return s, nil return s, nil
} }
@ -215,7 +215,7 @@ type ExistsFunc func(*ResourceData, interface{}) (bool, error)
// See Resource documentation. // See Resource documentation.
type StateMigrateFunc func( type StateMigrateFunc func(
int, *terraform.InstanceState, interface{}) (*terraform.InstanceState, error) int, *opentf.InstanceState, interface{}) (*opentf.InstanceState, error)
type StateUpgrader struct { type StateUpgrader struct {
// Version is the version schema that this Upgrader will handle, converting // Version is the version schema that this Upgrader will handle, converting
@ -243,9 +243,9 @@ type CustomizeDiffFunc func(*ResourceDiff, interface{}) error
// Apply creates, updates, and/or deletes a resource. // Apply creates, updates, and/or deletes a resource.
func (r *Resource) Apply( func (r *Resource) Apply(
s *terraform.InstanceState, s *opentf.InstanceState,
d *terraform.InstanceDiff, d *opentf.InstanceDiff,
meta interface{}) (*terraform.InstanceState, error) { meta interface{}) (*opentf.InstanceState, error) {
data, err := schemaMap(r.Schema).Data(s, d) data, err := schemaMap(r.Schema).Data(s, d)
if err != nil { if err != nil {
return s, err return s, err
@ -275,7 +275,7 @@ func (r *Resource) Apply(
if s == nil { if s == nil {
// The Terraform API dictates that this should never happen, but // The Terraform API dictates that this should never happen, but
// it doesn't hurt to be safe in this case. // it doesn't hurt to be safe in this case.
s = new(terraform.InstanceState) s = new(opentf.InstanceState)
} }
if d.Destroy || d.RequiresNew() { if d.Destroy || d.RequiresNew() {
@ -322,9 +322,9 @@ func (r *Resource) Apply(
// Diff returns a diff of this resource. // Diff returns a diff of this resource.
func (r *Resource) Diff( func (r *Resource) Diff(
s *terraform.InstanceState, s *opentf.InstanceState,
c *terraform.ResourceConfig, c *opentf.ResourceConfig,
meta interface{}) (*terraform.InstanceDiff, error) { meta interface{}) (*opentf.InstanceDiff, error) {
t := &ResourceTimeout{} t := &ResourceTimeout{}
err := t.ConfigDecode(r, c) err := t.ConfigDecode(r, c)
@ -350,9 +350,9 @@ func (r *Resource) Diff(
} }
func (r *Resource) simpleDiff( func (r *Resource) simpleDiff(
s *terraform.InstanceState, s *opentf.InstanceState,
c *terraform.ResourceConfig, c *opentf.ResourceConfig,
meta interface{}) (*terraform.InstanceDiff, error) { meta interface{}) (*opentf.InstanceDiff, error) {
instanceDiff, err := schemaMap(r.Schema).Diff(s, c, r.CustomizeDiff, meta, false) instanceDiff, err := schemaMap(r.Schema).Diff(s, c, r.CustomizeDiff, meta, false)
if err != nil { if err != nil {
@ -360,7 +360,7 @@ func (r *Resource) simpleDiff(
} }
if instanceDiff == nil { if instanceDiff == nil {
instanceDiff = terraform.NewInstanceDiff() instanceDiff = opentf.NewInstanceDiff()
} }
// Make sure the old value is set in each of the instance diffs. // Make sure the old value is set in each of the instance diffs.
@ -378,7 +378,7 @@ func (r *Resource) simpleDiff(
} }
// Validate validates the resource configuration against the schema. // Validate validates the resource configuration against the schema.
func (r *Resource) Validate(c *terraform.ResourceConfig) ([]string, []error) { func (r *Resource) Validate(c *opentf.ResourceConfig) ([]string, []error) {
warns, errs := schemaMap(r.Schema).Validate(c) warns, errs := schemaMap(r.Schema).Validate(c)
if r.DeprecationMessage != "" { if r.DeprecationMessage != "" {
@ -391,9 +391,9 @@ func (r *Resource) Validate(c *terraform.ResourceConfig) ([]string, []error) {
// ReadDataApply loads the data for a data source, given a diff that // ReadDataApply loads the data for a data source, given a diff that
// describes the configuration arguments and desired computed attributes. // describes the configuration arguments and desired computed attributes.
func (r *Resource) ReadDataApply( func (r *Resource) ReadDataApply(
d *terraform.InstanceDiff, d *opentf.InstanceDiff,
meta interface{}, meta interface{},
) (*terraform.InstanceState, error) { ) (*opentf.InstanceState, error) {
// Data sources are always built completely from scratch // Data sources are always built completely from scratch
// on each read, so the source state is always nil. // on each read, so the source state is always nil.
data, err := schemaMap(r.Schema).Data(nil, d) data, err := schemaMap(r.Schema).Data(nil, d)
@ -419,8 +419,8 @@ func (r *Resource) ReadDataApply(
// separate API call. // separate API call.
// RefreshWithoutUpgrade is part of the new plugin shims. // RefreshWithoutUpgrade is part of the new plugin shims.
func (r *Resource) RefreshWithoutUpgrade( func (r *Resource) RefreshWithoutUpgrade(
s *terraform.InstanceState, s *opentf.InstanceState,
meta interface{}) (*terraform.InstanceState, error) { meta interface{}) (*opentf.InstanceState, error) {
// If the ID is already somehow blank, it doesn't exist // If the ID is already somehow blank, it doesn't exist
if s.ID == "" { if s.ID == "" {
return nil, nil return nil, nil
@ -477,8 +477,8 @@ func (r *Resource) RefreshWithoutUpgrade(
// Refresh refreshes the state of the resource. // Refresh refreshes the state of the resource.
func (r *Resource) Refresh( func (r *Resource) Refresh(
s *terraform.InstanceState, s *opentf.InstanceState,
meta interface{}) (*terraform.InstanceState, error) { meta interface{}) (*opentf.InstanceState, error) {
// If the ID is already somehow blank, it doesn't exist // If the ID is already somehow blank, it doesn't exist
if s.ID == "" { if s.ID == "" {
return nil, nil return nil, nil
@ -531,7 +531,7 @@ func (r *Resource) Refresh(
return r.recordCurrentSchemaVersion(state), err return r.recordCurrentSchemaVersion(state), err
} }
func (r *Resource) upgradeState(s *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) { func (r *Resource) upgradeState(s *opentf.InstanceState, meta interface{}) (*opentf.InstanceState, error) {
var err error var err error
needsMigration, stateSchemaVersion := r.checkSchemaVersion(s) needsMigration, stateSchemaVersion := r.checkSchemaVersion(s)
@ -744,7 +744,7 @@ func isReservedResourceFieldName(name string, s *Schema) bool {
// itself (including the state given to this function). // itself (including the state given to this function).
// //
// This function is useful for unit tests and ResourceImporter functions. // This function is useful for unit tests and ResourceImporter functions.
func (r *Resource) Data(s *terraform.InstanceState) *ResourceData { func (r *Resource) Data(s *opentf.InstanceState) *ResourceData {
result, err := schemaMap(r.Schema).Data(s, nil) result, err := schemaMap(r.Schema).Data(s, nil)
if err != nil { if err != nil {
// At the time of writing, this isn't possible (Data never returns // At the time of writing, this isn't possible (Data never returns
@ -791,7 +791,7 @@ func (r *Resource) isTopLevel() bool {
// Determines if a given InstanceState needs to be migrated by checking the // Determines if a given InstanceState needs to be migrated by checking the
// stored version number with the current SchemaVersion // stored version number with the current SchemaVersion
func (r *Resource) checkSchemaVersion(is *terraform.InstanceState) (bool, int) { func (r *Resource) checkSchemaVersion(is *opentf.InstanceState) (bool, int) {
// Get the raw interface{} value for the schema version. If it doesn't // Get the raw interface{} value for the schema version. If it doesn't
// exist or is nil then set it to zero. // exist or is nil then set it to zero.
raw := is.Meta["schema_version"] raw := is.Meta["schema_version"]
@ -820,7 +820,7 @@ func (r *Resource) checkSchemaVersion(is *terraform.InstanceState) (bool, int) {
} }
func (r *Resource) recordCurrentSchemaVersion( func (r *Resource) recordCurrentSchemaVersion(
state *terraform.InstanceState) *terraform.InstanceState { state *opentf.InstanceState) *opentf.InstanceState {
if state != nil && r.SchemaVersion > 0 { if state != nil && r.SchemaVersion > 0 {
if state.Meta == nil { if state.Meta == nil {
state.Meta = make(map[string]interface{}) state.Meta = make(map[string]interface{})

View File

@ -10,7 +10,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
"github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty"
"github.com/zclconf/go-cty/cty/gocty" "github.com/zclconf/go-cty/cty/gocty"
) )
@ -26,9 +26,9 @@ import (
type ResourceData struct { type ResourceData struct {
// Settable (internally) // Settable (internally)
schema map[string]*Schema schema map[string]*Schema
config *terraform.ResourceConfig config *opentf.ResourceConfig
state *terraform.InstanceState state *opentf.InstanceState
diff *terraform.InstanceDiff diff *opentf.InstanceDiff
meta map[string]interface{} meta map[string]interface{}
timeouts *ResourceTimeout timeouts *ResourceTimeout
providerMeta cty.Value providerMeta cty.Value
@ -36,7 +36,7 @@ type ResourceData struct {
// Don't set // Don't set
multiReader *MultiLevelFieldReader multiReader *MultiLevelFieldReader
setWriter *MapFieldWriter setWriter *MapFieldWriter
newState *terraform.InstanceState newState *opentf.InstanceState
partial bool partial bool
partialMap map[string]struct{} partialMap map[string]struct{}
once sync.Once once sync.Once
@ -289,8 +289,8 @@ func (d *ResourceData) SetType(t string) {
// State returns the new InstanceState after the diff and any Set // State returns the new InstanceState after the diff and any Set
// calls. // calls.
func (d *ResourceData) State() *terraform.InstanceState { func (d *ResourceData) State() *opentf.InstanceState {
var result terraform.InstanceState var result opentf.InstanceState
result.ID = d.Id() result.ID = d.Id()
result.Meta = d.meta result.Meta = d.meta
@ -425,7 +425,7 @@ func (d *ResourceData) Timeout(key string) time.Duration {
func (d *ResourceData) init() { func (d *ResourceData) init() {
// Initialize the field that will store our new state // Initialize the field that will store our new state
var copyState terraform.InstanceState var copyState opentf.InstanceState
if d.state != nil { if d.state != nil {
copyState = *d.state.DeepCopy() copyState = *d.state.DeepCopy()
} }

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
// newValueWriter is a minor re-implementation of MapFieldWriter to include // newValueWriter is a minor re-implementation of MapFieldWriter to include
@ -116,16 +116,16 @@ type ResourceDiff struct {
schema map[string]*Schema schema map[string]*Schema
// The current config for this resource. // The current config for this resource.
config *terraform.ResourceConfig config *opentf.ResourceConfig
// The state for this resource as it exists post-refresh, after the initial // The state for this resource as it exists post-refresh, after the initial
// diff. // diff.
state *terraform.InstanceState state *opentf.InstanceState
// The diff created by Terraform. This diff is used, along with state, // The diff created by Terraform. This diff is used, along with state,
// config, and custom-set diff data, to provide a multi-level reader // config, and custom-set diff data, to provide a multi-level reader
// experience similar to ResourceData. // experience similar to ResourceData.
diff *terraform.InstanceDiff diff *opentf.InstanceDiff
// The internal reader structure that contains the state, config, the default // The internal reader structure that contains the state, config, the default
// diff, and the new diff. // diff, and the new diff.
@ -145,7 +145,7 @@ type ResourceDiff struct {
} }
// newResourceDiff creates a new ResourceDiff instance. // newResourceDiff creates a new ResourceDiff instance.
func newResourceDiff(schema map[string]*Schema, config *terraform.ResourceConfig, state *terraform.InstanceState, diff *terraform.InstanceDiff) *ResourceDiff { func newResourceDiff(schema map[string]*Schema, config *opentf.ResourceConfig, state *opentf.InstanceState, diff *opentf.InstanceDiff) *ResourceDiff {
d := &ResourceDiff{ d := &ResourceDiff{
config: config, config: config,
state: state, state: state,

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/hcl2shim" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/hcl2shim"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
"github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty"
ctyjson "github.com/zclconf/go-cty/cty/json" ctyjson "github.com/zclconf/go-cty/cty/json"
@ -37,11 +37,11 @@ func TestResourceApply_create(t *testing.T) {
return nil return nil
} }
var s *terraform.InstanceState = nil var s *opentf.InstanceState = nil
d := &terraform.InstanceDiff{ d := &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{ "foo": &opentf.ResourceAttrDiff{
New: "42", New: "42",
}, },
}, },
@ -56,7 +56,7 @@ func TestResourceApply_create(t *testing.T) {
t.Fatal("not called") t.Fatal("not called")
} }
expected := &terraform.InstanceState{ expected := &opentf.InstanceState{
ID: "foo", ID: "foo",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "foo", "id": "foo",
@ -95,11 +95,11 @@ func TestResourceApply_Timeout_state(t *testing.T) {
return nil return nil
} }
var s *terraform.InstanceState = nil var s *opentf.InstanceState = nil
d := &terraform.InstanceDiff{ d := &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{ "foo": &opentf.ResourceAttrDiff{
New: "42", New: "42",
}, },
}, },
@ -124,7 +124,7 @@ func TestResourceApply_Timeout_state(t *testing.T) {
t.Fatal("not called") t.Fatal("not called")
} }
expected := &terraform.InstanceState{ expected := &opentf.InstanceState{
ID: "foo", ID: "foo",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "foo", "id": "foo",
@ -169,7 +169,7 @@ func TestResourceApply_Timeout_destroy(t *testing.T) {
return nil return nil
} }
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "bar", ID: "bar",
} }
@ -177,7 +177,7 @@ func TestResourceApply_Timeout_destroy(t *testing.T) {
t.Fatalf("Error encoding to state: %s", err) t.Fatalf("Error encoding to state: %s", err)
} }
d := &terraform.InstanceDiff{ d := &opentf.InstanceDiff{
Destroy: true, Destroy: true,
} }
@ -219,7 +219,7 @@ func TestResourceDiff_Timeout_diff(t *testing.T) {
return nil return nil
} }
conf := terraform.NewResourceConfigRaw( conf := opentf.NewResourceConfigRaw(
map[string]interface{}{ map[string]interface{}{
"foo": 42, "foo": 42,
TimeoutsConfigKey: map[string]interface{}{ TimeoutsConfigKey: map[string]interface{}{
@ -227,16 +227,16 @@ func TestResourceDiff_Timeout_diff(t *testing.T) {
}, },
}, },
) )
var s *terraform.InstanceState var s *opentf.InstanceState
actual, err := r.Diff(s, conf, nil) actual, err := r.Diff(s, conf, nil)
if err != nil { if err != nil {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
expected := &terraform.InstanceDiff{ expected := &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{ "foo": &opentf.ResourceAttrDiff{
New: "42", New: "42",
}, },
}, },
@ -274,13 +274,13 @@ func TestResourceDiff_CustomizeFunc(t *testing.T) {
return nil return nil
} }
conf := terraform.NewResourceConfigRaw( conf := opentf.NewResourceConfigRaw(
map[string]interface{}{ map[string]interface{}{
"foo": 42, "foo": 42,
}, },
) )
var s *terraform.InstanceState var s *opentf.InstanceState
_, err := r.Diff(s, conf, nil) _, err := r.Diff(s, conf, nil)
if err != nil { if err != nil {
@ -308,11 +308,11 @@ func TestResourceApply_destroy(t *testing.T) {
return nil return nil
} }
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "bar", ID: "bar",
} }
d := &terraform.InstanceDiff{ d := &opentf.InstanceDiff{
Destroy: true, Destroy: true,
} }
@ -356,7 +356,7 @@ func TestResourceApply_destroyCreate(t *testing.T) {
return nil return nil
} }
var s *terraform.InstanceState = &terraform.InstanceState{ var s *opentf.InstanceState = &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"foo": "bar", "foo": "bar",
@ -364,13 +364,13 @@ func TestResourceApply_destroyCreate(t *testing.T) {
}, },
} }
d := &terraform.InstanceDiff{ d := &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{ "foo": &opentf.ResourceAttrDiff{
New: "42", New: "42",
RequiresNew: true, RequiresNew: true,
}, },
"tags.Name": &terraform.ResourceAttrDiff{ "tags.Name": &opentf.ResourceAttrDiff{
Old: "foo", Old: "foo",
New: "foo", New: "foo",
RequiresNew: true, RequiresNew: true,
@ -387,7 +387,7 @@ func TestResourceApply_destroyCreate(t *testing.T) {
t.Fatal("should have change") t.Fatal("should have change")
} }
expected := &terraform.InstanceState{ expected := &opentf.InstanceState{
ID: "foo", ID: "foo",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "foo", "id": "foo",
@ -418,14 +418,14 @@ func TestResourceApply_destroyPartial(t *testing.T) {
return fmt.Errorf("some error") return fmt.Errorf("some error")
} }
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"foo": "12", "foo": "12",
}, },
} }
d := &terraform.InstanceDiff{ d := &opentf.InstanceDiff{
Destroy: true, Destroy: true,
} }
@ -434,7 +434,7 @@ func TestResourceApply_destroyPartial(t *testing.T) {
t.Fatal("should error") t.Fatal("should error")
} }
expected := &terraform.InstanceState{ expected := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "bar", "id": "bar",
@ -465,16 +465,16 @@ func TestResourceApply_update(t *testing.T) {
return nil return nil
} }
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "foo", ID: "foo",
Attributes: map[string]string{ Attributes: map[string]string{
"foo": "12", "foo": "12",
}, },
} }
d := &terraform.InstanceDiff{ d := &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{ "foo": &opentf.ResourceAttrDiff{
New: "13", New: "13",
}, },
}, },
@ -485,7 +485,7 @@ func TestResourceApply_update(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
expected := &terraform.InstanceState{ expected := &opentf.InstanceState{
ID: "foo", ID: "foo",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "foo", "id": "foo",
@ -510,16 +510,16 @@ func TestResourceApply_updateNoCallback(t *testing.T) {
r.Update = nil r.Update = nil
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "foo", ID: "foo",
Attributes: map[string]string{ Attributes: map[string]string{
"foo": "12", "foo": "12",
}, },
} }
d := &terraform.InstanceDiff{ d := &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{ "foo": &opentf.ResourceAttrDiff{
New: "13", New: "13",
}, },
}, },
@ -530,7 +530,7 @@ func TestResourceApply_updateNoCallback(t *testing.T) {
t.Fatal("should error") t.Fatal("should error")
} }
expected := &terraform.InstanceState{ expected := &opentf.InstanceState{
ID: "foo", ID: "foo",
Attributes: map[string]string{ Attributes: map[string]string{
"foo": "12", "foo": "12",
@ -566,23 +566,23 @@ func TestResourceApply_isNewResource(t *testing.T) {
} }
r.Update = updateFunc r.Update = updateFunc
d := &terraform.InstanceDiff{ d := &opentf.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*opentf.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{ "foo": &opentf.ResourceAttrDiff{
New: "bla-blah", New: "bla-blah",
}, },
}, },
} }
// positive test // positive test
var s *terraform.InstanceState = nil var s *opentf.InstanceState = nil
actual, err := r.Apply(s, d, nil) actual, err := r.Apply(s, d, nil)
if err != nil { if err != nil {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
expected := &terraform.InstanceState{ expected := &opentf.InstanceState{
ID: "foo", ID: "foo",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "foo", "id": "foo",
@ -596,7 +596,7 @@ func TestResourceApply_isNewResource(t *testing.T) {
} }
// negative test // negative test
s = &terraform.InstanceState{ s = &opentf.InstanceState{
ID: "foo", ID: "foo",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "foo", "id": "foo",
@ -609,7 +609,7 @@ func TestResourceApply_isNewResource(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
expected = &terraform.InstanceState{ expected = &opentf.InstanceState{
ID: "foo", ID: "foo",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "foo", "id": "foo",
@ -903,14 +903,14 @@ func TestResourceRefresh(t *testing.T) {
return d.Set("foo", d.Get("foo").(int)+1) return d.Set("foo", d.Get("foo").(int)+1)
} }
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"foo": "12", "foo": "12",
}, },
} }
expected := &terraform.InstanceState{ expected := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "bar", "id": "bar",
@ -946,7 +946,7 @@ func TestResourceRefresh_blankId(t *testing.T) {
return nil return nil
} }
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "", ID: "",
Attributes: map[string]string{}, Attributes: map[string]string{},
} }
@ -975,7 +975,7 @@ func TestResourceRefresh_delete(t *testing.T) {
return nil return nil
} }
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"foo": "12", "foo": "12",
@ -1010,7 +1010,7 @@ func TestResourceRefresh_existsError(t *testing.T) {
panic("shouldn't be called") panic("shouldn't be called")
} }
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"foo": "12", "foo": "12",
@ -1044,7 +1044,7 @@ func TestResourceRefresh_noExists(t *testing.T) {
panic("shouldn't be called") panic("shouldn't be called")
} }
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"foo": "12", "foo": "12",
@ -1078,8 +1078,8 @@ func TestResourceRefresh_needsMigration(t *testing.T) {
r.MigrateState = func( r.MigrateState = func(
v int, v int,
s *terraform.InstanceState, s *opentf.InstanceState,
meta interface{}) (*terraform.InstanceState, error) { meta interface{}) (*opentf.InstanceState, error) {
// Real state migration functions will probably switch on this value, // Real state migration functions will probably switch on this value,
// but we'll just assert on it for now. // but we'll just assert on it for now.
if v != 1 { if v != 1 {
@ -1102,7 +1102,7 @@ func TestResourceRefresh_needsMigration(t *testing.T) {
// State is v1 and deals in oldfoo, which tracked foo as a float at 1/10th // State is v1 and deals in oldfoo, which tracked foo as a float at 1/10th
// the scale of newfoo // the scale of newfoo
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"oldfoo": "1.2", "oldfoo": "1.2",
@ -1117,7 +1117,7 @@ func TestResourceRefresh_needsMigration(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
expected := &terraform.InstanceState{ expected := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "bar", "id": "bar",
@ -1150,13 +1150,13 @@ func TestResourceRefresh_noMigrationNeeded(t *testing.T) {
r.MigrateState = func( r.MigrateState = func(
v int, v int,
s *terraform.InstanceState, s *opentf.InstanceState,
meta interface{}) (*terraform.InstanceState, error) { meta interface{}) (*opentf.InstanceState, error) {
t.Fatal("Migrate function shouldn't be called!") t.Fatal("Migrate function shouldn't be called!")
return nil, nil return nil, nil
} }
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"newfoo": "12", "newfoo": "12",
@ -1171,7 +1171,7 @@ func TestResourceRefresh_noMigrationNeeded(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
expected := &terraform.InstanceState{ expected := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "bar", "id": "bar",
@ -1205,13 +1205,13 @@ func TestResourceRefresh_stateSchemaVersionUnset(t *testing.T) {
r.MigrateState = func( r.MigrateState = func(
v int, v int,
s *terraform.InstanceState, s *opentf.InstanceState,
meta interface{}) (*terraform.InstanceState, error) { meta interface{}) (*opentf.InstanceState, error) {
s.Attributes["newfoo"] = s.Attributes["oldfoo"] s.Attributes["newfoo"] = s.Attributes["oldfoo"]
return s, nil return s, nil
} }
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"oldfoo": "12", "oldfoo": "12",
@ -1223,7 +1223,7 @@ func TestResourceRefresh_stateSchemaVersionUnset(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
expected := &terraform.InstanceState{ expected := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "bar", "id": "bar",
@ -1257,12 +1257,12 @@ func TestResourceRefresh_migrateStateErr(t *testing.T) {
r.MigrateState = func( r.MigrateState = func(
v int, v int,
s *terraform.InstanceState, s *opentf.InstanceState,
meta interface{}) (*terraform.InstanceState, error) { meta interface{}) (*opentf.InstanceState, error) {
return s, fmt.Errorf("triggering an error") return s, fmt.Errorf("triggering an error")
} }
s := &terraform.InstanceState{ s := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"oldfoo": "12", "oldfoo": "12",
@ -1286,7 +1286,7 @@ func TestResourceData(t *testing.T) {
}, },
} }
state := &terraform.InstanceState{ state := &opentf.InstanceState{
ID: "foo", ID: "foo",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "foo", "id": "foo",
@ -1548,7 +1548,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) {
}, },
}, },
// this MigrateState will take the state to version 2 // this MigrateState will take the state to version 2
MigrateState: func(v int, is *terraform.InstanceState, _ interface{}) (*terraform.InstanceState, error) { MigrateState: func(v int, is *opentf.InstanceState, _ interface{}) (*opentf.InstanceState, error) {
switch v { switch v {
case 0: case 0:
_, ok := is.Attributes["zero"] _, ok := is.Attributes["zero"]
@ -1611,7 +1611,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) {
}, },
} }
testStates := []*terraform.InstanceState{ testStates := []*opentf.InstanceState{
{ {
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
@ -1671,7 +1671,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
expected := &terraform.InstanceState{ expected := &opentf.InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{ Attributes: map[string]string{
"id": "bar", "id": "bar",

View File

@ -10,7 +10,7 @@ import (
"github.com/mitchellh/copystructure" "github.com/mitchellh/copystructure"
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/hcl2shim" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/hcl2shim"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
const TimeoutKey = "e2bfb730-ecaa-11e6-8f88-34363bc7c4c0" const TimeoutKey = "e2bfb730-ecaa-11e6-8f88-34363bc7c4c0"
@ -56,7 +56,7 @@ type ResourceTimeout struct {
// ConfigDecode takes a schema and the configuration (available in Diff) and // ConfigDecode takes a schema and the configuration (available in Diff) and
// validates, parses the timeouts into `t` // validates, parses the timeouts into `t`
func (t *ResourceTimeout) ConfigDecode(s *Resource, c *terraform.ResourceConfig) error { func (t *ResourceTimeout) ConfigDecode(s *Resource, c *opentf.ResourceConfig) error {
if s.Timeouts != nil { if s.Timeouts != nil {
raw, err := copystructure.Copy(s.Timeouts) raw, err := copystructure.Copy(s.Timeouts)
if err != nil { if err != nil {
@ -156,18 +156,18 @@ func unsupportedTimeoutKeyError(key string) error {
// //
// StateEncode encodes the timeout into the ResourceData's InstanceState for // StateEncode encodes the timeout into the ResourceData's InstanceState for
// saving to state // saving to state
func (t *ResourceTimeout) DiffEncode(id *terraform.InstanceDiff) error { func (t *ResourceTimeout) DiffEncode(id *opentf.InstanceDiff) error {
return t.metaEncode(id) return t.metaEncode(id)
} }
func (t *ResourceTimeout) StateEncode(is *terraform.InstanceState) error { func (t *ResourceTimeout) StateEncode(is *opentf.InstanceState) error {
return t.metaEncode(is) return t.metaEncode(is)
} }
// metaEncode encodes the ResourceTimeout into a map[string]interface{} format // metaEncode encodes the ResourceTimeout into a map[string]interface{} format
// and stores it in the Meta field of the interface it's given. // and stores it in the Meta field of the interface it's given.
// Assumes the interface is either *terraform.InstanceState or // Assumes the interface is either *opentf.InstanceState or
// *terraform.InstanceDiff, returns an error otherwise // *opentf.InstanceDiff, returns an error otherwise
func (t *ResourceTimeout) metaEncode(ids interface{}) error { func (t *ResourceTimeout) metaEncode(ids interface{}) error {
m := make(map[string]interface{}) m := make(map[string]interface{})
@ -197,12 +197,12 @@ func (t *ResourceTimeout) metaEncode(ids interface{}) error {
// only add the Timeout to the Meta if we have values // only add the Timeout to the Meta if we have values
if len(m) > 0 { if len(m) > 0 {
switch instance := ids.(type) { switch instance := ids.(type) {
case *terraform.InstanceDiff: case *opentf.InstanceDiff:
if instance.Meta == nil { if instance.Meta == nil {
instance.Meta = make(map[string]interface{}) instance.Meta = make(map[string]interface{})
} }
instance.Meta[TimeoutKey] = m instance.Meta[TimeoutKey] = m
case *terraform.InstanceState: case *opentf.InstanceState:
if instance.Meta == nil { if instance.Meta == nil {
instance.Meta = make(map[string]interface{}) instance.Meta = make(map[string]interface{})
} }
@ -215,10 +215,10 @@ func (t *ResourceTimeout) metaEncode(ids interface{}) error {
return nil return nil
} }
func (t *ResourceTimeout) StateDecode(id *terraform.InstanceState) error { func (t *ResourceTimeout) StateDecode(id *opentf.InstanceState) error {
return t.metaDecode(id) return t.metaDecode(id)
} }
func (t *ResourceTimeout) DiffDecode(is *terraform.InstanceDiff) error { func (t *ResourceTimeout) DiffDecode(is *opentf.InstanceDiff) error {
return t.metaDecode(is) return t.metaDecode(is)
} }
@ -226,12 +226,12 @@ func (t *ResourceTimeout) metaDecode(ids interface{}) error {
var rawMeta interface{} var rawMeta interface{}
var ok bool var ok bool
switch rawInstance := ids.(type) { switch rawInstance := ids.(type) {
case *terraform.InstanceDiff: case *opentf.InstanceDiff:
rawMeta, ok = rawInstance.Meta[TimeoutKey] rawMeta, ok = rawInstance.Meta[TimeoutKey]
if !ok { if !ok {
return nil return nil
} }
case *terraform.InstanceState: case *opentf.InstanceState:
rawMeta, ok = rawInstance.Meta[TimeoutKey] rawMeta, ok = rawInstance.Meta[TimeoutKey]
if !ok { if !ok {
return nil return nil

View File

@ -9,7 +9,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
func TestResourceTimeout_ConfigDecode_badkey(t *testing.T) { func TestResourceTimeout_ConfigDecode_badkey(t *testing.T) {
@ -62,7 +62,7 @@ func TestResourceTimeout_ConfigDecode_badkey(t *testing.T) {
Timeouts: c.ResourceDefaultTimeout, Timeouts: c.ResourceDefaultTimeout,
} }
conf := terraform.NewResourceConfigRaw( conf := opentf.NewResourceConfigRaw(
map[string]interface{}{ map[string]interface{}{
"foo": "bar", "foo": "bar",
TimeoutsConfigKey: c.Config, TimeoutsConfigKey: c.Config,
@ -99,7 +99,7 @@ func TestResourceTimeout_ConfigDecode(t *testing.T) {
}, },
} }
c := terraform.NewResourceConfigRaw( c := opentf.NewResourceConfigRaw(
map[string]interface{}{ map[string]interface{}{
"foo": "bar", "foo": "bar",
TimeoutsConfigKey: map[string]interface{}{ TimeoutsConfigKey: map[string]interface{}{
@ -133,7 +133,7 @@ func TestResourceTimeout_legacyConfigDecode(t *testing.T) {
}, },
} }
c := terraform.NewResourceConfigRaw( c := opentf.NewResourceConfigRaw(
map[string]interface{}{ map[string]interface{}{
"foo": "bar", "foo": "bar",
TimeoutsConfigKey: []interface{}{ TimeoutsConfigKey: []interface{}{
@ -195,7 +195,7 @@ func TestResourceTimeout_DiffEncode_basic(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
state := &terraform.InstanceDiff{} state := &opentf.InstanceDiff{}
err := c.Timeout.DiffEncode(state) err := c.Timeout.DiffEncode(state)
if err != nil && !c.ShouldErr { if err != nil && !c.ShouldErr {
t.Fatalf("Error, expected:\n%#v\n got:\n%#v\n", c.Expected, state.Meta) t.Fatalf("Error, expected:\n%#v\n got:\n%#v\n", c.Expected, state.Meta)
@ -209,7 +209,7 @@ func TestResourceTimeout_DiffEncode_basic(t *testing.T) {
} }
// same test cases but for InstanceState // same test cases but for InstanceState
for _, c := range cases { for _, c := range cases {
state := &terraform.InstanceState{} state := &opentf.InstanceState{}
err := c.Timeout.StateEncode(state) err := c.Timeout.StateEncode(state)
if err != nil && !c.ShouldErr { if err != nil && !c.ShouldErr {
t.Fatalf("Error, expected:\n%#v\n got:\n%#v\n", c.Expected, state.Meta) t.Fatalf("Error, expected:\n%#v\n got:\n%#v\n", c.Expected, state.Meta)
@ -225,32 +225,32 @@ func TestResourceTimeout_DiffEncode_basic(t *testing.T) {
func TestResourceTimeout_MetaDecode_basic(t *testing.T) { func TestResourceTimeout_MetaDecode_basic(t *testing.T) {
cases := []struct { cases := []struct {
State *terraform.InstanceDiff State *opentf.InstanceDiff
Expected *ResourceTimeout Expected *ResourceTimeout
// Not immediately clear when an error would hit // Not immediately clear when an error would hit
ShouldErr bool ShouldErr bool
}{ }{
// Two fields // Two fields
{ {
State: &terraform.InstanceDiff{Meta: map[string]interface{}{TimeoutKey: expectedForValues(10, 0, 5, 0, 0)}}, State: &opentf.InstanceDiff{Meta: map[string]interface{}{TimeoutKey: expectedForValues(10, 0, 5, 0, 0)}},
Expected: timeoutForValues(10, 0, 5, 0, 0), Expected: timeoutForValues(10, 0, 5, 0, 0),
ShouldErr: false, ShouldErr: false,
}, },
// Two fields, one is Default // Two fields, one is Default
{ {
State: &terraform.InstanceDiff{Meta: map[string]interface{}{TimeoutKey: expectedForValues(10, 0, 0, 0, 7)}}, State: &opentf.InstanceDiff{Meta: map[string]interface{}{TimeoutKey: expectedForValues(10, 0, 0, 0, 7)}},
Expected: timeoutForValues(10, 7, 7, 7, 7), Expected: timeoutForValues(10, 7, 7, 7, 7),
ShouldErr: false, ShouldErr: false,
}, },
// All fields // All fields
{ {
State: &terraform.InstanceDiff{Meta: map[string]interface{}{TimeoutKey: expectedForValues(10, 3, 4, 1, 7)}}, State: &opentf.InstanceDiff{Meta: map[string]interface{}{TimeoutKey: expectedForValues(10, 3, 4, 1, 7)}},
Expected: timeoutForValues(10, 3, 4, 1, 7), Expected: timeoutForValues(10, 3, 4, 1, 7),
ShouldErr: false, ShouldErr: false,
}, },
// No fields // No fields
{ {
State: &terraform.InstanceDiff{}, State: &opentf.InstanceDiff{},
Expected: &ResourceTimeout{}, Expected: &ResourceTimeout{},
ShouldErr: false, ShouldErr: false,
}, },

View File

@ -28,7 +28,7 @@ import (
"github.com/mitchellh/copystructure" "github.com/mitchellh/copystructure"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/hcl2shim" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/hcl2shim"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
// Name of ENV variable which (if not empty) prefers panic over error // Name of ENV variable which (if not empty) prefers panic over error
@ -360,7 +360,7 @@ func (s *Schema) ZeroValue() interface{} {
} }
} }
func (s *Schema) finalizeDiff(d *terraform.ResourceAttrDiff, customized bool) *terraform.ResourceAttrDiff { func (s *Schema) finalizeDiff(d *opentf.ResourceAttrDiff, customized bool) *opentf.ResourceAttrDiff {
if d == nil { if d == nil {
return d return d
} }
@ -447,8 +447,8 @@ func (m schemaMap) panicOnError() bool {
// //
// The diff is optional. // The diff is optional.
func (m schemaMap) Data( func (m schemaMap) Data(
s *terraform.InstanceState, s *opentf.InstanceState,
d *terraform.InstanceDiff) (*ResourceData, error) { d *opentf.InstanceDiff) (*ResourceData, error) {
return &ResourceData{ return &ResourceData{
schema: m, schema: m,
state: s, state: s,
@ -470,13 +470,13 @@ func (m *schemaMap) DeepCopy() schemaMap {
// Diff returns the diff for a resource given the schema map, // Diff returns the diff for a resource given the schema map,
// state, and configuration. // state, and configuration.
func (m schemaMap) Diff( func (m schemaMap) Diff(
s *terraform.InstanceState, s *opentf.InstanceState,
c *terraform.ResourceConfig, c *opentf.ResourceConfig,
customizeDiff CustomizeDiffFunc, customizeDiff CustomizeDiffFunc,
meta interface{}, meta interface{},
handleRequiresNew bool) (*terraform.InstanceDiff, error) { handleRequiresNew bool) (*opentf.InstanceDiff, error) {
result := new(terraform.InstanceDiff) result := new(opentf.InstanceDiff)
result.Attributes = make(map[string]*terraform.ResourceAttrDiff) result.Attributes = make(map[string]*opentf.ResourceAttrDiff)
// Make sure to mark if the resource is tainted // Make sure to mark if the resource is tainted
if s != nil { if s != nil {
@ -527,8 +527,8 @@ func (m schemaMap) Diff(
// caused that. // caused that.
if result.RequiresNew() { if result.RequiresNew() {
// Create the new diff // Create the new diff
result2 := new(terraform.InstanceDiff) result2 := new(opentf.InstanceDiff)
result2.Attributes = make(map[string]*terraform.ResourceAttrDiff) result2.Attributes = make(map[string]*opentf.ResourceAttrDiff)
// Preserve the DestroyTainted flag // Preserve the DestroyTainted flag
result2.DestroyTainted = result.DestroyTainted result2.DestroyTainted = result.DestroyTainted
@ -613,11 +613,11 @@ func (m schemaMap) Diff(
return result, nil return result, nil
} }
// Input implements the terraform.ResourceProvider method by asking // Input implements the opentf.ResourceProvider method by asking
// for input for required configuration keys that don't have a value. // for input for required configuration keys that don't have a value.
func (m schemaMap) Input( func (m schemaMap) Input(
input terraform.UIInput, input opentf.UIInput,
c *terraform.ResourceConfig) (*terraform.ResourceConfig, error) { c *opentf.ResourceConfig) (*opentf.ResourceConfig, error) {
keys := make([]string, 0, len(m)) keys := make([]string, 0, len(m))
for k, _ := range m { for k, _ := range m {
keys = append(keys, k) keys = append(keys, k)
@ -676,7 +676,7 @@ func (m schemaMap) Input(
} }
// Validate validates the configuration against this schema mapping. // Validate validates the configuration against this schema mapping.
func (m schemaMap) Validate(c *terraform.ResourceConfig) ([]string, []error) { func (m schemaMap) Validate(c *opentf.ResourceConfig) ([]string, []error) {
return m.validateObject("", m, c) return m.validateObject("", m, c)
} }
@ -868,12 +868,12 @@ type resourceDiffer interface {
func (m schemaMap) diff( func (m schemaMap) diff(
k string, k string,
schema *Schema, schema *Schema,
diff *terraform.InstanceDiff, diff *opentf.InstanceDiff,
d resourceDiffer, d resourceDiffer,
all bool) error { all bool) error {
unsupressedDiff := new(terraform.InstanceDiff) unsupressedDiff := new(opentf.InstanceDiff)
unsupressedDiff.Attributes = make(map[string]*terraform.ResourceAttrDiff) unsupressedDiff.Attributes = make(map[string]*opentf.ResourceAttrDiff)
var err error var err error
switch schema.Type { switch schema.Type {
@ -901,7 +901,7 @@ func (m schemaMap) diff(
continue continue
} }
attrV = &terraform.ResourceAttrDiff{ attrV = &opentf.ResourceAttrDiff{
Old: attrV.Old, Old: attrV.Old,
New: attrV.Old, New: attrV.Old,
} }
@ -916,7 +916,7 @@ func (m schemaMap) diff(
func (m schemaMap) diffList( func (m schemaMap) diffList(
k string, k string,
schema *Schema, schema *Schema,
diff *terraform.InstanceDiff, diff *opentf.InstanceDiff,
d resourceDiffer, d resourceDiffer,
all bool) error { all bool) error {
o, n, _, computedList, customized := d.diffChange(k) o, n, _, computedList, customized := d.diffChange(k)
@ -961,7 +961,7 @@ func (m schemaMap) diffList(
// If the whole list is computed, then say that the # is computed // If the whole list is computed, then say that the # is computed
if computedList { if computedList {
diff.Attributes[k+".#"] = &terraform.ResourceAttrDiff{ diff.Attributes[k+".#"] = &opentf.ResourceAttrDiff{
Old: oldStr, Old: oldStr,
NewComputed: true, NewComputed: true,
RequiresNew: schema.ForceNew, RequiresNew: schema.ForceNew,
@ -987,7 +987,7 @@ func (m schemaMap) diffList(
} }
diff.Attributes[k+".#"] = countSchema.finalizeDiff( diff.Attributes[k+".#"] = countSchema.finalizeDiff(
&terraform.ResourceAttrDiff{ &opentf.ResourceAttrDiff{
Old: oldStr, Old: oldStr,
New: newStr, New: newStr,
}, },
@ -1038,7 +1038,7 @@ func (m schemaMap) diffList(
func (m schemaMap) diffMap( func (m schemaMap) diffMap(
k string, k string,
schema *Schema, schema *Schema,
diff *terraform.InstanceDiff, diff *opentf.InstanceDiff,
d resourceDiffer, d resourceDiffer,
all bool) error { all bool) error {
prefix := k + "." prefix := k + "."
@ -1093,7 +1093,7 @@ func (m schemaMap) diffMap(
} }
diff.Attributes[k+".%"] = countSchema.finalizeDiff( diff.Attributes[k+".%"] = countSchema.finalizeDiff(
&terraform.ResourceAttrDiff{ &opentf.ResourceAttrDiff{
Old: oldStr, Old: oldStr,
New: newStr, New: newStr,
}, },
@ -1116,7 +1116,7 @@ func (m schemaMap) diffMap(
} }
diff.Attributes[prefix+k] = schema.finalizeDiff( diff.Attributes[prefix+k] = schema.finalizeDiff(
&terraform.ResourceAttrDiff{ &opentf.ResourceAttrDiff{
Old: old, Old: old,
New: v, New: v,
}, },
@ -1125,7 +1125,7 @@ func (m schemaMap) diffMap(
} }
for k, v := range stateMap { for k, v := range stateMap {
diff.Attributes[prefix+k] = schema.finalizeDiff( diff.Attributes[prefix+k] = schema.finalizeDiff(
&terraform.ResourceAttrDiff{ &opentf.ResourceAttrDiff{
Old: v, Old: v,
NewRemoved: true, NewRemoved: true,
}, },
@ -1139,7 +1139,7 @@ func (m schemaMap) diffMap(
func (m schemaMap) diffSet( func (m schemaMap) diffSet(
k string, k string,
schema *Schema, schema *Schema,
diff *terraform.InstanceDiff, diff *opentf.InstanceDiff,
d resourceDiffer, d resourceDiffer,
all bool) error { all bool) error {
@ -1203,7 +1203,7 @@ func (m schemaMap) diffSet(
} }
diff.Attributes[k+".#"] = countSchema.finalizeDiff( diff.Attributes[k+".#"] = countSchema.finalizeDiff(
&terraform.ResourceAttrDiff{ &opentf.ResourceAttrDiff{
Old: countStr, Old: countStr,
NewComputed: true, NewComputed: true,
}, },
@ -1216,7 +1216,7 @@ func (m schemaMap) diffSet(
changed := oldLen != newLen changed := oldLen != newLen
if changed || all { if changed || all {
diff.Attributes[k+".#"] = countSchema.finalizeDiff( diff.Attributes[k+".#"] = countSchema.finalizeDiff(
&terraform.ResourceAttrDiff{ &opentf.ResourceAttrDiff{
Old: oldStr, Old: oldStr,
New: newStr, New: newStr,
}, },
@ -1266,7 +1266,7 @@ func (m schemaMap) diffSet(
func (m schemaMap) diffString( func (m schemaMap) diffString(
k string, k string,
schema *Schema, schema *Schema,
diff *terraform.InstanceDiff, diff *opentf.InstanceDiff,
d resourceDiffer, d resourceDiffer,
all bool) error { all bool) error {
var originalN interface{} var originalN interface{}
@ -1309,7 +1309,7 @@ func (m schemaMap) diffString(
} }
diff.Attributes[k] = schema.finalizeDiff( diff.Attributes[k] = schema.finalizeDiff(
&terraform.ResourceAttrDiff{ &opentf.ResourceAttrDiff{
Old: os, Old: os,
New: ns, New: ns,
NewExtra: originalN, NewExtra: originalN,
@ -1323,10 +1323,10 @@ func (m schemaMap) diffString(
} }
func (m schemaMap) inputString( func (m schemaMap) inputString(
input terraform.UIInput, input opentf.UIInput,
k string, k string,
schema *Schema) (interface{}, error) { schema *Schema) (interface{}, error) {
result, err := input.Input(context.Background(), &terraform.InputOpts{ result, err := input.Input(context.Background(), &opentf.InputOpts{
Id: k, Id: k,
Query: k, Query: k,
Description: schema.Description, Description: schema.Description,
@ -1339,7 +1339,7 @@ func (m schemaMap) inputString(
func (m schemaMap) validate( func (m schemaMap) validate(
k string, k string,
schema *Schema, schema *Schema,
c *terraform.ResourceConfig) ([]string, []error) { c *opentf.ResourceConfig) ([]string, []error) {
raw, ok := c.Get(k) raw, ok := c.Get(k)
if !ok && schema.DefaultFunc != nil { if !ok && schema.DefaultFunc != nil {
// We have a dynamic default. Check if we have a value. // We have a dynamic default. Check if we have a value.
@ -1413,7 +1413,7 @@ func isWhollyKnown(raw interface{}) bool {
func (m schemaMap) validateConflictingAttributes( func (m schemaMap) validateConflictingAttributes(
k string, k string,
schema *Schema, schema *Schema,
c *terraform.ResourceConfig) error { c *opentf.ResourceConfig) error {
if len(schema.ConflictsWith) == 0 { if len(schema.ConflictsWith) == 0 {
return nil return nil
@ -1438,7 +1438,7 @@ func (m schemaMap) validateList(
k string, k string,
raw interface{}, raw interface{},
schema *Schema, schema *Schema,
c *terraform.ResourceConfig) ([]string, []error) { c *opentf.ResourceConfig) ([]string, []error) {
// first check if the list is wholly unknown // first check if the list is wholly unknown
if s, ok := raw.(string); ok { if s, ok := raw.(string); ok {
if s == hcl2shim.UnknownVariableValue { if s == hcl2shim.UnknownVariableValue {
@ -1530,7 +1530,7 @@ func (m schemaMap) validateMap(
k string, k string,
raw interface{}, raw interface{},
schema *Schema, schema *Schema,
c *terraform.ResourceConfig) ([]string, []error) { c *opentf.ResourceConfig) ([]string, []error) {
// first check if the list is wholly unknown // first check if the list is wholly unknown
if s, ok := raw.(string); ok { if s, ok := raw.(string); ok {
if s == hcl2shim.UnknownVariableValue { if s == hcl2shim.UnknownVariableValue {
@ -1666,7 +1666,7 @@ func getValueType(k string, schema *Schema) (ValueType, error) {
func (m schemaMap) validateObject( func (m schemaMap) validateObject(
k string, k string,
schema map[string]*Schema, schema map[string]*Schema,
c *terraform.ResourceConfig) ([]string, []error) { c *opentf.ResourceConfig) ([]string, []error) {
raw, _ := c.Get(k) raw, _ := c.Get(k)
// schemaMap can't validate nil // schemaMap can't validate nil
@ -1717,7 +1717,7 @@ func (m schemaMap) validatePrimitive(
k string, k string,
raw interface{}, raw interface{},
schema *Schema, schema *Schema,
c *terraform.ResourceConfig) ([]string, []error) { c *opentf.ResourceConfig) ([]string, []error) {
// a nil value shouldn't happen in the old protocol, and in the new // a nil value shouldn't happen in the old protocol, and in the new
// protocol the types have already been validated. Either way, we can't // protocol the types have already been validated. Either way, we can't
@ -1805,7 +1805,7 @@ func (m schemaMap) validateType(
k string, k string,
raw interface{}, raw interface{},
schema *Schema, schema *Schema,
c *terraform.ResourceConfig) ([]string, []error) { c *opentf.ResourceConfig) ([]string, []error) {
var ws []string var ws []string
var es []error var es []error
switch schema.Type { switch schema.Type {

File diff suppressed because it is too large Load Diff

View File

@ -11,14 +11,14 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema"
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/hcl2shim" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/hcl2shim"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
// DiffFromValues takes the current state and desired state as cty.Values and // DiffFromValues takes the current state and desired state as cty.Values and
// derives a terraform.InstanceDiff to give to the legacy providers. This is // derives a opentf.InstanceDiff to give to the legacy providers. This is
// used to take the states provided by the new ApplyResourceChange method and // used to take the states provided by the new ApplyResourceChange method and
// convert them to a state+diff required for the legacy Apply method. // convert them to a state+diff required for the legacy Apply method.
func DiffFromValues(prior, planned cty.Value, res *Resource) (*terraform.InstanceDiff, error) { func DiffFromValues(prior, planned cty.Value, res *Resource) (*opentf.InstanceDiff, error) {
return diffFromValues(prior, planned, res, nil) return diffFromValues(prior, planned, res, nil)
} }
@ -26,7 +26,7 @@ func DiffFromValues(prior, planned cty.Value, res *Resource) (*terraform.Instanc
// test fixtures from the legacy tests. In the new provider protocol the diff // test fixtures from the legacy tests. In the new provider protocol the diff
// only needs to be created for the apply operation, and any customizations // only needs to be created for the apply operation, and any customizations
// have already been done. // have already been done.
func diffFromValues(prior, planned cty.Value, res *Resource, cust CustomizeDiffFunc) (*terraform.InstanceDiff, error) { func diffFromValues(prior, planned cty.Value, res *Resource, cust CustomizeDiffFunc) (*opentf.InstanceDiff, error) {
instanceState, err := res.ShimInstanceStateFromValue(prior) instanceState, err := res.ShimInstanceStateFromValue(prior)
if err != nil { if err != nil {
return nil, err return nil, err
@ -34,7 +34,7 @@ func diffFromValues(prior, planned cty.Value, res *Resource, cust CustomizeDiffF
configSchema := res.CoreConfigSchema() configSchema := res.CoreConfigSchema()
cfg := terraform.NewResourceConfigShimmed(planned, configSchema) cfg := opentf.NewResourceConfigShimmed(planned, configSchema)
removeConfigUnknowns(cfg.Config) removeConfigUnknowns(cfg.Config)
removeConfigUnknowns(cfg.Raw) removeConfigUnknowns(cfg.Raw)
@ -68,11 +68,11 @@ func removeConfigUnknowns(cfg map[string]interface{}) {
} }
} }
// ApplyDiff takes a cty.Value state and applies a terraform.InstanceDiff to // ApplyDiff takes a cty.Value state and applies a opentf.InstanceDiff to
// get a new cty.Value state. This is used to convert the diff returned from // get a new cty.Value state. This is used to convert the diff returned from
// the legacy provider Diff method to the state required for the new // the legacy provider Diff method to the state required for the new
// PlanResourceChange method. // PlanResourceChange method.
func ApplyDiff(base cty.Value, d *terraform.InstanceDiff, schema *configschema.Block) (cty.Value, error) { func ApplyDiff(base cty.Value, d *opentf.InstanceDiff, schema *configschema.Block) (cty.Value, error) {
return d.ApplyToValue(base, schema) return d.ApplyToValue(base, schema)
} }
@ -110,9 +110,9 @@ func JSONMapToStateValue(m map[string]interface{}, block *configschema.Block) (c
return block.CoerceValue(val) return block.CoerceValue(val)
} }
// StateValueFromInstanceState converts a terraform.InstanceState to a // StateValueFromInstanceState converts a opentf.InstanceState to a
// cty.Value as described by the provided cty.Type, and maintains the resource // cty.Value as described by the provided cty.Type, and maintains the resource
// ID as the "id" attribute. // ID as the "id" attribute.
func StateValueFromInstanceState(is *terraform.InstanceState, ty cty.Type) (cty.Value, error) { func StateValueFromInstanceState(is *opentf.InstanceState, ty cty.Type) (cty.Value, error) {
return is.AttrsAsObjectValue(ty) return is.AttrsAsObjectValue(ty)
} }

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ package schema
import ( import (
"testing" "testing"
"github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/terraform" "github.com/placeholderplaceholderplaceholder/opentf/internal/legacy/opentf"
) )
// TestResourceDataRaw creates a ResourceData from a raw configuration map. // TestResourceDataRaw creates a ResourceData from a raw configuration map.
@ -14,7 +14,7 @@ func TestResourceDataRaw(
t *testing.T, schema map[string]*Schema, raw map[string]interface{}) *ResourceData { t *testing.T, schema map[string]*Schema, raw map[string]interface{}) *ResourceData {
t.Helper() t.Helper()
c := terraform.NewResourceConfigRaw(raw) c := opentf.NewResourceConfigRaw(raw)
sm := schemaMap(schema) sm := schemaMap(schema)
diff, err := sm.Diff(nil, c, nil, nil, true) diff, err := sm.Diff(nil, c, nil, nil, true)

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"fmt" "fmt"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"bufio" "bufio"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"fmt" "fmt"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import "os" import "os"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
//go:generate go run golang.org/x/tools/cmd/stringer -type=InstanceType instancetype.go //go:generate go run golang.org/x/tools/cmd/stringer -type=InstanceType instancetype.go

View File

@ -1,6 +1,6 @@
// Code generated by "stringer -type=InstanceType instancetype.go"; DO NOT EDIT. // Code generated by "stringer -type=InstanceType instancetype.go"; DO NOT EDIT.
package terraform package opentf
import "strconv" import "strconv"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"encoding/json" "encoding/json"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"sync" "sync"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"fmt" "fmt"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"fmt" "fmt"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"fmt" "fmt"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
//go:generate go run golang.org/x/tools/cmd/stringer -type=ResourceMode -output=resource_mode_string.go resource_mode.go //go:generate go run golang.org/x/tools/cmd/stringer -type=ResourceMode -output=resource_mode_string.go resource_mode.go

View File

@ -1,6 +1,6 @@
// Code generated by "stringer -type=ResourceMode -output=resource_mode_string.go resource_mode.go"; DO NOT EDIT. // Code generated by "stringer -type=ResourceMode -output=resource_mode_string.go resource_mode.go"; DO NOT EDIT.
package terraform package opentf
import "strconv" import "strconv"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
// ResourceProvider is a legacy interface for providers. // ResourceProvider is a legacy interface for providers.
// //

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"sync" "sync"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema" "github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"sync" "sync"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"fmt" "fmt"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"fmt" "fmt"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"bufio" "bufio"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"fmt" "fmt"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"bytes" "bytes"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"fmt" "fmt"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"fmt" "fmt"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
// stateV1 keeps track of a snapshot state-of-the-world that Terraform // stateV1 keeps track of a snapshot state-of-the-world that Terraform
// can use to keep track of what real world resources it is actually // can use to keep track of what real world resources it is actually

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"os" "os"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import "context" import "context"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import "context" import "context"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"context" "context"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"context" "context"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
// UIOutput is the interface that must be implemented to output // UIOutput is the interface that must be implemented to output
// data to the end user. // data to the end user.

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
type CallbackUIOutput struct { type CallbackUIOutput struct {
OutputFn func(string) OutputFn func(string)

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"testing" "testing"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import "sync" import "sync"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"testing" "testing"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"bytes" "bytes"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"bytes" "bytes"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"sort" "sort"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"fmt" "fmt"

View File

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
package terraform package opentf
import ( import (
"github.com/placeholderplaceholderplaceholder/opentf/version" "github.com/placeholderplaceholderplaceholder/opentf/version"