Replace internal/terraform -> internal/opentf

This commit is contained in:
RLRabinowitz
2023-08-27 17:51:49 +03:00
parent 12e8eeaa09
commit 42e7c5b25c
828 changed files with 753 additions and 753 deletions

View File

@@ -19,7 +19,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configschema"
"github.com/placeholderplaceholderplaceholder/opentf/internal/logging"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statemgr"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terraform"
"github.com/placeholderplaceholderplaceholder/opentf/internal/opentf"
"github.com/placeholderplaceholderplaceholder/opentf/internal/tfdiags"
"github.com/zclconf/go-cty/cty"
)
@@ -68,7 +68,7 @@ type Local struct {
// OpenTF context. Many of these will be overridden or merged by
// Operation. See Operation for more details.
ContextOpts *terraform.ContextOpts
ContextOpts *opentf.ContextOpts
// OpInput will ask for necessary input prior to performing any operations.
//
@@ -270,7 +270,7 @@ func (b *Local) StateMgr(name string) (statemgr.Full, error) {
// Operation implements backend.Enhanced
//
// This will initialize an in-memory terraform.Context to perform the
// This will initialize an in-memory opentf.Context to perform the
// operation within this process.
//
// The given operation parameter will be merged with the ContextOpts on
@@ -340,7 +340,7 @@ func (b *Local) opWait(
doneCh <-chan struct{},
stopCtx context.Context,
cancelCtx context.Context,
tfCtx *terraform.Context,
tfCtx *opentf.Context,
opStateMgr statemgr.Persister,
view views.Operation) (canceled bool) {
// Wait for the operation to finish or for us to be interrupted so

View File

@@ -18,7 +18,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/states"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statefile"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statemgr"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terraform"
"github.com/placeholderplaceholderplaceholder/opentf/internal/opentf"
"github.com/placeholderplaceholderplaceholder/opentf/internal/tfdiags"
)
@@ -163,7 +163,7 @@ func (b *Local) opApply(
diags = nil // reset so we won't show the same diagnostics again later
}
v, err := op.UIIn.Input(stopCtx, &terraform.InputOpts{
v, err := op.UIIn.Input(stopCtx, &opentf.InputOpts{
Id: "approve",
Query: "\n" + query,
Description: desc,

View File

@@ -15,7 +15,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/configs/configload"
"github.com/placeholderplaceholderplaceholder/opentf/internal/plans/planfile"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statemgr"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terraform"
"github.com/placeholderplaceholderplaceholder/opentf/internal/opentf"
"github.com/placeholderplaceholderplaceholder/opentf/internal/tfdiags"
"github.com/zclconf/go-cty/cty"
)
@@ -68,7 +68,7 @@ func (b *Local) localRun(op *backend.Operation) (*backend.LocalRun, *configload.
ret := &backend.LocalRun{}
// Initialize our context options
var coreOpts terraform.ContextOpts
var coreOpts opentf.ContextOpts
if v := b.ContextOpts; v != nil {
coreOpts = *v
}
@@ -115,7 +115,7 @@ func (b *Local) localRun(op *backend.Operation) (*backend.LocalRun, *configload.
if op.Type != backend.OperationTypeInvalid {
// If input asking is enabled, then do that
if op.PlanFile == nil && b.OpInput {
mode := terraform.InputModeProvider
mode := opentf.InputModeProvider
log.Printf("[TRACE] backend/local: requesting interactive input, if necessary")
inputDiags := ret.Core.Input(ret.Config, mode)
@@ -136,7 +136,7 @@ func (b *Local) localRun(op *backend.Operation) (*backend.LocalRun, *configload.
return ret, configSnap, s, diags
}
func (b *Local) localRunDirect(op *backend.Operation, run *backend.LocalRun, coreOpts *terraform.ContextOpts, s statemgr.Full) (*backend.LocalRun, *configload.Snapshot, tfdiags.Diagnostics) {
func (b *Local) localRunDirect(op *backend.Operation, run *backend.LocalRun, coreOpts *opentf.ContextOpts, s statemgr.Full) (*backend.LocalRun, *configload.Snapshot, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
// Load the configuration using the caller-provided configuration loader.
@@ -194,7 +194,7 @@ func (b *Local) localRunDirect(op *backend.Operation, run *backend.LocalRun, cor
return nil, nil, diags
}
planOpts := &terraform.PlanOpts{
planOpts := &opentf.PlanOpts{
Mode: op.PlanMode,
Targets: op.Targets,
ForceReplace: op.ForceReplace,
@@ -208,7 +208,7 @@ func (b *Local) localRunDirect(op *backend.Operation, run *backend.LocalRun, cor
// snapshot, from the previous run.
run.InputState = s.State()
tfCtx, moreDiags := terraform.NewContext(coreOpts)
tfCtx, moreDiags := opentf.NewContext(coreOpts)
diags = diags.Append(moreDiags)
if moreDiags.HasErrors() {
return nil, nil, diags
@@ -217,7 +217,7 @@ func (b *Local) localRunDirect(op *backend.Operation, run *backend.LocalRun, cor
return run, configSnap, diags
}
func (b *Local) localRunForPlanFile(op *backend.Operation, pf *planfile.Reader, run *backend.LocalRun, coreOpts *terraform.ContextOpts, currentStateMeta *statemgr.SnapshotMeta) (*backend.LocalRun, *configload.Snapshot, tfdiags.Diagnostics) {
func (b *Local) localRunForPlanFile(op *backend.Operation, pf *planfile.Reader, run *backend.LocalRun, coreOpts *opentf.ContextOpts, currentStateMeta *statemgr.SnapshotMeta) (*backend.LocalRun, *configload.Snapshot, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
const errSummary = "Invalid plan file"
@@ -342,7 +342,7 @@ func (b *Local) localRunForPlanFile(op *backend.Operation, pf *planfile.Reader,
// we need to apply the plan.
run.Plan = plan
tfCtx, moreDiags := terraform.NewContext(coreOpts)
tfCtx, moreDiags := opentf.NewContext(coreOpts)
diags = diags.Append(moreDiags)
if moreDiags.HasErrors() {
return nil, nil, diags
@@ -371,7 +371,7 @@ func (b *Local) localRunForPlanFile(op *backend.Operation, pf *planfile.Reader,
// messages that variables are not set rather than reporting that input failed:
// the primary resolution to missing variables is to provide them by some other
// means.
func (b *Local) interactiveCollectVariables(ctx context.Context, existing map[string]backend.UnparsedVariableValue, vcs map[string]*configs.Variable, uiInput terraform.UIInput) map[string]backend.UnparsedVariableValue {
func (b *Local) interactiveCollectVariables(ctx context.Context, existing map[string]backend.UnparsedVariableValue, vcs map[string]*configs.Variable, uiInput opentf.UIInput) map[string]backend.UnparsedVariableValue {
var needed []string
if b.OpInput && uiInput != nil {
for name, vc := range vcs {
@@ -400,7 +400,7 @@ func (b *Local) interactiveCollectVariables(ctx context.Context, existing map[st
}
for _, name := range needed {
vc := vcs[name]
rawValue, err := uiInput.Input(ctx, &terraform.InputOpts{
rawValue, err := uiInput.Input(ctx, &opentf.InputOpts{
Id: fmt.Sprintf("var.%s", name),
Query: fmt.Sprintf("var.%s", name),
Description: vc.Description,
@@ -478,16 +478,16 @@ type unparsedInteractiveVariableValue struct {
var _ backend.UnparsedVariableValue = unparsedInteractiveVariableValue{}
func (v unparsedInteractiveVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*terraform.InputValue, tfdiags.Diagnostics) {
func (v unparsedInteractiveVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
val, valDiags := mode.Parse(v.Name, v.RawValue)
diags = diags.Append(valDiags)
if diags.HasErrors() {
return nil, diags
}
return &terraform.InputValue{
return &opentf.InputValue{
Value: val,
SourceType: terraform.ValueFromInput,
SourceType: opentf.ValueFromInput,
}, diags
}
@@ -498,9 +498,9 @@ type unparsedUnknownVariableValue struct {
var _ backend.UnparsedVariableValue = unparsedUnknownVariableValue{}
func (v unparsedUnknownVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*terraform.InputValue, tfdiags.Diagnostics) {
return &terraform.InputValue{
func (v unparsedUnknownVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics) {
return &opentf.InputValue{
Value: cty.UnknownVal(v.WantType),
SourceType: terraform.ValueFromInput,
SourceType: opentf.ValueFromInput,
}, nil
}

View File

@@ -24,7 +24,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statefile"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statemgr"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terminal"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terraform"
"github.com/placeholderplaceholderplaceholder/opentf/internal/opentf"
"github.com/placeholderplaceholderplaceholder/opentf/internal/tfdiags"
)
@@ -272,6 +272,6 @@ func (s *stateStorageThatFailsRefresh) RefreshState() error {
return fmt.Errorf("intentionally failing for testing purposes")
}
func (s *stateStorageThatFailsRefresh) PersistState(schemas *terraform.Schemas) error {
func (s *stateStorageThatFailsRefresh) PersistState(schemas *opentf.Schemas) error {
return fmt.Errorf("unimplemented")
}

View File

@@ -16,7 +16,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/plans/planfile"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statefile"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statemgr"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terraform"
"github.com/placeholderplaceholderplaceholder/opentf/internal/opentf"
"github.com/placeholderplaceholderplaceholder/opentf/internal/tfdiags"
)
@@ -73,7 +73,7 @@ func (b *Local) opPlan(
}
if b.ContextOpts == nil {
b.ContextOpts = new(terraform.ContextOpts)
b.ContextOpts = new(opentf.ContextOpts)
}
// Get our context

View File

@@ -25,7 +25,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/providers"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terminal"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terraform"
"github.com/placeholderplaceholderplaceholder/opentf/internal/opentf"
)
func TestLocal_planBasic(t *testing.T) {
@@ -133,7 +133,7 @@ func TestLocal_plan_context_error(t *testing.T) {
// to test that we properly unlock the state if terraform.NewContext
// returns an error.
if b.ContextOpts == nil {
b.ContextOpts = &terraform.ContextOpts{}
b.ContextOpts = &opentf.ContextOpts{}
}
b.ContextOpts.Parallelism = -1

View File

@@ -20,7 +20,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/providers"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terminal"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terraform"
"github.com/placeholderplaceholderplaceholder/opentf/internal/opentf"
"github.com/zclconf/go-cty/cty"
)
@@ -102,7 +102,7 @@ func TestLocal_refreshInput(t *testing.T) {
// Enable input asking since it is normally disabled by default
b.OpInput = true
b.ContextOpts.UIInput = &terraform.MockUIInput{InputReturnString: "bar"}
b.ContextOpts.UIInput = &opentf.MockUIInput{InputReturnString: "bar"}
op, configCleanup, done := testOperationRefresh(t, "./testdata/refresh-var-unset")
defer configCleanup()

View File

@@ -10,13 +10,13 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/states"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statemgr"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terraform"
"github.com/placeholderplaceholderplaceholder/opentf/internal/opentf"
)
// StateHook is a hook that continuously updates the state by calling
// WriteState on a statemgr.Full.
type StateHook struct {
terraform.NilHook
opentf.NilHook
sync.Mutex
StateMgr statemgr.Writer
@@ -31,7 +31,7 @@ type StateHook struct {
// Schemas are the schemas to use when persisting state due to
// PersistInterval. This is ignored if PersistInterval is zero,
// and PersistInterval is ignored if this is nil.
Schemas *terraform.Schemas
Schemas *opentf.Schemas
intermediatePersist IntermediateStatePersistInfo
}
@@ -59,9 +59,9 @@ type IntermediateStatePersistInfo struct {
ForcePersist bool
}
var _ terraform.Hook = (*StateHook)(nil)
var _ opentf.Hook = (*StateHook)(nil)
func (h *StateHook) PostStateUpdate(new *states.State) (terraform.HookAction, error) {
func (h *StateHook) PostStateUpdate(new *states.State) (opentf.HookAction, error) {
h.Lock()
defer h.Unlock()
@@ -75,13 +75,13 @@ func (h *StateHook) PostStateUpdate(new *states.State) (terraform.HookAction, er
if h.StateMgr != nil {
if err := h.StateMgr.WriteState(new); err != nil {
return terraform.HookActionHalt, err
return opentf.HookActionHalt, err
}
if mgrPersist, ok := h.StateMgr.(statemgr.Persister); ok && h.PersistInterval != 0 && h.Schemas != nil {
if h.shouldPersist() {
err := mgrPersist.PersistState(h.Schemas)
if err != nil {
return terraform.HookActionHalt, err
return opentf.HookActionHalt, err
}
h.intermediatePersist.LastPersist = time.Now()
} else {
@@ -90,7 +90,7 @@ func (h *StateHook) PostStateUpdate(new *states.State) (terraform.HookAction, er
}
}
return terraform.HookActionContinue, nil
return opentf.HookActionContinue, nil
}
func (h *StateHook) Stopping() {

View File

@@ -11,23 +11,23 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statemgr"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terraform"
"github.com/placeholderplaceholderplaceholder/opentf/internal/opentf"
)
func TestStateHook_impl(t *testing.T) {
var _ terraform.Hook = new(StateHook)
var _ opentf.Hook = new(StateHook)
}
func TestStateHook(t *testing.T) {
is := statemgr.NewTransientInMemory(nil)
var hook terraform.Hook = &StateHook{StateMgr: is}
var hook opentf.Hook = &StateHook{StateMgr: is}
s := statemgr.TestFullInitialState()
action, err := hook.PostStateUpdate(s)
if err != nil {
t.Fatalf("err: %s", err)
}
if action != terraform.HookActionContinue {
if action != opentf.HookActionContinue {
t.Fatalf("bad: %v", action)
}
if !is.State().Equal(s) {
@@ -39,7 +39,7 @@ func TestStateHookStopping(t *testing.T) {
is := &testPersistentState{}
hook := &StateHook{
StateMgr: is,
Schemas: &terraform.Schemas{},
Schemas: &opentf.Schemas{},
PersistInterval: 4 * time.Hour,
intermediatePersist: IntermediateStatePersistInfo{
LastPersist: time.Now(),
@@ -51,7 +51,7 @@ func TestStateHookStopping(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error from PostStateUpdate: %s", err)
}
if got, want := action, terraform.HookActionContinue; got != want {
if got, want := action, opentf.HookActionContinue; got != want {
t.Fatalf("wrong hookaction %#v; want %#v", got, want)
}
if is.Written == nil || !is.Written.Equal(s) {
@@ -138,7 +138,7 @@ func TestStateHookCustomPersistRule(t *testing.T) {
is := &testPersistentStateThatRefusesToPersist{}
hook := &StateHook{
StateMgr: is,
Schemas: &terraform.Schemas{},
Schemas: &opentf.Schemas{},
PersistInterval: 4 * time.Hour,
intermediatePersist: IntermediateStatePersistInfo{
LastPersist: time.Now(),
@@ -150,7 +150,7 @@ func TestStateHookCustomPersistRule(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error from PostStateUpdate: %s", err)
}
if got, want := action, terraform.HookActionContinue; got != want {
if got, want := action, opentf.HookActionContinue; got != want {
t.Fatalf("wrong hookaction %#v; want %#v", got, want)
}
if is.Written == nil || !is.Written.Equal(s) {
@@ -255,7 +255,7 @@ func (sm *testPersistentState) WriteState(state *states.State) error {
return nil
}
func (sm *testPersistentState) PersistState(schemas *terraform.Schemas) error {
func (sm *testPersistentState) PersistState(schemas *opentf.Schemas) error {
if schemas == nil {
return fmt.Errorf("no schemas")
}
@@ -281,7 +281,7 @@ func (sm *testPersistentStateThatRefusesToPersist) WriteState(state *states.Stat
return nil
}
func (sm *testPersistentStateThatRefusesToPersist) PersistState(schemas *terraform.Schemas) error {
func (sm *testPersistentStateThatRefusesToPersist) PersistState(schemas *opentf.Schemas) error {
if schemas == nil {
return fmt.Errorf("no schemas")
}

View File

@@ -15,7 +15,7 @@ import (
"github.com/placeholderplaceholderplaceholder/opentf/internal/providers"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states"
"github.com/placeholderplaceholderplaceholder/opentf/internal/states/statemgr"
"github.com/placeholderplaceholderplaceholder/opentf/internal/terraform"
"github.com/placeholderplaceholderplaceholder/opentf/internal/opentf"
)
// TestLocal returns a configured Local struct with temporary paths and
@@ -35,16 +35,16 @@ func TestLocal(t *testing.T) *Local {
local.StateOutPath = filepath.Join(tempDir, "state.tfstate")
local.StateBackupPath = filepath.Join(tempDir, "state.tfstate.bak")
local.StateWorkspaceDir = filepath.Join(tempDir, "state.tfstate.d")
local.ContextOpts = &terraform.ContextOpts{}
local.ContextOpts = &opentf.ContextOpts{}
return local
}
// TestLocalProvider modifies the ContextOpts of the *Local parameter to
// have a provider with the given name.
func TestLocalProvider(t *testing.T, b *Local, name string, schema providers.ProviderSchema) *terraform.MockProvider {
func TestLocalProvider(t *testing.T, b *Local, name string, schema providers.ProviderSchema) *opentf.MockProvider {
// Build a mock resource provider for in-memory operations
p := new(terraform.MockProvider)
p := new(opentf.MockProvider)
p.GetProviderSchemaResponse = &schema
@@ -89,7 +89,7 @@ func TestLocalProvider(t *testing.T, b *Local, name string, schema providers.Pro
// Initialize the opts
if b.ContextOpts == nil {
b.ContextOpts = &terraform.ContextOpts{}
b.ContextOpts = &opentf.ContextOpts{}
}
// Set up our provider