Rename opentf package to tofu (#466)

This commit is contained in:
Yaron Yarimi 2023-09-20 15:16:53 +03:00 committed by GitHub
parent b524b2bdbe
commit 794e3413bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
830 changed files with 774 additions and 774 deletions

View File

@ -96,7 +96,7 @@ jobs:
# it for select packages.
- name: "Race detector"
run: |
go test -race ./internal/opentf ./internal/command ./internal/states
go test -race ./internal/tofu ./internal/command ./internal/states
e2e-tests:
# This is an intentionally-limited form of our E2E test run which only

View File

@ -22,12 +22,12 @@ import (
"github.com/opentofu/opentofu/internal/configs/configload"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/depsfile"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/plans/planfile"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/zclconf/go-cty/cty"
)
@ -173,7 +173,7 @@ type Local interface {
// calculate from an Operation object, which we can then use for local
// operations.
//
// The operation methods on opentf.Context (Plan, Apply, Import, etc) each
// The operation methods on tofu.Context (Plan, Apply, Import, etc) each
// generate new artifacts which supersede parts of the LocalRun object that
// started the operation, so callers should be careful to use those subsequent
// artifacts instead of the fields of LocalRun where appropriate. The LocalRun
@ -189,7 +189,7 @@ type Local interface {
type LocalRun struct {
// Core is an already-initialized OpenTF Core context, ready to be
// used to run operations such as Plan and Apply.
Core *opentf.Context
Core *tofu.Context
// Config is the configuration we're working with, which typically comes
// from either config files directly on local disk (when we're creating
@ -207,7 +207,7 @@ type LocalRun struct {
//
// This is nil when we're applying a saved plan, because the plan itself
// contains enough information about its options to apply it.
PlanOpts *opentf.PlanOpts
PlanOpts *tofu.PlanOpts
// Plan is a plan loaded from a saved plan file, if our operation is to
// apply that saved plan.
@ -265,7 +265,7 @@ type Operation struct {
// Hooks can be used to perform actions triggered by various events during
// the operation's lifecycle.
Hooks []opentf.Hook
Hooks []tofu.Hook
// Plan is a plan that was passed as an argument. This is valid for
// plan and apply arguments but may not work for all backends.
@ -293,8 +293,8 @@ type Operation struct {
View views.Operation
// Input/output/control options.
UIIn opentf.UIInput
UIOut opentf.UIOutput
UIIn tofu.UIInput
UIOut tofu.UIOutput
// StateLocker is used to lock the state while providing UI feedback to the
// user. This will be replaced by the Backend to update the context.

View File

@ -7,8 +7,8 @@ import (
"github.com/mitchellh/cli"
"github.com/mitchellh/colorstring"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
)
// CLI is an optional interface that can be implemented to be initialized
@ -73,7 +73,7 @@ type CLIOpts struct {
// ContextOpts are the base context options to set when initializing a
// OpenTF context. Many of these will be overridden or merged by
// Operation. See Operation for more details.
ContextOpts *opentf.ContextOpts
ContextOpts *tofu.ContextOpts
// Input will ask for necessary input prior to performing any operations.
//

View File

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

View File

@ -14,12 +14,12 @@ import (
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/logging"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// test hook called between plan+apply during opApply
@ -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, &opentf.InputOpts{
v, err := op.UIIn.Input(stopCtx, &tofu.InputOpts{
Id: "approve",
Query: "\n" + query,
Description: desc,

View File

@ -13,10 +13,10 @@ import (
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/configs/configload"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans/planfile"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
"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 opentf.ContextOpts
var coreOpts tofu.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 := opentf.InputModeProvider
mode := tofu.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 *opentf.ContextOpts, s statemgr.Full) (*backend.LocalRun, *configload.Snapshot, tfdiags.Diagnostics) {
func (b *Local) localRunDirect(op *backend.Operation, run *backend.LocalRun, coreOpts *tofu.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 := &opentf.PlanOpts{
planOpts := &tofu.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 := opentf.NewContext(coreOpts)
tfCtx, moreDiags := tofu.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 *opentf.ContextOpts, currentStateMeta *statemgr.SnapshotMeta) (*backend.LocalRun, *configload.Snapshot, tfdiags.Diagnostics) {
func (b *Local) localRunForPlanFile(op *backend.Operation, pf *planfile.Reader, run *backend.LocalRun, coreOpts *tofu.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 := opentf.NewContext(coreOpts)
tfCtx, moreDiags := tofu.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 opentf.UIInput) map[string]backend.UnparsedVariableValue {
func (b *Local) interactiveCollectVariables(ctx context.Context, existing map[string]backend.UnparsedVariableValue, vcs map[string]*configs.Variable, uiInput tofu.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, &opentf.InputOpts{
rawValue, err := uiInput.Input(ctx, &tofu.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) (*opentf.InputValue, tfdiags.Diagnostics) {
func (v unparsedInteractiveVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*tofu.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 &opentf.InputValue{
return &tofu.InputValue{
Value: val,
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
}, diags
}
@ -498,9 +498,9 @@ type unparsedUnknownVariableValue struct {
var _ backend.UnparsedVariableValue = unparsedUnknownVariableValue{}
func (v unparsedUnknownVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics) {
return &opentf.InputValue{
func (v unparsedUnknownVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*tofu.InputValue, tfdiags.Diagnostics) {
return &tofu.InputValue{
Value: cty.UnknownVal(v.WantType),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
}, nil
}

View File

@ -18,7 +18,6 @@ import (
"github.com/opentofu/opentofu/internal/configs/configload"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/initwd"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/plans/planfile"
"github.com/opentofu/opentofu/internal/states"
@ -26,6 +25,7 @@ import (
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestLocalRun(t *testing.T) {
@ -272,6 +272,6 @@ func (s *stateStorageThatFailsRefresh) RefreshState() error {
return fmt.Errorf("intentionally failing for testing purposes")
}
func (s *stateStorageThatFailsRefresh) PersistState(schemas *opentf.Schemas) error {
func (s *stateStorageThatFailsRefresh) PersistState(schemas *tofu.Schemas) error {
return fmt.Errorf("unimplemented")
}

View File

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

View File

@ -20,12 +20,12 @@ import (
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/depsfile"
"github.com/opentofu/opentofu/internal/initwd"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/plans/planfile"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
)
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 = &opentf.ContextOpts{}
b.ContextOpts = &tofu.ContextOpts{}
}
b.ContextOpts.Parallelism = -1

View File

@ -17,10 +17,10 @@ import (
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/depsfile"
"github.com/opentofu/opentofu/internal/initwd"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
"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 = &opentf.MockUIInput{InputReturnString: "bar"}
b.ContextOpts.UIInput = &tofu.MockUIInput{InputReturnString: "bar"}
op, configCleanup, done := testOperationRefresh(t, "./testdata/refresh-var-unset")
defer configCleanup()

View File

@ -8,15 +8,15 @@ import (
"sync"
"time"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tofu"
)
// StateHook is a hook that continuously updates the state by calling
// WriteState on a statemgr.Full.
type StateHook struct {
opentf.NilHook
tofu.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 *opentf.Schemas
Schemas *tofu.Schemas
intermediatePersist IntermediateStatePersistInfo
}
@ -59,9 +59,9 @@ type IntermediateStatePersistInfo struct {
ForcePersist bool
}
var _ opentf.Hook = (*StateHook)(nil)
var _ tofu.Hook = (*StateHook)(nil)
func (h *StateHook) PostStateUpdate(new *states.State) (opentf.HookAction, error) {
func (h *StateHook) PostStateUpdate(new *states.State) (tofu.HookAction, error) {
h.Lock()
defer h.Unlock()
@ -75,13 +75,13 @@ func (h *StateHook) PostStateUpdate(new *states.State) (opentf.HookAction, error
if h.StateMgr != nil {
if err := h.StateMgr.WriteState(new); err != nil {
return opentf.HookActionHalt, err
return tofu.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 opentf.HookActionHalt, err
return tofu.HookActionHalt, err
}
h.intermediatePersist.LastPersist = time.Now()
} else {
@ -90,7 +90,7 @@ func (h *StateHook) PostStateUpdate(new *states.State) (opentf.HookAction, error
}
}
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *StateHook) Stopping() {

View File

@ -9,25 +9,25 @@ import (
"time"
"github.com/google/go-cmp/cmp"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestStateHook_impl(t *testing.T) {
var _ opentf.Hook = new(StateHook)
var _ tofu.Hook = new(StateHook)
}
func TestStateHook(t *testing.T) {
is := statemgr.NewTransientInMemory(nil)
var hook opentf.Hook = &StateHook{StateMgr: is}
var hook tofu.Hook = &StateHook{StateMgr: is}
s := statemgr.TestFullInitialState()
action, err := hook.PostStateUpdate(s)
if err != nil {
t.Fatalf("err: %s", err)
}
if action != opentf.HookActionContinue {
if action != tofu.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: &opentf.Schemas{},
Schemas: &tofu.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, opentf.HookActionContinue; got != want {
if got, want := action, tofu.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: &opentf.Schemas{},
Schemas: &tofu.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, opentf.HookActionContinue; got != want {
if got, want := action, tofu.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 *opentf.Schemas) error {
func (sm *testPersistentState) PersistState(schemas *tofu.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 *opentf.Schemas) error {
func (sm *testPersistentStateThatRefusesToPersist) PersistState(schemas *tofu.Schemas) error {
if schemas == nil {
return fmt.Errorf("no schemas")
}

View File

@ -12,10 +12,10 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tofu"
)
// 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 = &opentf.ContextOpts{}
local.ContextOpts = &tofu.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) *opentf.MockProvider {
func TestLocalProvider(t *testing.T, b *Local, name string, schema providers.ProviderSchema) *tofu.MockProvider {
// Build a mock resource provider for in-memory operations
p := new(opentf.MockProvider)
p := new(tofu.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 = &opentf.ContextOpts{}
b.ContextOpts = &tofu.ContextOpts{}
}
// Set up our provider

View File

@ -24,10 +24,10 @@ import (
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/logging"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states/remote"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
tfversion "github.com/opentofu/opentofu/version"
"github.com/zclconf/go-cty/cty"
@ -52,7 +52,7 @@ type Remote struct {
// ContextOpts are the base context options to set when initializing a
// new OpenTF context. Many of these will be overridden or merged by
// Operation. See Operation for more details.
ContextOpts *opentf.ContextOpts
ContextOpts *tofu.ContextOpts
// client is the remote backend API client.
client *tfe.Client
@ -870,7 +870,7 @@ func (b *Remote) cancel(cancelCtx context.Context, op *backend.Operation, r *tfe
// Only ask if the remote operation should be canceled
// if the auto approve flag is not set.
if !op.AutoApprove {
v, err := op.UIIn.Input(cancelCtx, &opentf.InputOpts{
v, err := op.UIIn.Input(cancelCtx, &tofu.InputOpts{
Id: "cancel",
Query: "\nDo you want to cancel the remote operation?",
Description: "Only 'yes' will be accepted to cancel.",

View File

@ -13,9 +13,9 @@ import (
tfe "github.com/hashicorp/go-tfe"
version "github.com/hashicorp/go-version"
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
func (b *Remote) opApply(stopCtx, cancelCtx context.Context, op *backend.Operation, w *tfe.Workspace) (*tfe.Run, error) {
@ -220,7 +220,7 @@ func (b *Remote) opApply(stopCtx, cancelCtx context.Context, op *backend.Operati
if !w.AutoApply {
if mustConfirm {
opts := &opentf.InputOpts{Id: "approve"}
opts := &tofu.InputOpts{Id: "approve"}
if op.PlanMode == plans.DestroyMode {
opts.Query = "\nDo you really want to destroy all resources in workspace \"" + op.Workspace + "\"?"

View File

@ -25,11 +25,11 @@ import (
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/depsfile"
"github.com/opentofu/opentofu/internal/initwd"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/plans/planfile"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
tfversion "github.com/opentofu/opentofu/version"
)
@ -235,7 +235,7 @@ func TestRemote_applyWithParallelism(t *testing.T) {
defer configCleanup()
if b.ContextOpts == nil {
b.ContextOpts = &opentf.ContextOpts{}
b.ContextOpts = &tofu.ContextOpts{}
}
b.ContextOpts.Parallelism = 3
op.Workspace = backend.DefaultStateName
@ -580,7 +580,7 @@ func TestRemote_applyWithVariables(t *testing.T) {
op, configCleanup, done := testOperationApply(t, "./testdata/apply-variables")
defer configCleanup()
op.Variables = testVariables(opentf.ValueFromNamedFile, "foo", "bar")
op.Variables = testVariables(tofu.ValueFromNamedFile, "foo", "bar")
op.Workspace = backend.DefaultStateName
run, err := b.Operation(context.Background(), op)

View File

@ -17,8 +17,8 @@ import (
tfe "github.com/hashicorp/go-tfe"
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/logging"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/tofu"
)
var (
@ -242,7 +242,7 @@ func (b *Remote) hasExplicitVariableValues(op *backend.Operation) bool {
// their final values will come from the _remote_ execution context.
for _, v := range variables {
switch v.SourceType {
case opentf.ValueFromCLIArg, opentf.ValueFromNamedFile:
case tofu.ValueFromCLIArg, tofu.ValueFromNamedFile:
return true
}
}
@ -431,7 +431,7 @@ func (b *Remote) checkPolicy(stopCtx, cancelCtx context.Context, op *backend.Ope
return generalError(fmt.Sprintf("Failed to override policy check.\n%s", runUrl), err)
}
} else {
opts := &opentf.InputOpts{
opts := &tofu.InputOpts{
Id: "override",
Query: "\nDo you want to override the soft failed policy check?",
Description: "Only 'override' will be accepted to override.",
@ -461,7 +461,7 @@ func (b *Remote) checkPolicy(stopCtx, cancelCtx context.Context, op *backend.Ope
return nil
}
func (b *Remote) confirm(stopCtx context.Context, op *backend.Operation, opts *opentf.InputOpts, r *tfe.Run, keyword string) error {
func (b *Remote) confirm(stopCtx context.Context, op *backend.Operation, opts *tofu.InputOpts, r *tfe.Run, keyword string) error {
doneCtx, cancel := context.WithCancel(stopCtx)
result := make(chan error, 2)

View File

@ -14,9 +14,9 @@ import (
"github.com/hashicorp/hcl/v2/hclsyntax"
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/zclconf/go-cty/cty"
)
@ -24,7 +24,7 @@ import (
func (b *Remote) LocalRun(op *backend.Operation) (*backend.LocalRun, statemgr.Full, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
ret := &backend.LocalRun{
PlanOpts: &opentf.PlanOpts{
PlanOpts: &tofu.PlanOpts{
Mode: op.PlanMode,
Targets: op.Targets,
},
@ -63,7 +63,7 @@ func (b *Remote) LocalRun(op *backend.Operation) (*backend.LocalRun, statemgr.Fu
}
// Initialize our context options
var opts opentf.ContextOpts
var opts tofu.ContextOpts
if v := b.ContextOpts; v != nil {
opts = *v
}
@ -142,7 +142,7 @@ func (b *Remote) LocalRun(op *backend.Operation) (*backend.LocalRun, statemgr.Fu
}
}
tfCtx, ctxDiags := opentf.NewContext(&opts)
tfCtx, ctxDiags := tofu.NewContext(&opts)
diags = diags.Append(ctxDiags)
ret.Core = tfCtx
@ -186,24 +186,24 @@ func (b *Remote) getRemoteWorkspaceID(ctx context.Context, localWorkspaceName st
return remoteWorkspace.ID, nil
}
func stubAllVariables(vv map[string]backend.UnparsedVariableValue, decls map[string]*configs.Variable) opentf.InputValues {
ret := make(opentf.InputValues, len(decls))
func stubAllVariables(vv map[string]backend.UnparsedVariableValue, decls map[string]*configs.Variable) tofu.InputValues {
ret := make(tofu.InputValues, len(decls))
for name, cfg := range decls {
raw, exists := vv[name]
if !exists {
ret[name] = &opentf.InputValue{
ret[name] = &tofu.InputValue{
Value: cty.UnknownVal(cfg.Type),
SourceType: opentf.ValueFromConfig,
SourceType: tofu.ValueFromConfig,
}
continue
}
val, diags := raw.ParseVariableValue(cfg.ParsingMode)
if diags.HasErrors() {
ret[name] = &opentf.InputValue{
ret[name] = &tofu.InputValue{
Value: cty.UnknownVal(cfg.Type),
SourceType: opentf.ValueFromConfig,
SourceType: tofu.ValueFromConfig,
}
continue
}
@ -222,7 +222,7 @@ type remoteStoredVariableValue struct {
var _ backend.UnparsedVariableValue = (*remoteStoredVariableValue)(nil)
func (v *remoteStoredVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics) {
func (v *remoteStoredVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*tofu.InputValue, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
var val cty.Value
@ -285,7 +285,7 @@ func (v *remoteStoredVariableValue) ParseVariableValue(mode configs.VariablePars
val = cty.StringVal(v.definition.Value)
}
return &opentf.InputValue{
return &tofu.InputValue{
Value: val,
// We mark these as "from input" with the rationale that entering
@ -293,6 +293,6 @@ func (v *remoteStoredVariableValue) ParseVariableValue(mode configs.VariablePars
// roughly speaking, a similar idea to entering variable values at
// the interactive CLI prompts. It's not a perfect correspondance,
// but it's closer than the other options.
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
}, diags
}

View File

@ -8,8 +8,8 @@ import (
"reflect"
"testing"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
tfe "github.com/hashicorp/go-tfe"
"github.com/zclconf/go-cty/cty"
@ -256,7 +256,7 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
tests := map[string]struct {
localVariables map[string]backend.UnparsedVariableValue
remoteVariables []*tfe.VariableCreateOptions
expectedVariables opentf.InputValues
expectedVariables tofu.InputValues
}{
"no local variables": {
map[string]backend.UnparsedVariableValue{},
@ -277,28 +277,28 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
Category: &catTerraform,
},
},
opentf.InputValues{
varName1: &opentf.InputValue{
tofu.InputValues{
varName1: &tofu.InputValue{
Value: cty.StringVal(varValue1),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
End: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
},
},
varName2: &opentf.InputValue{
varName2: &tofu.InputValue{
Value: cty.StringVal(varValue2),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
End: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
},
},
varName3: &opentf.InputValue{
varName3: &tofu.InputValue{
Value: cty.StringVal(varValue3),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
@ -326,28 +326,28 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
Category: &catTerraform,
},
},
opentf.InputValues{
varName1: &opentf.InputValue{
tofu.InputValues{
varName1: &tofu.InputValue{
Value: cty.StringVal(varValue1),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
End: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
},
},
varName2: &opentf.InputValue{
varName2: &tofu.InputValue{
Value: cty.StringVal(varValue2),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
End: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
},
},
varName3: &opentf.InputValue{
varName3: &tofu.InputValue{
Value: cty.StringVal(varValue3),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
@ -371,28 +371,28 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
Category: &catTerraform,
},
},
opentf.InputValues{
varName1: &opentf.InputValue{
tofu.InputValues{
varName1: &tofu.InputValue{
Value: cty.StringVal(varValue1),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
End: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
},
},
varName2: &opentf.InputValue{
varName2: &tofu.InputValue{
Value: cty.StringVal(varValue2),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
End: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
},
},
varName3: &opentf.InputValue{
varName3: &tofu.InputValue{
Value: cty.StringVal(varValue3),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
@ -461,10 +461,10 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
type testUnparsedVariableValue string
func (v testUnparsedVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics) {
return &opentf.InputValue{
func (v testUnparsedVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*tofu.InputValue, tfdiags.Diagnostics) {
return &tofu.InputValue{
Value: cty.StringVal(string(v)),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},

View File

@ -24,11 +24,11 @@ import (
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/depsfile"
"github.com/opentofu/opentofu/internal/initwd"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/plans/planfile"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
)
func testOperationPlan(t *testing.T, configDir string) (*backend.Operation, func(), func(*testing.T) *terminal.TestOutput) {
@ -210,7 +210,7 @@ func TestRemote_planWithParallelism(t *testing.T) {
defer configCleanup()
if b.ContextOpts == nil {
b.ContextOpts = &opentf.ContextOpts{}
b.ContextOpts = &tofu.ContextOpts{}
}
b.ContextOpts.Parallelism = 3
op.Workspace = backend.DefaultStateName
@ -615,7 +615,7 @@ func TestRemote_planWithVariables(t *testing.T) {
op, configCleanup, done := testOperationPlan(t, "./testdata/plan-variables")
defer configCleanup()
op.Variables = testVariables(opentf.ValueFromCLIArg, "foo", "bar")
op.Variables = testVariables(tofu.ValueFromCLIArg, "foo", "bar")
op.Workspace = backend.DefaultStateName
run, err := b.Operation(context.Background(), op)

View File

@ -23,10 +23,10 @@ import (
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/httpclient"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states/remote"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/opentofu/opentofu/version"
"github.com/zclconf/go-cty/cty"
@ -49,7 +49,7 @@ type mockInput struct {
answers map[string]string
}
func (m *mockInput) Input(ctx context.Context, opts *opentf.InputOpts) (string, error) {
func (m *mockInput) Input(ctx context.Context, opts *tofu.InputOpts) (string, error) {
v, ok := m.answers[opts.Id]
if !ok {
return "", fmt.Errorf("unexpected input request in test: %s", opts.Id)
@ -304,18 +304,18 @@ func testDisco(s *httptest.Server) *disco.Disco {
type unparsedVariableValue struct {
value string
source opentf.ValueSourceType
source tofu.ValueSourceType
}
func (v *unparsedVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics) {
return &opentf.InputValue{
func (v *unparsedVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*tofu.InputValue, tfdiags.Diagnostics) {
return &tofu.InputValue{
Value: cty.StringVal(v.value),
SourceType: v.source,
}, tfdiags.Diagnostics{}
}
// testVariable returns a backend.UnparsedVariableValue used for testing.
func testVariables(s opentf.ValueSourceType, vs ...string) map[string]backend.UnparsedVariableValue {
func testVariables(s tofu.ValueSourceType, vs ...string) map[string]backend.UnparsedVariableValue {
vars := make(map[string]backend.UnparsedVariableValue, len(vs))
for _, v := range vs {
vars[v] = &unparsedVariableValue{

View File

@ -8,8 +8,8 @@ import (
"github.com/hashicorp/hcl/v2"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/zclconf/go-cty/cty"
)
@ -25,7 +25,7 @@ type UnparsedVariableValue interface {
//
// If error diagnostics are returned, the resulting value may be invalid
// or incomplete.
ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics)
ParseVariableValue(mode configs.VariableParsingMode) (*tofu.InputValue, tfdiags.Diagnostics)
}
// ParseUndeclaredVariableValues processes a map of unparsed variable values
@ -34,9 +34,9 @@ type UnparsedVariableValue interface {
// variables being present, depending on the source of these values. If more
// than two undeclared values are present in file form (config, auto, -var-file)
// the remaining errors are summarized to avoid a massive list of errors.
func ParseUndeclaredVariableValues(vv map[string]UnparsedVariableValue, decls map[string]*configs.Variable) (opentf.InputValues, tfdiags.Diagnostics) {
func ParseUndeclaredVariableValues(vv map[string]UnparsedVariableValue, decls map[string]*configs.Variable) (tofu.InputValues, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
ret := make(opentf.InputValues, len(vv))
ret := make(tofu.InputValues, len(vv))
seenUndeclaredInFile := 0
for name, rv := range vv {
@ -53,7 +53,7 @@ func ParseUndeclaredVariableValues(vv map[string]UnparsedVariableValue, decls ma
ret[name] = val
switch val.SourceType {
case opentf.ValueFromConfig, opentf.ValueFromAutoFile, opentf.ValueFromNamedFile:
case tofu.ValueFromConfig, tofu.ValueFromAutoFile, tofu.ValueFromNamedFile:
// We allow undeclared names for variable values from files and warn in case
// users have forgotten a variable {} declaration or have a typo in their var name.
// Some users will actively ignore this warning because they use a .tfvars file
@ -67,12 +67,12 @@ func ParseUndeclaredVariableValues(vv map[string]UnparsedVariableValue, decls ma
}
seenUndeclaredInFile++
case opentf.ValueFromEnvVar:
case tofu.ValueFromEnvVar:
// We allow and ignore undeclared names for environment
// variables, because users will often set these globally
// when they are used across many (but not necessarily all)
// configurations.
case opentf.ValueFromCLIArg:
case tofu.ValueFromCLIArg:
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Value for undeclared variable",
@ -105,9 +105,9 @@ func ParseUndeclaredVariableValues(vv map[string]UnparsedVariableValue, decls ma
// and returns an input values map of the ones declared in the specified
// variable declaration mapping. Diagnostics will be populating with
// any variable parsing errors encountered within this collection.
func ParseDeclaredVariableValues(vv map[string]UnparsedVariableValue, decls map[string]*configs.Variable) (opentf.InputValues, tfdiags.Diagnostics) {
func ParseDeclaredVariableValues(vv map[string]UnparsedVariableValue, decls map[string]*configs.Variable) (tofu.InputValues, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
ret := make(opentf.InputValues, len(vv))
ret := make(tofu.InputValues, len(vv))
for name, rv := range vv {
var mode configs.VariableParsingMode
@ -132,9 +132,9 @@ func ParseDeclaredVariableValues(vv map[string]UnparsedVariableValue, decls map[
return ret, diags
}
// Checks all given opentf.InputValues variable maps for the existance of
// Checks all given tofu.InputValues variable maps for the existance of
// a named variable
func isDefinedAny(name string, maps ...opentf.InputValues) bool {
func isDefinedAny(name string, maps ...tofu.InputValues) bool {
for _, m := range maps {
if _, defined := m[name]; defined {
return true
@ -155,11 +155,11 @@ func isDefinedAny(name string, maps ...opentf.InputValues) bool {
//
// If this function returns without any errors in the diagnostics, the
// resulting input values map is guaranteed to be valid and ready to pass
// to opentf.NewContext. If the diagnostics contains errors, the returned
// to tofu.NewContext. If the diagnostics contains errors, the returned
// InputValues may be incomplete but will include the subset of variables
// that were successfully processed, allowing for careful analysis of the
// partial result.
func ParseVariableValues(vv map[string]UnparsedVariableValue, decls map[string]*configs.Variable) (opentf.InputValues, tfdiags.Diagnostics) {
func ParseVariableValues(vv map[string]UnparsedVariableValue, decls map[string]*configs.Variable) (tofu.InputValues, tfdiags.Diagnostics) {
ret, diags := ParseDeclaredVariableValues(vv, decls)
undeclared, diagsUndeclared := ParseUndeclaredVariableValues(vv, decls)
@ -191,9 +191,9 @@ func ParseVariableValues(vv map[string]UnparsedVariableValue, decls map[string]*
// result is complete for any calling code that wants to cautiously
// analyze it for diagnostic purposes. Since our diagnostics now
// includes an error, normal processing will ignore this result.
ret[name] = &opentf.InputValue{
ret[name] = &tofu.InputValue{
Value: cty.DynamicVal,
SourceType: opentf.ValueFromConfig,
SourceType: tofu.ValueFromConfig,
SourceRange: tfdiags.SourceRangeFromHCL(vc.DeclRange),
}
} else {
@ -203,9 +203,9 @@ func ParseVariableValues(vv map[string]UnparsedVariableValue, decls map[string]*
// that it wasn't set at all at this layer, and so OpenTF Core
// should substitute a default if available, or generate an error
// if not.
ret[name] = &opentf.InputValue{
ret[name] = &tofu.InputValue{
Value: cty.NilVal,
SourceType: opentf.ValueFromConfig,
SourceType: tofu.ValueFromConfig,
SourceRange: tfdiags.SourceRangeFromHCL(vc.DeclRange),
}
}

View File

@ -12,8 +12,8 @@ import (
"github.com/zclconf/go-cty/cty"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestUnparsedValue(t *testing.T) {
@ -72,10 +72,10 @@ func TestUnparsedValue(t *testing.T) {
t.Fatalf("wrong number of diagnostics %d; want %d", got, want)
}
wantVals := opentf.InputValues{
wantVals := tofu.InputValues{
"declared1": {
Value: cty.StringVal("5"),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
@ -108,10 +108,10 @@ func TestUnparsedValue(t *testing.T) {
t.Errorf("wrong summary for diagnostic 2\ngot: %s\nwant: %s", got, want)
}
wantVals := opentf.InputValues{
wantVals := tofu.InputValues{
"undeclared0": {
Value: cty.StringVal("0"),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1},
@ -120,7 +120,7 @@ func TestUnparsedValue(t *testing.T) {
},
"undeclared1": {
Value: cty.StringVal("1"),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1},
@ -129,7 +129,7 @@ func TestUnparsedValue(t *testing.T) {
},
"undeclared2": {
Value: cty.StringVal("2"),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1},
@ -138,7 +138,7 @@ func TestUnparsedValue(t *testing.T) {
},
"undeclared3": {
Value: cty.StringVal("3"),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1},
@ -147,7 +147,7 @@ func TestUnparsedValue(t *testing.T) {
},
"undeclared4": {
Value: cty.StringVal("4"),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1},
@ -187,10 +187,10 @@ func TestUnparsedValue(t *testing.T) {
t.Errorf("wrong summary for diagnostic 3\ngot: %s\nwant: %s", got, want)
}
wantVals := opentf.InputValues{
wantVals := tofu.InputValues{
"declared1": {
Value: cty.StringVal("5"),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
@ -199,7 +199,7 @@ func TestUnparsedValue(t *testing.T) {
},
"missing1": {
Value: cty.DynamicVal,
SourceType: opentf.ValueFromConfig,
SourceType: tofu.ValueFromConfig,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tf",
Start: tfdiags.SourcePos{Line: 3, Column: 1, Byte: 0},
@ -208,7 +208,7 @@ func TestUnparsedValue(t *testing.T) {
},
"missing2": {
Value: cty.NilVal, // OpenTF Core handles substituting the default
SourceType: opentf.ValueFromConfig,
SourceType: tofu.ValueFromConfig,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tf",
Start: tfdiags.SourcePos{Line: 4, Column: 1, Byte: 0},
@ -224,10 +224,10 @@ func TestUnparsedValue(t *testing.T) {
type testUnparsedVariableValue string
func (v testUnparsedVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics) {
return &opentf.InputValue{
func (v testUnparsedVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*tofu.InputValue, tfdiags.Diagnostics) {
return &tofu.InputValue{
Value: cty.StringVal(string(v)),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},

View File

@ -28,10 +28,10 @@ import (
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/command/jsonformat"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
tfversion "github.com/opentofu/opentofu/version"
backendLocal "github.com/opentofu/opentofu/internal/backend/local"
@ -57,7 +57,7 @@ type Cloud struct {
// ContextOpts are the base context options to set when initializing a
// new Terraform context. Many of these will be overridden or merged by
// Operation. See Operation for more details.
ContextOpts *opentf.ContextOpts
ContextOpts *tofu.ContextOpts
// client is the cloud backend API client.
client *tfe.Client
@ -879,7 +879,7 @@ func (b *Cloud) cancel(cancelCtx context.Context, op *backend.Operation, r *tfe.
// Only ask if the remote operation should be canceled
// if the auto approve flag is not set.
if !op.AutoApprove {
v, err := op.UIIn.Input(cancelCtx, &opentf.InputOpts{
v, err := op.UIIn.Input(cancelCtx, &tofu.InputOpts{
Id: "cancel",
Query: "\nDo you want to cancel the remote operation?",
Description: "Only 'yes' will be accepted to cancel.",

View File

@ -15,9 +15,9 @@ import (
tfe "github.com/hashicorp/go-tfe"
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/command/jsonformat"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
func (b *Cloud) opApply(stopCtx, cancelCtx context.Context, op *backend.Operation, w *tfe.Workspace) (*tfe.Run, error) {
@ -154,7 +154,7 @@ func (b *Cloud) opApply(stopCtx, cancelCtx context.Context, op *backend.Operatio
mustConfirm := (op.UIIn != nil && op.UIOut != nil) && !op.AutoApprove
if mustConfirm && b.input {
opts := &opentf.InputOpts{Id: "approve"}
opts := &tofu.InputOpts{Id: "approve"}
if op.PlanMode == plans.DestroyMode {
opts.Query = "\nDo you really want to destroy all resources in workspace \"" + op.Workspace + "\"?"

View File

@ -29,11 +29,11 @@ import (
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/depsfile"
"github.com/opentofu/opentofu/internal/initwd"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/plans/planfile"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
tfversion "github.com/opentofu/opentofu/version"
)
@ -386,7 +386,7 @@ func TestCloud_applyWithParallelism(t *testing.T) {
defer configCleanup()
if b.ContextOpts == nil {
b.ContextOpts = &opentf.ContextOpts{}
b.ContextOpts = &tofu.ContextOpts{}
}
b.ContextOpts.Parallelism = 3
op.Workspace = testBackendSingleWorkspaceName
@ -668,7 +668,7 @@ func TestCloud_applyWithRequiredVariables(t *testing.T) {
defer configCleanup()
defer done(t)
op.Variables = testVariables(opentf.ValueFromNamedFile, "foo") // "bar" variable value missing
op.Variables = testVariables(tofu.ValueFromNamedFile, "foo") // "bar" variable value missing
op.Workspace = testBackendSingleWorkspaceName
run, err := b.Operation(context.Background(), op)

View File

@ -24,8 +24,8 @@ import (
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/command/jsonformat"
"github.com/opentofu/opentofu/internal/logging"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/tofu"
)
var (
@ -405,7 +405,7 @@ func (b *Cloud) checkPolicy(stopCtx, cancelCtx context.Context, op *backend.Oper
} else if !b.input {
return errPolicyOverrideNeedsUIConfirmation
} else {
opts := &opentf.InputOpts{
opts := &tofu.InputOpts{
Id: "override",
Query: "\nDo you want to override the soft failed policy check?",
Description: "Only 'override' will be accepted to override.",
@ -437,7 +437,7 @@ func (b *Cloud) checkPolicy(stopCtx, cancelCtx context.Context, op *backend.Oper
return nil
}
func (b *Cloud) confirm(stopCtx context.Context, op *backend.Operation, opts *opentf.InputOpts, r *tfe.Run, keyword string) error {
func (b *Cloud) confirm(stopCtx context.Context, op *backend.Operation, opts *tofu.InputOpts, r *tfe.Run, keyword string) error {
doneCtx, cancel := context.WithCancel(stopCtx)
result := make(chan error, 2)

View File

@ -14,9 +14,9 @@ import (
"github.com/hashicorp/hcl/v2/hclsyntax"
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/zclconf/go-cty/cty"
)
@ -24,7 +24,7 @@ import (
func (b *Cloud) LocalRun(op *backend.Operation) (*backend.LocalRun, statemgr.Full, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
ret := &backend.LocalRun{
PlanOpts: &opentf.PlanOpts{
PlanOpts: &tofu.PlanOpts{
Mode: op.PlanMode,
Targets: op.Targets,
},
@ -63,7 +63,7 @@ func (b *Cloud) LocalRun(op *backend.Operation) (*backend.LocalRun, statemgr.Ful
}
// Initialize our context options
var opts opentf.ContextOpts
var opts tofu.ContextOpts
if v := b.ContextOpts; v != nil {
opts = *v
}
@ -143,7 +143,7 @@ func (b *Cloud) LocalRun(op *backend.Operation) (*backend.LocalRun, statemgr.Ful
}
}
tfCtx, ctxDiags := opentf.NewContext(&opts)
tfCtx, ctxDiags := tofu.NewContext(&opts)
diags = diags.Append(ctxDiags)
ret.Core = tfCtx
@ -183,24 +183,24 @@ func (b *Cloud) getRemoteWorkspaceID(ctx context.Context, localWorkspaceName str
return remoteWorkspace.ID, nil
}
func stubAllVariables(vv map[string]backend.UnparsedVariableValue, decls map[string]*configs.Variable) opentf.InputValues {
ret := make(opentf.InputValues, len(decls))
func stubAllVariables(vv map[string]backend.UnparsedVariableValue, decls map[string]*configs.Variable) tofu.InputValues {
ret := make(tofu.InputValues, len(decls))
for name, cfg := range decls {
raw, exists := vv[name]
if !exists {
ret[name] = &opentf.InputValue{
ret[name] = &tofu.InputValue{
Value: cty.UnknownVal(cfg.Type),
SourceType: opentf.ValueFromConfig,
SourceType: tofu.ValueFromConfig,
}
continue
}
val, diags := raw.ParseVariableValue(cfg.ParsingMode)
if diags.HasErrors() {
ret[name] = &opentf.InputValue{
ret[name] = &tofu.InputValue{
Value: cty.UnknownVal(cfg.Type),
SourceType: opentf.ValueFromConfig,
SourceType: tofu.ValueFromConfig,
}
continue
}
@ -219,7 +219,7 @@ type remoteStoredVariableValue struct {
var _ backend.UnparsedVariableValue = (*remoteStoredVariableValue)(nil)
func (v *remoteStoredVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics) {
func (v *remoteStoredVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*tofu.InputValue, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
var val cty.Value
@ -282,7 +282,7 @@ func (v *remoteStoredVariableValue) ParseVariableValue(mode configs.VariablePars
val = cty.StringVal(v.definition.Value)
}
return &opentf.InputValue{
return &tofu.InputValue{
Value: val,
// We mark these as "from input" with the rationale that entering
@ -290,6 +290,6 @@ func (v *remoteStoredVariableValue) ParseVariableValue(mode configs.VariablePars
// roughly speaking, a similar idea to entering variable values at
// the interactive CLI prompts. It's not a perfect correspondance,
// but it's closer than the other options.
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
}, diags
}

View File

@ -17,10 +17,10 @@ import (
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/initwd"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestRemoteStoredVariableValue(t *testing.T) {
@ -255,7 +255,7 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
tests := map[string]struct {
localVariables map[string]backend.UnparsedVariableValue
remoteVariables []*tfe.VariableCreateOptions
expectedVariables opentf.InputValues
expectedVariables tofu.InputValues
}{
"no local variables": {
map[string]backend.UnparsedVariableValue{},
@ -276,28 +276,28 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
Category: &catTerraform,
},
},
opentf.InputValues{
varName1: &opentf.InputValue{
tofu.InputValues{
varName1: &tofu.InputValue{
Value: cty.StringVal(varValue1),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
End: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
},
},
varName2: &opentf.InputValue{
varName2: &tofu.InputValue{
Value: cty.StringVal(varValue2),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
End: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
},
},
varName3: &opentf.InputValue{
varName3: &tofu.InputValue{
Value: cty.StringVal(varValue3),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
@ -308,7 +308,7 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
},
"single conflicting local variable": {
map[string]backend.UnparsedVariableValue{
varName3: testUnparsedVariableValue{source: opentf.ValueFromNamedFile, value: cty.StringVal(varValue3)},
varName3: testUnparsedVariableValue{source: tofu.ValueFromNamedFile, value: cty.StringVal(varValue3)},
},
[]*tfe.VariableCreateOptions{
{
@ -325,28 +325,28 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
Category: &catTerraform,
},
},
opentf.InputValues{
varName1: &opentf.InputValue{
tofu.InputValues{
varName1: &tofu.InputValue{
Value: cty.StringVal(varValue1),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
End: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
},
},
varName2: &opentf.InputValue{
varName2: &tofu.InputValue{
Value: cty.StringVal(varValue2),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
End: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
},
},
varName3: &opentf.InputValue{
varName3: &tofu.InputValue{
Value: cty.StringVal(varValue3),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
@ -357,7 +357,7 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
},
"no conflicting local variable": {
map[string]backend.UnparsedVariableValue{
varName3: testUnparsedVariableValue{source: opentf.ValueFromNamedFile, value: cty.StringVal(varValue3)},
varName3: testUnparsedVariableValue{source: tofu.ValueFromNamedFile, value: cty.StringVal(varValue3)},
},
[]*tfe.VariableCreateOptions{
{
@ -370,28 +370,28 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
Category: &catTerraform,
},
},
opentf.InputValues{
varName1: &opentf.InputValue{
tofu.InputValues{
varName1: &tofu.InputValue{
Value: cty.StringVal(varValue1),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
End: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
},
},
varName2: &opentf.InputValue{
varName2: &tofu.InputValue{
Value: cty.StringVal(varValue2),
SourceType: opentf.ValueFromInput,
SourceType: tofu.ValueFromInput,
SourceRange: tfdiags.SourceRange{
Filename: "",
Start: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
End: tfdiags.SourcePos{Line: 0, Column: 0, Byte: 0},
},
},
varName3: &opentf.InputValue{
varName3: &tofu.InputValue{
Value: cty.StringVal(varValue3),
SourceType: opentf.ValueFromNamedFile,
SourceType: tofu.ValueFromNamedFile,
SourceRange: tfdiags.SourceRange{
Filename: "fake.tfvars",
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},

View File

@ -27,11 +27,11 @@ import (
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/depsfile"
"github.com/opentofu/opentofu/internal/initwd"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/plans/planfile"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
)
func testOperationPlan(t *testing.T, configDir string) (*backend.Operation, func(), func(*testing.T) *terminal.TestOutput) {
@ -309,7 +309,7 @@ func TestCloud_planWithParallelism(t *testing.T) {
defer configCleanup()
if b.ContextOpts == nil {
b.ContextOpts = &opentf.ContextOpts{}
b.ContextOpts = &tofu.ContextOpts{}
}
b.ContextOpts.Parallelism = 3
op.Workspace = testBackendSingleWorkspaceName
@ -610,7 +610,7 @@ func TestCloud_planWithRequiredVariables(t *testing.T) {
defer configCleanup()
defer done(t)
op.Variables = testVariables(opentf.ValueFromCLIArg, "foo") // "bar" variable defined in config is missing
op.Variables = testVariables(tofu.ValueFromCLIArg, "foo") // "bar" variable defined in config is missing
op.Workspace = testBackendSingleWorkspaceName
run, err := b.Operation(context.Background(), op)

View File

@ -10,7 +10,7 @@ import (
"github.com/hashicorp/go-multierror"
tfe "github.com/hashicorp/go-tfe"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tofu"
)
type taskStages map[tfe.Stage]*tfe.TaskStage
@ -169,7 +169,7 @@ func processSummarizers(ctx *IntegrationContext, output IntegrationOutputWriter,
}
func (b *Cloud) processStageOverrides(context *IntegrationContext, output IntegrationOutputWriter, taskStageID string) (bool, error) {
opts := &opentf.InputOpts{
opts := &tofu.InputOpts{
Id: fmt.Sprintf("%c%c [bold]Override", Arrow, Arrow),
Query: "\nDo you want to override the failed policy check?",
Description: "Only 'override' will be accepted to override.",

View File

@ -7,12 +7,12 @@ import (
"github.com/hashicorp/hcl/v2/hclwrite"
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
func allowedSourceType(source opentf.ValueSourceType) bool {
return source == opentf.ValueFromNamedFile || source == opentf.ValueFromCLIArg || source == opentf.ValueFromEnvVar
func allowedSourceType(source tofu.ValueSourceType) bool {
return source == tofu.ValueFromNamedFile || source == tofu.ValueFromCLIArg || source == tofu.ValueFromEnvVar
}
// ParseCloudRunVariables accepts a mapping of unparsed values and a mapping of variable

View File

@ -10,24 +10,24 @@ import (
"github.com/hashicorp/hcl/v2"
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/zclconf/go-cty/cty"
)
func TestParseCloudRunVariables(t *testing.T) {
t.Run("populates variables from allowed sources", func(t *testing.T) {
vv := map[string]backend.UnparsedVariableValue{
"undeclared": testUnparsedVariableValue{source: opentf.ValueFromCLIArg, value: cty.StringVal("0")},
"declaredFromConfig": testUnparsedVariableValue{source: opentf.ValueFromConfig, value: cty.StringVal("1")},
"declaredFromNamedFileMapString": testUnparsedVariableValue{source: opentf.ValueFromNamedFile, value: cty.MapVal(map[string]cty.Value{"foo": cty.StringVal("bar")})},
"declaredFromNamedFileBool": testUnparsedVariableValue{source: opentf.ValueFromNamedFile, value: cty.BoolVal(true)},
"declaredFromNamedFileNumber": testUnparsedVariableValue{source: opentf.ValueFromNamedFile, value: cty.NumberIntVal(2)},
"declaredFromNamedFileListString": testUnparsedVariableValue{source: opentf.ValueFromNamedFile, value: cty.ListVal([]cty.Value{cty.StringVal("2a"), cty.StringVal("2b")})},
"declaredFromNamedFileNull": testUnparsedVariableValue{source: opentf.ValueFromNamedFile, value: cty.NullVal(cty.String)},
"declaredFromNamedMapComplex": testUnparsedVariableValue{source: opentf.ValueFromNamedFile, value: cty.MapVal(map[string]cty.Value{"foo": cty.ObjectVal(map[string]cty.Value{"qux": cty.ListVal([]cty.Value{cty.BoolVal(true), cty.BoolVal(false)})})})},
"declaredFromCLIArg": testUnparsedVariableValue{source: opentf.ValueFromCLIArg, value: cty.StringVal("3")},
"declaredFromEnvVar": testUnparsedVariableValue{source: opentf.ValueFromEnvVar, value: cty.StringVal("4")},
"undeclared": testUnparsedVariableValue{source: tofu.ValueFromCLIArg, value: cty.StringVal("0")},
"declaredFromConfig": testUnparsedVariableValue{source: tofu.ValueFromConfig, value: cty.StringVal("1")},
"declaredFromNamedFileMapString": testUnparsedVariableValue{source: tofu.ValueFromNamedFile, value: cty.MapVal(map[string]cty.Value{"foo": cty.StringVal("bar")})},
"declaredFromNamedFileBool": testUnparsedVariableValue{source: tofu.ValueFromNamedFile, value: cty.BoolVal(true)},
"declaredFromNamedFileNumber": testUnparsedVariableValue{source: tofu.ValueFromNamedFile, value: cty.NumberIntVal(2)},
"declaredFromNamedFileListString": testUnparsedVariableValue{source: tofu.ValueFromNamedFile, value: cty.ListVal([]cty.Value{cty.StringVal("2a"), cty.StringVal("2b")})},
"declaredFromNamedFileNull": testUnparsedVariableValue{source: tofu.ValueFromNamedFile, value: cty.NullVal(cty.String)},
"declaredFromNamedMapComplex": testUnparsedVariableValue{source: tofu.ValueFromNamedFile, value: cty.MapVal(map[string]cty.Value{"foo": cty.ObjectVal(map[string]cty.Value{"qux": cty.ListVal([]cty.Value{cty.BoolVal(true), cty.BoolVal(false)})})})},
"declaredFromCLIArg": testUnparsedVariableValue{source: tofu.ValueFromCLIArg, value: cty.StringVal("3")},
"declaredFromEnvVar": testUnparsedVariableValue{source: tofu.ValueFromEnvVar, value: cty.StringVal("4")},
}
decls := map[string]*configs.Variable{
@ -169,12 +169,12 @@ func TestParseCloudRunVariables(t *testing.T) {
}
type testUnparsedVariableValue struct {
source opentf.ValueSourceType
source tofu.ValueSourceType
value cty.Value
}
func (v testUnparsedVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics) {
return &opentf.InputValue{
func (v testUnparsedVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*tofu.InputValue, tfdiags.Diagnostics) {
return &tofu.InputValue{
Value: v.value,
SourceType: v.source,
SourceRange: tfdiags.SourceRange{

View File

@ -27,11 +27,11 @@ import (
"github.com/opentofu/opentofu/internal/backend/local"
"github.com/opentofu/opentofu/internal/command/jsonstate"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/remote"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tofu"
)
// State implements the State interfaces in the state package to handle
@ -157,7 +157,7 @@ func (s *State) WriteState(state *states.State) error {
}
// PersistState uploads a snapshot of the latest state as a StateVersion to Terraform Cloud
func (s *State) PersistState(schemas *opentf.Schemas) error {
func (s *State) PersistState(schemas *tofu.Schemas) error {
s.mu.Lock()
defer s.mu.Unlock()

View File

@ -29,11 +29,11 @@ import (
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/httpclient"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/opentofu/opentofu/version"
backendLocal "github.com/opentofu/opentofu/internal/backend/local"
@ -63,7 +63,7 @@ type mockInput struct {
answers map[string]string
}
func (m *mockInput) Input(ctx context.Context, opts *opentf.InputOpts) (string, error) {
func (m *mockInput) Input(ctx context.Context, opts *tofu.InputOpts) (string, error) {
v, ok := m.answers[opts.Id]
if !ok {
return "", fmt.Errorf("unexpected input request in test: %s", opts.Id)
@ -589,18 +589,18 @@ func testDisco(s *httptest.Server) *disco.Disco {
type unparsedVariableValue struct {
value string
source opentf.ValueSourceType
source tofu.ValueSourceType
}
func (v *unparsedVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics) {
return &opentf.InputValue{
func (v *unparsedVariableValue) ParseVariableValue(mode configs.VariableParsingMode) (*tofu.InputValue, tfdiags.Diagnostics) {
return &tofu.InputValue{
Value: cty.StringVal(v.value),
SourceType: v.source,
}, tfdiags.Diagnostics{}
}
// testVariable returns a backend.UnparsedVariableValue used for testing.
func testVariables(s opentf.ValueSourceType, vs ...string) map[string]backend.UnparsedVariableValue {
func testVariables(s tofu.ValueSourceType, vs ...string) map[string]backend.UnparsedVariableValue {
vars := make(map[string]backend.UnparsedVariableValue, len(vs))
for _, v := range vs {
vars[v] = &unparsedVariableValue{

View File

@ -22,12 +22,12 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestApply(t *testing.T) {
@ -298,7 +298,7 @@ func TestApply_parallelism(t *testing.T) {
providerFactories := map[addrs.Provider]providers.Factory{}
for i := 0; i < 10; i++ {
name := fmt.Sprintf("test%d", i)
provider := &opentf.MockProvider{}
provider := &tofu.MockProvider{}
provider.GetProviderSchemaResponse = &providers.GetProviderSchemaResponse{
ResourceTypes: map[string]providers.Schema{
name + "_instance": {Block: &configschema.Block{}},
@ -2159,7 +2159,7 @@ func applyFixtureSchema() *providers.GetProviderSchemaResponse {
// GetSchemaResponse, PlanResourceChangeFn, and ApplyResourceChangeFn populated,
// with the plan/apply steps just passing through the data determined by
// Terraform Core.
func applyFixtureProvider() *opentf.MockProvider {
func applyFixtureProvider() *tofu.MockProvider {
p := testProvider()
p.GetProviderSchemaResponse = applyFixtureSchema()
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse {

View File

@ -42,7 +42,6 @@ import (
"github.com/opentofu/opentofu/internal/initwd"
legacy "github.com/opentofu/opentofu/internal/legacy/opentf"
_ "github.com/opentofu/opentofu/internal/logging"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/plans/planfile"
"github.com/opentofu/opentofu/internal/providers"
@ -51,6 +50,7 @@ import (
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/opentofu/opentofu/version"
)
@ -523,8 +523,8 @@ func testStateOutput(t *testing.T, path string, expected string) {
}
}
func testProvider() *opentf.MockProvider {
p := new(opentf.MockProvider)
func testProvider() *tofu.MockProvider {
p := new(tofu.MockProvider)
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
resp.PlannedState = req.ProposedNewState
return resp

View File

@ -12,9 +12,9 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/repl"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/mitchellh/cli"
)
@ -121,7 +121,7 @@ func (c *ConsoleCommand) Run(args []string) int {
ErrorWriter: os.Stderr,
}
evalOpts := &opentf.EvalOpts{}
evalOpts := &tofu.EvalOpts{}
if lr.PlanOpts != nil {
// the LocalRun type is built primarily to support the main operations,
// so the variable values end up in the "PlanOpts" even though we're

View File

@ -10,10 +10,10 @@ import (
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/dag"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/plans/planfile"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// GraphCommand is a Command implementation that takes a Terraform
@ -123,7 +123,7 @@ func (c *GraphCommand) Run(args []string) int {
}
}
var g *opentf.Graph
var g *tofu.Graph
var graphDiags tfdiags.Diagnostics
switch graphTypeStr {
case "plan":
@ -171,7 +171,7 @@ func (c *GraphCommand) Run(args []string) int {
return 1
}
graphStr, err := opentf.GraphDot(g, &dag.DotOpts{
graphStr, err := tofu.GraphDot(g, &dag.DotOpts{
DrawCycles: drawCycles,
MaxDepth: moduleDepth,
Verbose: verbose,

View File

@ -19,8 +19,8 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// ImportCommand is a cli.Command implementation that imports resources
@ -194,7 +194,7 @@ func (c *ImportCommand) Run(args []string) int {
c.showDiagnostics(diags)
return 1
}
opReq.Hooks = []opentf.Hook{c.uiHook()}
opReq.Hooks = []tofu.Hook{c.uiHook()}
{
var moreDiags tfdiags.Diagnostics
opReq.Variables, moreDiags = c.collectVariableValues()
@ -233,8 +233,8 @@ func (c *ImportCommand) Run(args []string) int {
// Perform the import. Note that as you can see it is possible for this
// API to import more than one resource at once. For now, we only allow
// one while we stabilize this feature.
newState, importDiags := lr.Core.Import(lr.Config, lr.InputState, &opentf.ImportOpts{
Targets: []*opentf.ImportTarget{
newState, importDiags := lr.Core.Import(lr.Config, lr.InputState, &tofu.ImportOpts{
Targets: []*tofu.ImportTarget{
{
Addr: addr,
@ -256,7 +256,7 @@ func (c *ImportCommand) Run(args []string) int {
}
// Get schemas, if possible, before writing state
var schemas *opentf.Schemas
var schemas *tofu.Schemas
if isCloudMode(b) {
var schemaDiags tfdiags.Diagnostics
schemas, schemaDiags = c.MaybeGetSchemas(newState, nil)

View File

@ -27,10 +27,10 @@ import (
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/getproviders"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/providercache"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
tfversion "github.com/opentofu/opentofu/version"
)
@ -256,7 +256,7 @@ func (c *InitCommand) Run(args []string) int {
// the configuration declare that they don't support this Terraform
// version, so we can produce a version-related error message rather than
// potentially-confusing downstream errors.
versionDiags := opentf.CheckCoreVersionRequirements(config)
versionDiags := tofu.CheckCoreVersionRequirements(config)
if versionDiags.HasErrors() {
c.showDiagnostics(versionDiags)
return 1

View File

@ -15,7 +15,7 @@ import (
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/getproviders"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tofu"
)
// Config represents the complete configuration source
@ -120,7 +120,7 @@ type provisioner struct {
}
// Marshal returns the json encoding of terraform configuration.
func Marshal(c *configs.Config, schemas *opentf.Schemas) ([]byte, error) {
func Marshal(c *configs.Config, schemas *tofu.Schemas) ([]byte, error) {
var output config
pcs := make(map[string]providerConfig)
@ -147,7 +147,7 @@ func Marshal(c *configs.Config, schemas *opentf.Schemas) ([]byte, error) {
func marshalProviderConfigs(
c *configs.Config,
schemas *opentf.Schemas,
schemas *tofu.Schemas,
m map[string]providerConfig,
) {
if c == nil {
@ -304,7 +304,7 @@ func marshalProviderConfigs(
}
}
func marshalModule(c *configs.Config, schemas *opentf.Schemas, addr string) (module, error) {
func marshalModule(c *configs.Config, schemas *tofu.Schemas, addr string) (module, error) {
var module module
var rs []resource
@ -373,7 +373,7 @@ func marshalModule(c *configs.Config, schemas *opentf.Schemas, addr string) (mod
return module, nil
}
func marshalModuleCalls(c *configs.Config, schemas *opentf.Schemas) map[string]moduleCall {
func marshalModuleCalls(c *configs.Config, schemas *tofu.Schemas) map[string]moduleCall {
ret := make(map[string]moduleCall)
for name, mc := range c.Module.ModuleCalls {
@ -384,7 +384,7 @@ func marshalModuleCalls(c *configs.Config, schemas *opentf.Schemas) map[string]m
return ret
}
func marshalModuleCall(c *configs.Config, mc *configs.ModuleCall, schemas *opentf.Schemas) moduleCall {
func marshalModuleCall(c *configs.Config, mc *configs.ModuleCall, schemas *tofu.Schemas) moduleCall {
// It is possible to have a module call with a nil config.
if c == nil {
return moduleCall{}
@ -441,7 +441,7 @@ func marshalModuleCall(c *configs.Config, mc *configs.ModuleCall, schemas *opent
return ret
}
func marshalResources(resources map[string]*configs.Resource, schemas *opentf.Schemas, moduleAddr string) ([]resource, error) {
func marshalResources(resources map[string]*configs.Resource, schemas *tofu.Schemas, moduleAddr string) ([]resource, error) {
var rs []resource
for _, v := range resources {
providerConfigKey := opaqueProviderKey(v.ProviderConfigAddr().StringCompact(), moduleAddr)

View File

@ -20,11 +20,11 @@ import (
"github.com/opentofu/opentofu/internal/command/jsonprovider"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/lang/marks"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestRenderHuman_EmptyPlan(t *testing.T) {
@ -6986,7 +6986,7 @@ func runTestCases(t *testing.T, testCases map[string]testCase) {
RequiredReplace: tc.RequiredReplace,
}
tfschemas := &opentf.Schemas{
tfschemas := &tofu.Schemas{
Providers: map[addrs.Provider]providers.ProviderSchema{
src.ProviderAddr.Provider: {
ResourceTypes: map[string]providers.Schema{

View File

@ -19,9 +19,9 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestState(t *testing.T) {
@ -29,12 +29,12 @@ func TestState(t *testing.T) {
tests := []struct {
State *states.State
Schemas *opentf.Schemas
Schemas *tofu.Schemas
Want string
}{
{
State: &states.State{},
Schemas: &opentf.Schemas{},
Schemas: &tofu.Schemas{},
Want: "The state file is empty. No resources are represented.\n",
},
{
@ -98,8 +98,8 @@ func TestState(t *testing.T) {
}
}
func testProvider() *opentf.MockProvider {
p := new(opentf.MockProvider)
func testProvider() *tofu.MockProvider {
p := new(tofu.MockProvider)
p.ReadResourceFn = func(req providers.ReadResourceRequest) providers.ReadResourceResponse {
return providers.ReadResourceResponse{NewState: req.PriorState}
}
@ -153,9 +153,9 @@ func testProviderSchema() *providers.GetProviderSchemaResponse {
}
}
func testSchemas() *opentf.Schemas {
func testSchemas() *tofu.Schemas {
provider := testProvider()
return &opentf.Schemas{
return &tofu.Schemas{
Providers: map[addrs.Provider]providers.ProviderSchema{
addrs.NewDefaultProvider("test"): provider.GetProviderSchema(),
},

View File

@ -18,10 +18,10 @@ import (
"github.com/opentofu/opentofu/internal/command/jsonconfig"
"github.com/opentofu/opentofu/internal/command/jsonstate"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/opentofu/opentofu/version"
)
@ -171,7 +171,7 @@ type Variable struct {
// the part of the plan required by the jsonformat.Plan renderer.
func MarshalForRenderer(
p *plans.Plan,
schemas *opentf.Schemas,
schemas *tofu.Schemas,
) (map[string]Change, []ResourceChange, []ResourceChange, []ResourceAttr, error) {
output := newPlan()
@ -218,7 +218,7 @@ func MarshalForLog(
config *configs.Config,
p *plans.Plan,
sf *statefile.File,
schemas *opentf.Schemas,
schemas *tofu.Schemas,
) (*Plan, error) {
output := newPlan()
output.TerraformVersion = version.String()
@ -302,7 +302,7 @@ func Marshal(
config *configs.Config,
p *plans.Plan,
sf *statefile.File,
schemas *opentf.Schemas,
schemas *tofu.Schemas,
) ([]byte, error) {
output, err := MarshalForLog(config, p, sf, schemas)
if err != nil {
@ -372,7 +372,7 @@ func (p *Plan) marshalPlanVariables(vars map[string]plans.DynamicValue, decls ma
// This function is referenced directly from the structured renderer tests, to
// ensure parity between the renderers. It probably shouldn't be used anywhere
// else.
func MarshalResourceChanges(resources []*plans.ResourceInstanceChangeSrc, schemas *opentf.Schemas) ([]ResourceChange, error) {
func MarshalResourceChanges(resources []*plans.ResourceInstanceChangeSrc, schemas *tofu.Schemas) ([]ResourceChange, error) {
var ret []ResourceChange
var sortedResources []*plans.ResourceInstanceChangeSrc
@ -654,7 +654,7 @@ func MarshalOutputChanges(changes *plans.Changes) (map[string]Change, error) {
return outputChanges, nil
}
func (p *Plan) marshalPlannedValues(changes *plans.Changes, schemas *opentf.Schemas) error {
func (p *Plan) marshalPlannedValues(changes *plans.Changes, schemas *tofu.Schemas) error {
// marshal the planned changes into a module
plan, err := marshalPlannedValues(changes, schemas)
if err != nil {

View File

@ -14,9 +14,9 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/command/jsonstate"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tofu"
)
// StateValues is the common representation of resolved values for both the
@ -93,7 +93,7 @@ func marshalPlannedOutputs(changes *plans.Changes) (map[string]Output, error) {
}
func marshalPlannedValues(changes *plans.Changes, schemas *opentf.Schemas) (Module, error) {
func marshalPlannedValues(changes *plans.Changes, schemas *tofu.Schemas) (Module, error) {
var ret Module
// build two maps:
@ -166,7 +166,7 @@ func marshalPlannedValues(changes *plans.Changes, schemas *opentf.Schemas) (Modu
}
// marshalPlanResources
func marshalPlanResources(changes *plans.Changes, ris []addrs.AbsResourceInstance, schemas *opentf.Schemas) ([]Resource, error) {
func marshalPlanResources(changes *plans.Changes, ris []addrs.AbsResourceInstance, schemas *tofu.Schemas) ([]Resource, error) {
var ret []Resource
for _, ri := range ris {
@ -248,7 +248,7 @@ func marshalPlanResources(changes *plans.Changes, ris []addrs.AbsResourceInstanc
// the full module tree.
func marshalPlanModules(
changes *plans.Changes,
schemas *opentf.Schemas,
schemas *tofu.Schemas,
childModules []addrs.ModuleInstance,
moduleMap map[string][]addrs.ModuleInstance,
moduleResourceMap map[string][]addrs.AbsResourceInstance,

View File

@ -12,9 +12,9 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestMarshalAttributeValues(t *testing.T) {
@ -344,8 +344,8 @@ func TestMarshalPlanValuesNoopDeposed(t *testing.T) {
}
}
func testSchemas() *opentf.Schemas {
return &opentf.Schemas{
func testSchemas() *tofu.Schemas {
return &tofu.Schemas{
Providers: map[addrs.Provider]providers.ProviderSchema{
addrs.NewDefaultProvider("test"): providers.ProviderSchema{
ResourceTypes: map[string]providers.Schema{

View File

@ -6,8 +6,8 @@ package jsonprovider
import (
"encoding/json"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/tofu"
)
// FormatVersion represents the version of the json format and will be
@ -39,7 +39,7 @@ func newProviders() *Providers {
// schema into the public structured JSON versions.
//
// This is a format that can be read by the structured plan renderer.
func MarshalForRenderer(s *opentf.Schemas) map[string]*Provider {
func MarshalForRenderer(s *tofu.Schemas) map[string]*Provider {
schemas := make(map[string]*Provider, len(s.Providers))
for k, v := range s.Providers {
schemas[k.String()] = marshalProvider(v)
@ -47,7 +47,7 @@ func MarshalForRenderer(s *opentf.Schemas) map[string]*Provider {
return schemas
}
func Marshal(s *opentf.Schemas) ([]byte, error) {
func Marshal(s *tofu.Schemas) ([]byte, error) {
providers := newProviders()
providers.Schemas = MarshalForRenderer(s)
ret, err := json.Marshal(providers)

View File

@ -14,9 +14,9 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/command/jsonchecks"
"github.com/opentofu/opentofu/internal/lang/marks"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/tofu"
)
const (
@ -143,7 +143,7 @@ func newState() *State {
// MarshalForRenderer returns the pre-json encoding changes of the state, in a
// format available to the structured renderer.
func MarshalForRenderer(sf *statefile.File, schemas *opentf.Schemas) (Module, map[string]Output, error) {
func MarshalForRenderer(sf *statefile.File, schemas *tofu.Schemas) (Module, map[string]Output, error) {
if sf.State.Modules == nil {
// Empty state case.
return Module{}, nil, nil
@ -164,7 +164,7 @@ func MarshalForRenderer(sf *statefile.File, schemas *opentf.Schemas) (Module, ma
// MarshalForLog returns the origin JSON compatible state, read for a logging
// package to marshal further.
func MarshalForLog(sf *statefile.File, schemas *opentf.Schemas) (*State, error) {
func MarshalForLog(sf *statefile.File, schemas *tofu.Schemas) (*State, error) {
output := newState()
if sf == nil || sf.State.Empty() {
@ -190,7 +190,7 @@ func MarshalForLog(sf *statefile.File, schemas *opentf.Schemas) (*State, error)
}
// Marshal returns the json encoding of a terraform state.
func Marshal(sf *statefile.File, schemas *opentf.Schemas) ([]byte, error) {
func Marshal(sf *statefile.File, schemas *tofu.Schemas) ([]byte, error) {
output, err := MarshalForLog(sf, schemas)
if err != nil {
return nil, err
@ -200,7 +200,7 @@ func Marshal(sf *statefile.File, schemas *opentf.Schemas) ([]byte, error) {
return ret, err
}
func (jsonstate *State) marshalStateValues(s *states.State, schemas *opentf.Schemas) error {
func (jsonstate *State) marshalStateValues(s *states.State, schemas *tofu.Schemas) error {
var sv StateValues
var err error
@ -248,7 +248,7 @@ func MarshalOutputs(outputs map[string]*states.OutputValue) (map[string]Output,
return ret, nil
}
func marshalRootModule(s *states.State, schemas *opentf.Schemas) (Module, error) {
func marshalRootModule(s *states.State, schemas *tofu.Schemas) (Module, error) {
var ret Module
var err error
@ -295,7 +295,7 @@ func marshalRootModule(s *states.State, schemas *opentf.Schemas) (Module, error)
// out of terraform state.
func marshalModules(
s *states.State,
schemas *opentf.Schemas,
schemas *tofu.Schemas,
modules []addrs.ModuleInstance,
moduleMap map[string][]addrs.ModuleInstance,
) ([]Module, error) {
@ -333,7 +333,7 @@ func marshalModules(
return ret, nil
}
func marshalResources(resources map[string]*states.Resource, module addrs.ModuleInstance, schemas *opentf.Schemas) ([]Resource, error) {
func marshalResources(resources map[string]*states.Resource, module addrs.ModuleInstance, schemas *tofu.Schemas) ([]Resource, error) {
var ret []Resource
var sortedResources []*states.Resource

View File

@ -14,9 +14,9 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/lang/marks"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestMarshalOutputs(t *testing.T) {
@ -183,7 +183,7 @@ func TestMarshalResources(t *testing.T) {
deposedKey := states.NewDeposedKey()
tests := map[string]struct {
Resources map[string]*states.Resource
Schemas *opentf.Schemas
Schemas *tofu.Schemas
Want []Resource
Err bool
}{
@ -806,8 +806,8 @@ func TestMarshalModules_parent_no_resources(t *testing.T) {
}
}
func testSchemas() *opentf.Schemas {
return &opentf.Schemas{
func testSchemas() *tofu.Schemas {
return &tofu.Schemas{
Providers: map[addrs.Provider]providers.ProviderSchema{
addrs.NewDefaultProvider("test"): {
ResourceTypes: map[string]providers.Schema{

View File

@ -27,8 +27,8 @@ import (
"github.com/opentofu/opentofu/internal/command/cliconfig"
"github.com/opentofu/opentofu/internal/httpclient"
"github.com/opentofu/opentofu/internal/logging"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
uuid "github.com/hashicorp/go-uuid"
"golang.org/x/oauth2"
@ -540,7 +540,7 @@ func (c *LoginCommand) interactiveGetTokenByPassword(hostname svchost.Hostname,
c.Ui.Output("\n---------------------------------------------------------------------------------\n")
c.Ui.Output("OpenTF must temporarily use your password to request an API token.\nThis password will NOT be saved locally.\n")
username, err := c.UIInput().Input(context.Background(), &opentf.InputOpts{
username, err := c.UIInput().Input(context.Background(), &tofu.InputOpts{
Id: "username",
Query: fmt.Sprintf("Username for %s:", hostname.ForDisplay()),
})
@ -548,7 +548,7 @@ func (c *LoginCommand) interactiveGetTokenByPassword(hostname svchost.Hostname,
diags = diags.Append(fmt.Errorf("Failed to request username: %w", err))
return nil, diags
}
password, err := c.UIInput().Input(context.Background(), &opentf.InputOpts{
password, err := c.UIInput().Input(context.Background(), &tofu.InputOpts{
Id: "password",
Query: fmt.Sprintf("Password for %s:", hostname.ForDisplay()),
Secret: true,
@ -631,7 +631,7 @@ func (c *LoginCommand) interactiveGetTokenByUI(hostname svchost.Hostname, credsC
}
}
token, err := c.UIInput().Input(context.Background(), &opentf.InputOpts{
token, err := c.UIInput().Input(context.Background(), &tofu.InputOpts{
Id: "token",
Query: fmt.Sprintf("Token for %s:", hostname.ForDisplay()),
Secret: true,
@ -692,7 +692,7 @@ func (c *LoginCommand) interactiveContextConsent(hostname svchost.Hostname, gran
}
}
v, err := c.UIInput().Input(context.Background(), &opentf.InputOpts{
v, err := c.UIInput().Input(context.Background(), &tofu.InputOpts{
Id: "approve",
Query: "Do you want to proceed?",
Description: `Only 'yes' will be accepted to confirm.`,

View File

@ -34,12 +34,12 @@ import (
"github.com/opentofu/opentofu/internal/configs/configload"
"github.com/opentofu/opentofu/internal/getproviders"
legacy "github.com/opentofu/opentofu/internal/legacy/opentf"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/provisioners"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// Meta are the meta-options that are available on all or most commands.
@ -334,8 +334,8 @@ const (
)
// InputMode returns the type of input we should ask for in the form of
// opentf.InputMode which is passed directly to Context.Input.
func (m *Meta) InputMode() opentf.InputMode {
// tofu.InputMode which is passed directly to Context.Input.
func (m *Meta) InputMode() tofu.InputMode {
if test || !m.input {
return 0
}
@ -348,14 +348,14 @@ func (m *Meta) InputMode() opentf.InputMode {
}
}
var mode opentf.InputMode
mode |= opentf.InputModeProvider
var mode tofu.InputMode
mode |= tofu.InputModeProvider
return mode
}
// UIInput returns a UIInput object to be used for asking for input.
func (m *Meta) UIInput() opentf.UIInput {
func (m *Meta) UIInput() tofu.UIInput {
return &UIInput{
Colorize: m.Colorize(),
}
@ -518,13 +518,13 @@ func (m *Meta) RunOperation(b backend.Enhanced, opReq *backend.Operation) (*back
// contextOpts returns the options to use to initialize a Terraform
// context with the settings from this Meta.
func (m *Meta) contextOpts() (*opentf.ContextOpts, error) {
func (m *Meta) contextOpts() (*tofu.ContextOpts, error) {
workspace, err := m.Workspace()
if err != nil {
return nil, err
}
var opts opentf.ContextOpts
var opts tofu.ContextOpts
opts.UIInput = m.UIInput()
opts.Parallelism = m.parallelism
@ -542,7 +542,7 @@ func (m *Meta) contextOpts() (*opentf.ContextOpts, error) {
opts.Provisioners = m.provisionerFactories()
}
opts.Meta = &opentf.ContextMeta{
opts.Meta = &tofu.ContextMeta{
Env: workspace,
OriginalWorkingDir: m.WorkingDir.OriginalWorkingDir(),
}
@ -651,7 +651,7 @@ func (m *Meta) uiHook() *views.UiHook {
}
// confirm asks a yes/no confirmation.
func (m *Meta) confirm(opts *opentf.InputOpts) (bool, error) {
func (m *Meta) confirm(opts *tofu.InputOpts) (bool, error) {
if !m.Input() {
return false, errors.New("input is disabled")
}
@ -833,7 +833,7 @@ func (m *Meta) checkRequiredVersion() tfdiags.Diagnostics {
return diags
}
versionDiags := opentf.CheckCoreVersionRequirements(config)
versionDiags := tofu.CheckCoreVersionRequirements(config)
if versionDiags.HasErrors() {
diags = diags.Append(versionDiags)
return diags
@ -847,7 +847,7 @@ func (m *Meta) checkRequiredVersion() tfdiags.Diagnostics {
// it could potentially return nil without errors. It is the
// responsibility of the caller to handle the lack of schema
// information accordingly
func (c *Meta) MaybeGetSchemas(state *states.State, config *configs.Config) (*opentf.Schemas, tfdiags.Diagnostics) {
func (c *Meta) MaybeGetSchemas(state *states.State, config *configs.Config) (*tofu.Schemas, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
path, err := os.Getwd()
@ -870,7 +870,7 @@ func (c *Meta) MaybeGetSchemas(state *states.State, config *configs.Config) (*op
diags = diags.Append(err)
return nil, diags
}
tfCtx, ctxDiags := opentf.NewContext(opts)
tfCtx, ctxDiags := tofu.NewContext(opts)
diags = diags.Append(ctxDiags)
if ctxDiags.HasErrors() {
return nil, diags

View File

@ -28,10 +28,10 @@ import (
"github.com/opentofu/opentofu/internal/command/clistate"
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
backendInit "github.com/opentofu/opentofu/internal/backend/init"
backendLocal "github.com/opentofu/opentofu/internal/backend/local"
@ -227,7 +227,7 @@ func (m *Meta) selectWorkspace(b backend.Backend) error {
// len is always 1 if using Name; 0 means we're using Tags and there
// aren't any matching workspaces. Which might be normal and fine, so
// let's just ask:
name, err := m.UIInput().Input(context.Background(), &opentf.InputOpts{
name, err := m.UIInput().Input(context.Background(), &tofu.InputOpts{
Id: "create-workspace",
Query: "\n[reset][bold][yellow]No workspaces found.[reset]",
Description: fmt.Sprintf(inputCloudInitCreateWorkspace, strings.Join(c.WorkspaceMapping.Tags, ", ")),
@ -274,7 +274,7 @@ func (m *Meta) selectWorkspace(b backend.Backend) error {
}
// Otherwise, ask the user to select a workspace from the list of existing workspaces.
v, err := m.UIInput().Input(context.Background(), &opentf.InputOpts{
v, err := m.UIInput().Input(context.Background(), &tofu.InputOpts{
Id: "select-workspace",
Query: fmt.Sprintf(
"\n[reset][bold][yellow]The currently selected workspace (%s) does not exist.[reset]",

View File

@ -20,9 +20,9 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/command/clistate"
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tofu"
)
type backendMigrateOpts struct {
@ -167,7 +167,7 @@ func (m *Meta) backendMigrateState_S_S(opts *backendMigrateOpts) error {
if !migrate {
var err error
// Ask the user if they want to migrate their existing remote state
migrate, err = m.confirm(&opentf.InputOpts{
migrate, err = m.confirm(&tofu.InputOpts{
Id: "backend-migrate-multistate-to-multistate",
Query: fmt.Sprintf(
"Do you want to migrate all workspaces to %q?",
@ -227,7 +227,7 @@ func (m *Meta) backendMigrateState_S_s(opts *backendMigrateOpts) error {
if !migrate {
var err error
// Ask the user if they want to migrate their existing remote state
migrate, err = m.confirm(&opentf.InputOpts{
migrate, err = m.confirm(&tofu.InputOpts{
Id: "backend-migrate-multistate-to-single",
Query: fmt.Sprintf(
"Destination state %q doesn't support workspaces.\n"+
@ -460,15 +460,15 @@ func (m *Meta) backendMigrateState_s_s(opts *backendMigrateOpts) error {
}
func (m *Meta) backendMigrateEmptyConfirm(source, destination statemgr.Full, opts *backendMigrateOpts) (bool, error) {
var inputOpts *opentf.InputOpts
var inputOpts *tofu.InputOpts
if opts.DestinationType == "cloud" {
inputOpts = &opentf.InputOpts{
inputOpts = &tofu.InputOpts{
Id: "backend-migrate-copy-to-empty-cloud",
Query: "Do you want to copy existing state to Terraform Cloud?",
Description: fmt.Sprintf(strings.TrimSpace(inputBackendMigrateEmptyCloud), opts.SourceType),
}
} else {
inputOpts = &opentf.InputOpts{
inputOpts = &tofu.InputOpts{
Id: "backend-migrate-copy-to-empty",
Query: "Do you want to copy existing state to the new backend?",
Description: fmt.Sprintf(
@ -510,9 +510,9 @@ func (m *Meta) backendMigrateNonEmptyConfirm(
}
// Ask for confirmation
var inputOpts *opentf.InputOpts
var inputOpts *tofu.InputOpts
if opts.DestinationType == "cloud" {
inputOpts = &opentf.InputOpts{
inputOpts = &tofu.InputOpts{
Id: "backend-migrate-to-tfc",
Query: "Do you want to copy existing state to Terraform Cloud?",
Description: fmt.Sprintf(
@ -520,7 +520,7 @@ func (m *Meta) backendMigrateNonEmptyConfirm(
opts.SourceType, sourcePath, destinationPath),
}
} else {
inputOpts = &opentf.InputOpts{
inputOpts = &tofu.InputOpts{
Id: "backend-migrate-to-backend",
Query: "Do you want to copy existing state to the new backend?",
Description: fmt.Sprintf(
@ -807,7 +807,7 @@ func (m *Meta) promptSingleToCloudSingleStateMigration(opts *backendMigrateOpts)
migrate := opts.force
if !migrate {
var err error
migrate, err = m.confirm(&opentf.InputOpts{
migrate, err = m.confirm(&tofu.InputOpts{
Id: "backend-migrate-state-single-to-cloud-single",
Query: "Do you wish to proceed?",
Description: strings.TrimSpace(tfcInputBackendMigrateStateSingleToCloudSingle),
@ -828,7 +828,7 @@ func (m *Meta) promptRemotePrefixToCloudTagsMigration(opts *backendMigrateOpts)
migrate := opts.force
if !migrate {
var err error
migrate, err = m.confirm(&opentf.InputOpts{
migrate, err = m.confirm(&tofu.InputOpts{
Id: "backend-migrate-remote-multistate-to-cloud",
Query: "Do you wish to proceed?",
Description: strings.TrimSpace(tfcInputBackendMigrateRemoteMultiToCloud),
@ -855,7 +855,7 @@ func (m *Meta) promptMultiToSingleCloudMigration(opts *backendMigrateOpts) error
if !migrate {
var err error
// Ask the user if they want to migrate their existing remote state
migrate, err = m.confirm(&opentf.InputOpts{
migrate, err = m.confirm(&tofu.InputOpts{
Id: "backend-migrate-multistate-to-single",
Query: "Do you want to copy only your current workspace?",
Description: fmt.Sprintf(
@ -884,7 +884,7 @@ func (m *Meta) promptNewWorkspaceName(destinationType string) (string, error) {
}
message = `[reset][bold][yellow]Terraform Cloud requires all workspaces to be given an explicit name.[reset]`
}
name, err := m.UIInput().Input(context.Background(), &opentf.InputOpts{
name, err := m.UIInput().Input(context.Background(), &tofu.InputOpts{
Id: "new-state-name",
Query: message,
Description: strings.TrimSpace(inputBackendNewWorkspaceName),
@ -899,7 +899,7 @@ func (m *Meta) promptNewWorkspaceName(destinationType string) (string, error) {
func (m *Meta) promptMultiStateMigrationPattern(sourceType string) (string, error) {
// This is not the first prompt a user would be presented with in the migration to TFC, so no
// guard on m.input is needed here.
renameWorkspaces, err := m.UIInput().Input(context.Background(), &opentf.InputOpts{
renameWorkspaces, err := m.UIInput().Input(context.Background(), &tofu.InputOpts{
Id: "backend-migrate-multistate-to-tfc",
Query: fmt.Sprintf("[reset][bold][yellow]%s[reset]", "Would you like to rename your workspaces?"),
Description: fmt.Sprintf(strings.TrimSpace(tfcInputBackendMigrateMultiToMulti), sourceType),
@ -917,7 +917,7 @@ func (m *Meta) promptMultiStateMigrationPattern(sourceType string) (string, erro
return "*", nil
}
pattern, err := m.UIInput().Input(context.Background(), &opentf.InputOpts{
pattern, err := m.UIInput().Input(context.Background(), &tofu.InputOpts{
Id: "backend-migrate-multistate-to-tfc-pattern",
Query: fmt.Sprintf("[reset][bold][yellow]%s[reset]", "How would you like to rename your workspaces?"),
Description: strings.TrimSpace(tfcInputBackendMigrateMultiToMultiPattern),

View File

@ -21,9 +21,9 @@ import (
"github.com/opentofu/opentofu/internal/configs/configload"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/initwd"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/registry"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// normalizePath normalizes a given path so that it is, if possible, relative
@ -282,7 +282,7 @@ func (m *Meta) inputForSchema(given cty.Value, schema *configschema.Block) (cty.
attrS := schema.Attributes[name]
for {
strVal, err := input.Input(context.Background(), &opentf.InputOpts{
strVal, err := input.Input(context.Background(), &tofu.InputOpts{
Id: name,
Query: name,
Description: attrS.Description,

View File

@ -16,7 +16,7 @@ import (
"github.com/mitchellh/cli"
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/backend/local"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestMetaColorize(t *testing.T) {
@ -89,7 +89,7 @@ func TestMetaInputMode(t *testing.T) {
t.Fatalf("err: %s", err)
}
if m.InputMode() != opentf.InputModeStd {
if m.InputMode() != tofu.InputModeStd {
t.Fatalf("bad: %#v", m.InputMode())
}
}
@ -108,11 +108,11 @@ func TestMetaInputMode_envVar(t *testing.T) {
t.Fatalf("err: %s", err)
}
off := opentf.InputMode(0)
on := opentf.InputModeStd
off := tofu.InputMode(0)
on := tofu.InputModeStd
cases := []struct {
EnvVar string
Expected opentf.InputMode
Expected tofu.InputMode
}{
{"false", off},
{"0", off},

View File

@ -14,8 +14,8 @@ import (
"github.com/opentofu/opentofu/internal/backend"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// VarEnvPrefix is the prefix for environment variables that represent values
@ -55,7 +55,7 @@ func (m *Meta) collectVariableValues() (map[string]backend.UnparsedVariableValue
ret[name] = unparsedVariableValueString{
str: rawVal,
name: name,
sourceType: opentf.ValueFromEnvVar,
sourceType: tofu.ValueFromEnvVar,
}
}
}
@ -65,12 +65,12 @@ func (m *Meta) collectVariableValues() (map[string]backend.UnparsedVariableValue
// (DefaultVarsFilename) along with the later-added search for all files
// ending in .auto.tfvars.
if _, err := os.Stat(DefaultVarsFilename); err == nil {
moreDiags := m.addVarsFromFile(DefaultVarsFilename, opentf.ValueFromAutoFile, ret)
moreDiags := m.addVarsFromFile(DefaultVarsFilename, tofu.ValueFromAutoFile, ret)
diags = diags.Append(moreDiags)
}
const defaultVarsFilenameJSON = DefaultVarsFilename + ".json"
if _, err := os.Stat(defaultVarsFilenameJSON); err == nil {
moreDiags := m.addVarsFromFile(defaultVarsFilenameJSON, opentf.ValueFromAutoFile, ret)
moreDiags := m.addVarsFromFile(defaultVarsFilenameJSON, tofu.ValueFromAutoFile, ret)
diags = diags.Append(moreDiags)
}
if infos, err := os.ReadDir("."); err == nil {
@ -80,7 +80,7 @@ func (m *Meta) collectVariableValues() (map[string]backend.UnparsedVariableValue
if !isAutoVarFile(name) {
continue
}
moreDiags := m.addVarsFromFile(name, opentf.ValueFromAutoFile, ret)
moreDiags := m.addVarsFromFile(name, tofu.ValueFromAutoFile, ret)
diags = diags.Append(moreDiags)
}
}
@ -116,11 +116,11 @@ func (m *Meta) collectVariableValues() (map[string]backend.UnparsedVariableValue
ret[name] = unparsedVariableValueString{
str: rawVal,
name: name,
sourceType: opentf.ValueFromCLIArg,
sourceType: tofu.ValueFromCLIArg,
}
case "-var-file":
moreDiags := m.addVarsFromFile(rawFlag.Value, opentf.ValueFromNamedFile, ret)
moreDiags := m.addVarsFromFile(rawFlag.Value, tofu.ValueFromNamedFile, ret)
diags = diags.Append(moreDiags)
default:
@ -133,7 +133,7 @@ func (m *Meta) collectVariableValues() (map[string]backend.UnparsedVariableValue
return ret, diags
}
func (m *Meta) addVarsFromFile(filename string, sourceType opentf.ValueSourceType, to map[string]backend.UnparsedVariableValue) tfdiags.Diagnostics {
func (m *Meta) addVarsFromFile(filename string, sourceType tofu.ValueSourceType, to map[string]backend.UnparsedVariableValue) tfdiags.Diagnostics {
var diags tfdiags.Diagnostics
src, err := os.ReadFile(filename)
@ -228,17 +228,17 @@ func (m *Meta) addVarsFromFile(filename string, sourceType opentf.ValueSourceTyp
// intended to deal with expressions inside "tfvars" files.
type unparsedVariableValueExpression struct {
expr hcl.Expression
sourceType opentf.ValueSourceType
sourceType tofu.ValueSourceType
}
func (v unparsedVariableValueExpression) ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics) {
func (v unparsedVariableValueExpression) ParseVariableValue(mode configs.VariableParsingMode) (*tofu.InputValue, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
val, hclDiags := v.expr.Value(nil) // nil because no function calls or variable references are allowed here
diags = diags.Append(hclDiags)
rng := tfdiags.SourceRangeFromHCL(v.expr.Range())
return &opentf.InputValue{
return &tofu.InputValue{
Value: val,
SourceType: v.sourceType,
SourceRange: rng,
@ -252,16 +252,16 @@ func (v unparsedVariableValueExpression) ParseVariableValue(mode configs.Variabl
type unparsedVariableValueString struct {
str string
name string
sourceType opentf.ValueSourceType
sourceType tofu.ValueSourceType
}
func (v unparsedVariableValueString) ParseVariableValue(mode configs.VariableParsingMode) (*opentf.InputValue, tfdiags.Diagnostics) {
func (v unparsedVariableValueString) ParseVariableValue(mode configs.VariableParsingMode) (*tofu.InputValue, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
val, hclDiags := mode.Parse(v.name, v.str)
diags = diags.Append(hclDiags)
return &opentf.InputValue{
return &tofu.InputValue{
Value: val,
SourceType: v.sourceType,
}, diags

View File

@ -22,11 +22,11 @@ import (
backendinit "github.com/opentofu/opentofu/internal/backend/init"
"github.com/opentofu/opentofu/internal/checks"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestPlan(t *testing.T) {
@ -1435,7 +1435,7 @@ func TestPlan_parallelism(t *testing.T) {
providerFactories := map[addrs.Provider]providers.Factory{}
for i := 0; i < 10; i++ {
name := fmt.Sprintf("test%d", i)
provider := &opentf.MockProvider{}
provider := &tofu.MockProvider{}
provider.GetProviderSchemaResponse = &providers.GetProviderSchemaResponse{
ResourceTypes: map[string]providers.Schema{
name + "_instance": {Block: &configschema.Block{}},
@ -1631,7 +1631,7 @@ func planFixtureSchema() *providers.GetProviderSchemaResponse {
// operation with the configuration in testdata/plan. This mock has
// GetSchemaResponse and PlanResourceChangeFn populated, with the plan
// step just passing through the new object proposed by Terraform Core.
func planFixtureProvider() *opentf.MockProvider {
func planFixtureProvider() *tofu.MockProvider {
p := testProvider()
p.GetProviderSchemaResponse = planFixtureSchema()
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse {
@ -1672,7 +1672,7 @@ func planVarsFixtureSchema() *providers.GetProviderSchemaResponse {
// operation with the configuration in testdata/plan-vars. This mock has
// GetSchemaResponse and PlanResourceChangeFn populated, with the plan
// step just passing through the new object proposed by Terraform Core.
func planVarsFixtureProvider() *opentf.MockProvider {
func planVarsFixtureProvider() *tofu.MockProvider {
p := testProvider()
p.GetProviderSchemaResponse = planVarsFixtureSchema()
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse {
@ -1694,7 +1694,7 @@ func planVarsFixtureProvider() *opentf.MockProvider {
// planFixtureProvider returns a mock provider that is configured for basic
// operation with the configuration in testdata/plan. This mock has
// GetSchemaResponse and PlanResourceChangeFn populated, returning 3 warnings.
func planWarningsFixtureProvider() *opentf.MockProvider {
func planWarningsFixtureProvider() *tofu.MockProvider {
p := testProvider()
p.GetProviderSchemaResponse = planFixtureSchema()
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse {

View File

@ -14,8 +14,8 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/mitchellh/cli"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/zclconf/go-cty/cty"
)
@ -116,7 +116,7 @@ type providerSchema struct {
// testProvider returns a mock provider that is configured for basic
// operation with the configuration in testdata/providers-schema.
func providersSchemaFixtureProvider() *opentf.MockProvider {
func providersSchemaFixtureProvider() *tofu.MockProvider {
p := testProvider()
p.GetProviderSchemaResponse = providersSchemaFixtureSchema()
return p

View File

@ -16,12 +16,12 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/plans/planfile"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// Many of the methods we get data from can emit special error types if they're
@ -107,13 +107,13 @@ func (c *ShowCommand) Synopsis() string {
return "Show the current state or a saved plan"
}
func (c *ShowCommand) show(path string) (*plans.Plan, *cloudplan.RemotePlanJSON, *statefile.File, *configs.Config, *opentf.Schemas, tfdiags.Diagnostics) {
func (c *ShowCommand) show(path string) (*plans.Plan, *cloudplan.RemotePlanJSON, *statefile.File, *configs.Config, *tofu.Schemas, tfdiags.Diagnostics) {
var diags, showDiags tfdiags.Diagnostics
var plan *plans.Plan
var jsonPlan *cloudplan.RemotePlanJSON
var stateFile *statefile.File
var config *configs.Config
var schemas *opentf.Schemas
var schemas *tofu.Schemas
// No plan file or state file argument provided,
// so get the latest state snapshot

View File

@ -17,11 +17,11 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/opentofu/opentofu/version"
)
@ -1054,7 +1054,7 @@ func showFixtureSensitiveSchema() *providers.GetProviderSchemaResponse {
// GetSchemaResponse, PlanResourceChangeFn, and ApplyResourceChangeFn populated,
// with the plan/apply steps just passing through the data determined by
// Terraform Core.
func showFixtureProvider() *opentf.MockProvider {
func showFixtureProvider() *tofu.MockProvider {
p := testProvider()
p.GetProviderSchemaResponse = showFixtureSchema()
p.ReadResourceFn = func(req providers.ReadResourceRequest) providers.ReadResourceResponse {
@ -1117,7 +1117,7 @@ func showFixtureProvider() *opentf.MockProvider {
// GetSchemaResponse, PlanResourceChangeFn, and ApplyResourceChangeFn populated,
// with the plan/apply steps just passing through the data determined by
// Terraform Core. It also has a sensitive attribute in the provider schema.
func showFixtureSensitiveProvider() *opentf.MockProvider {
func showFixtureSensitiveProvider() *tofu.MockProvider {
p := testProvider()
p.GetProviderSchemaResponse = showFixtureSensitiveSchema()
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse {

View File

@ -14,9 +14,9 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/command/clistate"
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// StateMvCommand is a Command implementation that shows a single resource.
@ -398,7 +398,7 @@ func (c *StateMvCommand) Run(args []string) int {
}
// Get schemas, if possible, before writing state
var schemas *opentf.Schemas
var schemas *tofu.Schemas
if isCloudMode(b) {
var schemaDiags tfdiags.Diagnostics
schemas, schemaDiags = c.MaybeGetSchemas(stateTo, nil)

View File

@ -14,10 +14,10 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/command/clistate"
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// StatePushCommand is a Command implementation that shows a single resource.
@ -134,7 +134,7 @@ func (c *StatePushCommand) Run(args []string) int {
}
// Get schemas, if possible, before writing state
var schemas *opentf.Schemas
var schemas *tofu.Schemas
var diags tfdiags.Diagnostics
if isCloudMode(b) {
schemas, diags = c.MaybeGetSchemas(srcStateFile.State, nil)

View File

@ -13,9 +13,9 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/command/clistate"
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// StateReplaceProviderCommand is a Command implementation that allows users
@ -173,7 +173,7 @@ func (c *StateReplaceProviderCommand) Run(args []string) int {
}
// Get schemas, if possible, before writing state
var schemas *opentf.Schemas
var schemas *tofu.Schemas
if isCloudMode(b) {
var schemaDiags tfdiags.Diagnostics
schemas, schemaDiags = c.MaybeGetSchemas(state, nil)

View File

@ -13,8 +13,8 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/command/clistate"
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// StateRmCommand is a Command implementation that shows a single resource.
@ -123,7 +123,7 @@ func (c *StateRmCommand) Run(args []string) int {
}
// Get schemas, if possible, before writing state
var schemas *opentf.Schemas
var schemas *tofu.Schemas
if isCloudMode(b) {
var schemaDiags tfdiags.Diagnostics
schemas, schemaDiags = c.MaybeGetSchemas(state, nil)

View File

@ -11,9 +11,9 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/command/clistate"
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// TaintCommand is a cli.Command implementation that manually taints
@ -130,7 +130,7 @@ func (c *TaintCommand) Run(args []string) int {
}
// Get schemas, if possible, before writing state
var schemas *opentf.Schemas
var schemas *tofu.Schemas
if isCloudMode(b) {
var schemaDiags tfdiags.Diagnostics
schemas, schemaDiags = c.MaybeGetSchemas(state, nil)

View File

@ -20,10 +20,10 @@ import (
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/logging"
"github.com/opentofu/opentofu/internal/moduletest"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
const (
@ -308,7 +308,7 @@ type TestSuiteRunner struct {
Config *configs.Config
GlobalVariables map[string]backend.UnparsedVariableValue
Opts *opentf.ContextOpts
Opts *tofu.ContextOpts
View views.Test
@ -615,7 +615,7 @@ func (runner *TestFileRunner) validate(config *configs.Config, run *moduletest.R
var diags tfdiags.Diagnostics
tfCtx, ctxDiags := opentf.NewContext(runner.Suite.Opts)
tfCtx, ctxDiags := tofu.NewContext(runner.Suite.Opts)
diags = diags.Append(ctxDiags)
if ctxDiags.HasErrors() {
return diags
@ -662,12 +662,12 @@ func (runner *TestFileRunner) destroy(config *configs.Config, state *states.Stat
return state, diags
}
planOpts := &opentf.PlanOpts{
planOpts := &tofu.PlanOpts{
Mode: plans.DestroyMode,
SetVariables: variables,
}
tfCtx, ctxDiags := opentf.NewContext(runner.Suite.Opts)
tfCtx, ctxDiags := tofu.NewContext(runner.Suite.Opts)
diags = diags.Append(ctxDiags)
if ctxDiags.HasErrors() {
return state, diags
@ -703,7 +703,7 @@ func (runner *TestFileRunner) destroy(config *configs.Config, state *states.Stat
return updated, diags
}
func (runner *TestFileRunner) plan(config *configs.Config, state *states.State, run *moduletest.Run, file *moduletest.File) (*opentf.Context, *plans.Plan, tfdiags.Diagnostics) {
func (runner *TestFileRunner) plan(config *configs.Config, state *states.State, run *moduletest.Run, file *moduletest.File) (*tofu.Context, *plans.Plan, tfdiags.Diagnostics) {
log.Printf("[TRACE] TestFileRunner: called plan for %s/%s", file.Name, run.Name)
var diags tfdiags.Diagnostics
@ -724,7 +724,7 @@ func (runner *TestFileRunner) plan(config *configs.Config, state *states.State,
return nil, nil, diags
}
planOpts := &opentf.PlanOpts{
planOpts := &tofu.PlanOpts{
Mode: func() plans.Mode {
switch run.Config.Options.Mode {
case configs.RefreshOnlyTestMode:
@ -740,7 +740,7 @@ func (runner *TestFileRunner) plan(config *configs.Config, state *states.State,
ExternalReferences: references,
}
tfCtx, ctxDiags := opentf.NewContext(runner.Suite.Opts)
tfCtx, ctxDiags := tofu.NewContext(runner.Suite.Opts)
diags = diags.Append(ctxDiags)
if ctxDiags.HasErrors() {
return nil, nil, diags
@ -770,7 +770,7 @@ func (runner *TestFileRunner) plan(config *configs.Config, state *states.State,
return tfCtx, plan, diags
}
func (runner *TestFileRunner) apply(plan *plans.Plan, state *states.State, config *configs.Config, run *moduletest.Run, file *moduletest.File) (*opentf.Context, *states.State, tfdiags.Diagnostics) {
func (runner *TestFileRunner) apply(plan *plans.Plan, state *states.State, config *configs.Config, run *moduletest.Run, file *moduletest.File) (*tofu.Context, *states.State, tfdiags.Diagnostics) {
log.Printf("[TRACE] TestFileRunner: called apply for %s/%s", file.Name, run.Name)
var diags tfdiags.Diagnostics
@ -794,7 +794,7 @@ func (runner *TestFileRunner) apply(plan *plans.Plan, state *states.State, confi
created = append(created, change)
}
tfCtx, ctxDiags := opentf.NewContext(runner.Suite.Opts)
tfCtx, ctxDiags := tofu.NewContext(runner.Suite.Opts)
diags = diags.Append(ctxDiags)
if ctxDiags.HasErrors() {
return nil, state, diags
@ -824,7 +824,7 @@ func (runner *TestFileRunner) apply(plan *plans.Plan, state *states.State, confi
return tfCtx, updated, diags
}
func (runner *TestFileRunner) wait(ctx *opentf.Context, runningCtx context.Context, run *moduletest.Run, file *moduletest.File, created []*plans.ResourceInstanceChangeSrc) (diags tfdiags.Diagnostics, cancelled bool) {
func (runner *TestFileRunner) wait(ctx *tofu.Context, runningCtx context.Context, run *moduletest.Run, file *moduletest.File, created []*plans.ResourceInstanceChangeSrc) (diags tfdiags.Diagnostics, cancelled bool) {
var identifier string
if file == nil {
identifier = "validate"
@ -997,13 +997,13 @@ func (runner *TestFileRunner) Cleanup(file *moduletest.File) {
// helper functions
// buildInputVariablesForTest creates a opentf.InputValues mapping for
// buildInputVariablesForTest creates a tofu.InputValues mapping for
// variable values that are relevant to the config being tested.
//
// Crucially, it differs from prepareInputVariablesForAssertions in that it only
// includes variables that are reference by the config and not everything that
// is defined within the test run block and test file.
func buildInputVariablesForTest(run *moduletest.Run, file *moduletest.File, config *configs.Config, globals map[string]backend.UnparsedVariableValue) (opentf.InputValues, tfdiags.Diagnostics) {
func buildInputVariablesForTest(run *moduletest.Run, file *moduletest.File, config *configs.Config, globals map[string]backend.UnparsedVariableValue) (tofu.InputValues, tfdiags.Diagnostics) {
variables := make(map[string]backend.UnparsedVariableValue)
for name := range config.Module.Variables {
if run != nil {
@ -1011,7 +1011,7 @@ func buildInputVariablesForTest(run *moduletest.Run, file *moduletest.File, conf
// Local variables take precedence.
variables[name] = unparsedVariableValueExpression{
expr: expr,
sourceType: opentf.ValueFromConfig,
sourceType: tofu.ValueFromConfig,
}
continue
}
@ -1022,7 +1022,7 @@ func buildInputVariablesForTest(run *moduletest.Run, file *moduletest.File, conf
// If it's not set locally, it maybe set for the entire file.
variables[name] = unparsedVariableValueExpression{
expr: expr,
sourceType: opentf.ValueFromConfig,
sourceType: tofu.ValueFromConfig,
}
continue
}
@ -1043,7 +1043,7 @@ func buildInputVariablesForTest(run *moduletest.Run, file *moduletest.File, conf
return backend.ParseVariableValues(variables, config.Module.Variables)
}
// prepareInputVariablesForAssertions creates a opentf.InputValues mapping
// prepareInputVariablesForAssertions creates a tofu.InputValues mapping
// that contains all the variables defined for a given run and file, alongside
// any unset variables that have defaults within the provided config.
//
@ -1055,14 +1055,14 @@ func buildInputVariablesForTest(run *moduletest.Run, file *moduletest.File, conf
// In addition, it modifies the provided config so that any variables that are
// available are also defined in the config. It returns a function that resets
// the config which must be called so the config can be reused going forward.
func prepareInputVariablesForAssertions(config *configs.Config, run *moduletest.Run, file *moduletest.File, globals map[string]backend.UnparsedVariableValue) (opentf.InputValues, func(), tfdiags.Diagnostics) {
func prepareInputVariablesForAssertions(config *configs.Config, run *moduletest.Run, file *moduletest.File, globals map[string]backend.UnparsedVariableValue) (tofu.InputValues, func(), tfdiags.Diagnostics) {
variables := make(map[string]backend.UnparsedVariableValue)
if run != nil {
for name, expr := range run.Config.Variables {
variables[name] = unparsedVariableValueExpression{
expr: expr,
sourceType: opentf.ValueFromConfig,
sourceType: tofu.ValueFromConfig,
}
}
}
@ -1076,7 +1076,7 @@ func prepareInputVariablesForAssertions(config *configs.Config, run *moduletest.
}
variables[name] = unparsedVariableValueExpression{
expr: expr,
sourceType: opentf.ValueFromConfig,
sourceType: tofu.ValueFromConfig,
}
}
}
@ -1094,7 +1094,7 @@ func prepareInputVariablesForAssertions(config *configs.Config, run *moduletest.
// We've gathered all the values we have, let's convert them into
// terraform.InputValues so they can be passed into the Terraform graph.
inputs := make(opentf.InputValues, len(variables))
inputs := make(tofu.InputValues, len(variables))
var diags tfdiags.Diagnostics
for name, variable := range variables {
value, valueDiags := variable.ParseVariableValue(configs.VariableParseLiteral)
@ -1114,9 +1114,9 @@ func prepareInputVariablesForAssertions(config *configs.Config, run *moduletest.
}
if variable.Default != cty.NilVal {
inputs[name] = &opentf.InputValue{
inputs[name] = &tofu.InputValue{
Value: variable.Default,
SourceType: opentf.ValueFromConfig,
SourceType: tofu.ValueFromConfig,
SourceRange: tfdiags.SourceRangeFromHCL(variable.DeclRange),
}
}

View File

@ -1038,7 +1038,7 @@ The plan was created with the -target option in effect, so some changes
requested in the configuration may have been ignored and the output values
may not be fully updated. Run the following command to verify that no other
changes are pending:
opentf plan
tofu plan
Note that the -target option is not suitable for routine use, and is provided
only for exceptional situations such as recovering from errors or mistakes,
@ -1069,7 +1069,7 @@ The plan was created with the -target option in effect, so some changes
requested in the configuration may have been ignored and the output values
may not be fully updated. Run the following command to verify that no other
changes are pending:
opentf plan
tofu plan
Note that the -target option is not suitable for routine use, and is provided
only for exceptional situations such as recovering from errors or mistakes,

View File

@ -11,9 +11,9 @@ import (
"github.com/zclconf/go-cty/cty"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
var (
@ -54,7 +54,7 @@ var (
// TestProvider is a wrapper around terraform.MockProvider that defines dynamic
// schemas, and keeps track of the resources and data sources that it contains.
type TestProvider struct {
Provider *opentf.MockProvider
Provider *tofu.MockProvider
data, resource cty.Value
@ -71,7 +71,7 @@ func NewProvider(store *ResourceStore) *TestProvider {
}
provider := &TestProvider{
Provider: new(opentf.MockProvider),
Provider: new(tofu.MockProvider),
Store: store,
}

View File

@ -21,7 +21,7 @@ import (
"github.com/bgentry/speakeasy"
"github.com/mattn/go-isatty"
"github.com/mitchellh/colorstring"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tofu"
)
var defaultInputReader io.Reader
@ -49,7 +49,7 @@ type UIInput struct {
once sync.Once
}
func (i *UIInput) Input(ctx context.Context, opts *opentf.InputOpts) (string, error) {
func (i *UIInput) Input(ctx context.Context, opts *tofu.InputOpts) (string, error) {
i.once.Do(i.init)
r := i.Reader

View File

@ -12,11 +12,11 @@ import (
"testing"
"time"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestUIInput_impl(t *testing.T) {
var _ opentf.UIInput = new(UIInput)
var _ tofu.UIInput = new(UIInput)
}
func TestUIInputInput(t *testing.T) {
@ -25,7 +25,7 @@ func TestUIInputInput(t *testing.T) {
Writer: bytes.NewBuffer(nil),
}
v, err := i.Input(context.Background(), &opentf.InputOpts{})
v, err := i.Input(context.Background(), &tofu.InputOpts{})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@ -52,7 +52,7 @@ func TestUIInputInput_canceled(t *testing.T) {
}()
// Get input until the context is canceled.
v, err := i.Input(ctx, &opentf.InputOpts{})
v, err := i.Input(ctx, &tofu.InputOpts{})
if err != context.Canceled {
t.Fatalf("expected a context.Canceled error, got: %v", err)
}
@ -75,7 +75,7 @@ func TestUIInputInput_canceled(t *testing.T) {
w.Close()
}()
v, err = i.Input(context.Background(), &opentf.InputOpts{})
v, err = i.Input(context.Background(), &tofu.InputOpts{})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@ -91,7 +91,7 @@ func TestUIInputInput_spaces(t *testing.T) {
Writer: bytes.NewBuffer(nil),
}
v, err := i.Input(context.Background(), &opentf.InputOpts{})
v, err := i.Input(context.Background(), &tofu.InputOpts{})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@ -107,7 +107,7 @@ func TestUIInputInput_Error(t *testing.T) {
Writer: bytes.NewBuffer(nil),
}
v, err := i.Input(context.Background(), &opentf.InputOpts{})
v, err := i.Input(context.Background(), &tofu.InputOpts{})
if err == nil {
t.Fatalf("Error is not 'nil'")
}

View File

@ -12,8 +12,8 @@ import (
"github.com/mitchellh/cli"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// UnlockCommand is a cli.Command implementation that manually unlocks
@ -94,7 +94,7 @@ func (c *UnlockCommand) Run(args []string) int {
"This will allow local OpenTF commands to modify this state, even though it\n" +
"may still be in use. Only 'yes' will be accepted to confirm."
v, err := c.UIInput().Input(context.Background(), &opentf.InputOpts{
v, err := c.UIInput().Input(context.Background(), &tofu.InputOpts{
Id: "force-unlock",
Query: "Do you really want to force-unlock?",
Description: desc,

View File

@ -11,9 +11,9 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/command/clistate"
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// UntaintCommand is a cli.Command implementation that manually untaints
@ -169,7 +169,7 @@ func (c *UntaintCommand) Run(args []string) int {
}
// Get schemas, if possible, before writing state
var schemas *opentf.Schemas
var schemas *tofu.Schemas
if isCloudMode(b) {
var schemaDiags tfdiags.Diagnostics
schemas, schemaDiags = c.MaybeGetSchemas(state, nil)

View File

@ -12,8 +12,8 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/command/views"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// ValidateCommand is a Command implementation that validates the terraform files
@ -88,7 +88,7 @@ func (c *ValidateCommand) validate(dir, testDir string, noTests bool) tfdiags.Di
return diags
}
tfCtx, ctxDiags := opentf.NewContext(opts)
tfCtx, ctxDiags := tofu.NewContext(opts)
diags = diags.Append(ctxDiags)
if ctxDiags.HasErrors() {
return diags

View File

@ -9,9 +9,9 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/command/format"
"github.com/opentofu/opentofu/internal/command/views/json"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// The Apply view is used for the apply command.
@ -20,7 +20,7 @@ type Apply interface {
Outputs(outputValues map[string]*states.OutputValue)
Operation() Operation
Hooks() []opentf.Hook
Hooks() []tofu.Hook
Diagnostics(diags tfdiags.Diagnostics)
HelpPrompt()
@ -99,8 +99,8 @@ func (v *ApplyHuman) Operation() Operation {
return NewOperation(arguments.ViewHuman, v.inAutomation, v.view)
}
func (v *ApplyHuman) Hooks() []opentf.Hook {
return []opentf.Hook{
func (v *ApplyHuman) Hooks() []tofu.Hook {
return []tofu.Hook{
v.countHook,
NewUiHook(v.view),
}
@ -159,8 +159,8 @@ func (v *ApplyJSON) Operation() Operation {
return &OperationJSON{view: v.view}
}
func (v *ApplyJSON) Hooks() []opentf.Hook {
return []opentf.Hook{
func (v *ApplyJSON) Hooks() []tofu.Hook {
return []tofu.Hook{
v.countHook,
newJSONHook(v.view),
}

View File

@ -9,9 +9,9 @@ import (
"github.com/zclconf/go-cty/cty"
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tofu"
)
// countHook is a hook that counts the number of resources
@ -30,10 +30,10 @@ type countHook struct {
pending map[string]plans.Action
sync.Mutex
opentf.NilHook
tofu.NilHook
}
var _ opentf.Hook = (*countHook)(nil)
var _ tofu.Hook = (*countHook)(nil)
func (h *countHook) Reset() {
h.Lock()
@ -46,7 +46,7 @@ func (h *countHook) Reset() {
h.Imported = 0
}
func (h *countHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (opentf.HookAction, error) {
func (h *countHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (tofu.HookAction, error) {
h.Lock()
defer h.Unlock()
@ -56,10 +56,10 @@ func (h *countHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generati
h.pending[addr.String()] = action
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *countHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation, newState cty.Value, err error) (opentf.HookAction, error) {
func (h *countHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation, newState cty.Value, err error) (tofu.HookAction, error) {
h.Lock()
defer h.Unlock()
@ -84,16 +84,16 @@ func (h *countHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generat
}
}
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *countHook) PostDiff(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (opentf.HookAction, error) {
func (h *countHook) PostDiff(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (tofu.HookAction, error) {
h.Lock()
defer h.Unlock()
// We don't count anything for data resources
if addr.Resource.Resource.Mode == addrs.DataResourceMode {
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
switch action {
@ -107,13 +107,13 @@ func (h *countHook) PostDiff(addr addrs.AbsResourceInstance, gen states.Generati
h.ToChange += 1
}
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *countHook) PostApplyImport(addr addrs.AbsResourceInstance, importing plans.ImportingSrc) (opentf.HookAction, error) {
func (h *countHook) PostApplyImport(addr addrs.AbsResourceInstance, importing plans.ImportingSrc) (tofu.HookAction, error) {
h.Lock()
defer h.Unlock()
h.Imported++
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}

View File

@ -10,15 +10,15 @@ import (
"github.com/zclconf/go-cty/cty"
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tofu"
legacy "github.com/opentofu/opentofu/internal/legacy/opentf"
)
func TestCountHook_impl(t *testing.T) {
var _ opentf.Hook = new(countHook)
var _ tofu.Hook = new(countHook)
}
func TestCountHookPostDiff_DestroyDeposed(t *testing.T) {

View File

@ -15,9 +15,9 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/command/format"
"github.com/opentofu/opentofu/internal/command/views/json"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tofu"
)
// How long to wait between sending heartbeat/progress messages
@ -33,7 +33,7 @@ func newJSONHook(view *JSONView) *jsonHook {
}
type jsonHook struct {
opentf.NilHook
tofu.NilHook
view *JSONView
@ -47,7 +47,7 @@ type jsonHook struct {
timeAfter func(time.Duration) <-chan time.Time
}
var _ opentf.Hook = (*jsonHook)(nil)
var _ tofu.Hook = (*jsonHook)(nil)
type applyProgress struct {
addr addrs.AbsResourceInstance
@ -62,7 +62,7 @@ type applyProgress struct {
heartbeatDone chan struct{}
}
func (h *jsonHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (opentf.HookAction, error) {
func (h *jsonHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (tofu.HookAction, error) {
if action != plans.NoOp {
idKey, idValue := format.ObjectValueIDOrName(priorState)
h.view.Hook(json.NewApplyStart(addr, action, idKey, idValue))
@ -82,7 +82,7 @@ func (h *jsonHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generatio
if action != plans.NoOp {
go h.applyingHeartbeat(progress)
}
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *jsonHook) applyingHeartbeat(progress applyProgress) {
@ -99,7 +99,7 @@ func (h *jsonHook) applyingHeartbeat(progress applyProgress) {
}
}
func (h *jsonHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation, newState cty.Value, err error) (opentf.HookAction, error) {
func (h *jsonHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation, newState cty.Value, err error) (tofu.HookAction, error) {
key := addr.String()
h.applyingLock.Lock()
progress := h.applying[key]
@ -110,7 +110,7 @@ func (h *jsonHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generati
h.applyingLock.Unlock()
if progress.action == plans.NoOp {
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
elapsed := h.timeNow().Round(time.Second).Sub(progress.start)
@ -124,15 +124,15 @@ func (h *jsonHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generati
idKey, idValue := format.ObjectValueID(newState)
h.view.Hook(json.NewApplyComplete(addr, progress.action, idKey, idValue, elapsed))
}
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *jsonHook) PreProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string) (opentf.HookAction, error) {
func (h *jsonHook) PreProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string) (tofu.HookAction, error) {
h.view.Hook(json.NewProvisionStart(addr, typeName))
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *jsonHook) PostProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string, err error) (opentf.HookAction, error) {
func (h *jsonHook) PostProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string, err error) (tofu.HookAction, error) {
if err != nil {
// Errors are collected and displayed post-apply, so no need to
// re-render them here. Instead just signal that this provisioner step
@ -141,7 +141,7 @@ func (h *jsonHook) PostProvisionInstanceStep(addr addrs.AbsResourceInstance, typ
} else {
h.view.Hook(json.NewProvisionComplete(addr, typeName))
}
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *jsonHook) ProvisionOutput(addr addrs.AbsResourceInstance, typeName string, msg string) {
@ -155,14 +155,14 @@ func (h *jsonHook) ProvisionOutput(addr addrs.AbsResourceInstance, typeName stri
}
}
func (h *jsonHook) PreRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value) (opentf.HookAction, error) {
func (h *jsonHook) PreRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value) (tofu.HookAction, error) {
idKey, idValue := format.ObjectValueID(priorState)
h.view.Hook(json.NewRefreshStart(addr, idKey, idValue))
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *jsonHook) PostRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value, newState cty.Value) (opentf.HookAction, error) {
func (h *jsonHook) PostRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value, newState cty.Value) (tofu.HookAction, error) {
idKey, idValue := format.ObjectValueID(newState)
h.view.Hook(json.NewRefreshComplete(addr, idKey, idValue))
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}

View File

@ -10,10 +10,10 @@ import (
"time"
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/zclconf/go-cty/cty"
)
@ -329,13 +329,13 @@ func TestJSONHook_refresh(t *testing.T) {
testJSONViewOutputEquals(t, done(t).Stdout(), want)
}
func testHookReturnValues(t *testing.T, action opentf.HookAction, err error) {
func testHookReturnValues(t *testing.T, action tofu.HookAction, err error) {
t.Helper()
if err != nil {
t.Fatal(err)
}
if action != opentf.HookActionContinue {
if action != tofu.HookActionContinue {
t.Fatalf("Expected hook to continue, given: %#v", action)
}
}

View File

@ -16,10 +16,10 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/command/format"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tofu"
)
const defaultPeriodicUiTimer = 10 * time.Second
@ -34,7 +34,7 @@ func NewUiHook(view *View) *UiHook {
}
type UiHook struct {
opentf.NilHook
tofu.NilHook
view *View
viewLock sync.Mutex
@ -45,7 +45,7 @@ type UiHook struct {
resourcesLock sync.Mutex
}
var _ opentf.Hook = (*UiHook)(nil)
var _ tofu.Hook = (*UiHook)(nil)
// uiResourceState tracks the state of a single resource
type uiResourceState struct {
@ -71,7 +71,7 @@ const (
uiResourceNoOp
)
func (h *UiHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (opentf.HookAction, error) {
func (h *UiHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (tofu.HookAction, error) {
dispAddr := addr.String()
if gen != states.CurrentGen {
dispAddr = fmt.Sprintf("%s (deposed object %s)", dispAddr, gen)
@ -99,7 +99,7 @@ func (h *UiHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation,
// We don't expect any other actions in here, so anything else is a
// bug in the caller but we'll ignore it in order to be robust.
h.println(fmt.Sprintf("(Unknown action %s for %s)", action, dispAddr))
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
var stateIdSuffix string
@ -141,7 +141,7 @@ func (h *UiHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation,
go h.stillApplying(uiState)
}
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *UiHook) stillApplying(state uiResourceState) {
@ -184,7 +184,7 @@ func (h *UiHook) stillApplying(state uiResourceState) {
}
}
func (h *UiHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation, newState cty.Value, applyerr error) (opentf.HookAction, error) {
func (h *UiHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation, newState cty.Value, applyerr error) (tofu.HookAction, error) {
id := addr.String()
h.resourcesLock.Lock()
@ -213,14 +213,14 @@ func (h *UiHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation
msg = "Read complete"
case uiResourceNoOp:
// We don't make any announcements about no-op changes
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
case uiResourceUnknown:
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
if applyerr != nil {
// Errors are collected and printed in ApplyCommand, no need to duplicate
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
addrStr := addr.String()
@ -234,15 +234,15 @@ func (h *UiHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation
h.println(colorized)
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *UiHook) PreProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string) (opentf.HookAction, error) {
func (h *UiHook) PreProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string) (tofu.HookAction, error) {
h.println(fmt.Sprintf(
h.view.colorize.Color("[reset][bold]%s: Provisioning with '%s'...[reset]"),
addr, typeName,
))
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *UiHook) ProvisionOutput(addr addrs.AbsResourceInstance, typeName string, msg string) {
@ -264,7 +264,7 @@ func (h *UiHook) ProvisionOutput(addr addrs.AbsResourceInstance, typeName string
h.println(strings.TrimSpace(buf.String()))
}
func (h *UiHook) PreRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value) (opentf.HookAction, error) {
func (h *UiHook) PreRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value) (tofu.HookAction, error) {
var stateIdSuffix string
if k, v := format.ObjectValueID(priorState); k != "" && v != "" {
stateIdSuffix = fmt.Sprintf(" [%s=%s]", k, v)
@ -278,18 +278,18 @@ func (h *UiHook) PreRefresh(addr addrs.AbsResourceInstance, gen states.Generatio
h.println(fmt.Sprintf(
h.view.colorize.Color("[reset][bold]%s: Refreshing state...%s"),
addrStr, stateIdSuffix))
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *UiHook) PreImportState(addr addrs.AbsResourceInstance, importID string) (opentf.HookAction, error) {
func (h *UiHook) PreImportState(addr addrs.AbsResourceInstance, importID string) (tofu.HookAction, error) {
h.println(fmt.Sprintf(
h.view.colorize.Color("[reset][bold]%s: Importing from ID %q..."),
addr, importID,
))
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *UiHook) PostImportState(addr addrs.AbsResourceInstance, imported []providers.ImportedResource) (opentf.HookAction, error) {
func (h *UiHook) PostImportState(addr addrs.AbsResourceInstance, imported []providers.ImportedResource) (tofu.HookAction, error) {
h.println(fmt.Sprintf(
h.view.colorize.Color("[reset][bold][green]%s: Import prepared!"),
addr,
@ -301,34 +301,34 @@ func (h *UiHook) PostImportState(addr addrs.AbsResourceInstance, imported []prov
))
}
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *UiHook) PrePlanImport(addr addrs.AbsResourceInstance, importID string) (opentf.HookAction, error) {
func (h *UiHook) PrePlanImport(addr addrs.AbsResourceInstance, importID string) (tofu.HookAction, error) {
h.println(fmt.Sprintf(
h.view.colorize.Color("[reset][bold]%s: Preparing import... [id=%s]"),
addr, importID,
))
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *UiHook) PreApplyImport(addr addrs.AbsResourceInstance, importing plans.ImportingSrc) (opentf.HookAction, error) {
func (h *UiHook) PreApplyImport(addr addrs.AbsResourceInstance, importing plans.ImportingSrc) (tofu.HookAction, error) {
h.println(fmt.Sprintf(
h.view.colorize.Color("[reset][bold]%s: Importing... [id=%s]"),
addr, importing.ID,
))
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
func (h *UiHook) PostApplyImport(addr addrs.AbsResourceInstance, importing plans.ImportingSrc) (opentf.HookAction, error) {
func (h *UiHook) PostApplyImport(addr addrs.AbsResourceInstance, importing plans.ImportingSrc) (tofu.HookAction, error) {
h.println(fmt.Sprintf(
h.view.colorize.Color("[reset][bold]%s: Import complete [id=%s]"),
addr, importing.ID,
))
return opentf.HookActionContinue, nil
return tofu.HookActionContinue, nil
}
// Wrap calls to the view so that concurrent calls do not interleave println.

View File

@ -15,11 +15,11 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
)
// Test the PreApply hook for creating a new resource
@ -55,7 +55,7 @@ func TestUiHookPreApply_create(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if action != opentf.HookActionContinue {
if action != tofu.HookActionContinue {
t.Fatalf("Expected hook to continue, given: %#v", action)
}
@ -113,7 +113,7 @@ func TestUiHookPreApply_periodicTimer(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if action != opentf.HookActionContinue {
if action != tofu.HookActionContinue {
t.Fatalf("Expected hook to continue, given: %#v", action)
}
@ -177,7 +177,7 @@ func TestUiHookPreApply_destroy(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if action != opentf.HookActionContinue {
if action != tofu.HookActionContinue {
t.Fatalf("Expected hook to continue, given: %#v", action)
}
@ -228,7 +228,7 @@ func TestUiHookPostApply_colorInterpolation(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if action != opentf.HookActionContinue {
if action != tofu.HookActionContinue {
t.Fatalf("Expected hook to continue, given: %#v", action)
}
result := done(t)
@ -281,7 +281,7 @@ func TestUiHookPostApply_emptyState(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if action != opentf.HookActionContinue {
if action != tofu.HookActionContinue {
t.Fatalf("Expected hook to continue, given: %#v", action)
}
result := done(t)
@ -314,7 +314,7 @@ func TestPreProvisionInstanceStep(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if action != opentf.HookActionContinue {
if action != tofu.HookActionContinue {
t.Fatalf("Expected hook to continue, given: %#v", action)
}
result := done(t)
@ -430,7 +430,7 @@ func TestPreRefresh(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if action != opentf.HookActionContinue {
if action != tofu.HookActionContinue {
t.Fatalf("Expected hook to continue, given: %#v", action)
}
result := done(t)
@ -462,7 +462,7 @@ func TestPreRefresh_noID(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if action != opentf.HookActionContinue {
if action != tofu.HookActionContinue {
t.Fatalf("Expected hook to continue, given: %#v", action)
}
result := done(t)
@ -489,7 +489,7 @@ func TestPreImportState(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if action != opentf.HookActionContinue {
if action != tofu.HookActionContinue {
t.Fatalf("Expected hook to continue, given: %#v", action)
}
result := done(t)
@ -537,7 +537,7 @@ func TestPostImportState(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if action != opentf.HookActionContinue {
if action != tofu.HookActionContinue {
t.Fatalf("Expected hook to continue, given: %#v", action)
}
result := done(t)

View File

@ -15,10 +15,10 @@ import (
"github.com/opentofu/opentofu/internal/command/jsonplan"
"github.com/opentofu/opentofu/internal/command/jsonprovider"
"github.com/opentofu/opentofu/internal/command/views/json"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
type Operation interface {
@ -30,7 +30,7 @@ type Operation interface {
EmergencyDumpState(stateFile *statefile.File) error
PlannedChange(change *plans.ResourceInstanceChangeSrc)
Plan(plan *plans.Plan, schemas *opentf.Schemas)
Plan(plan *plans.Plan, schemas *tofu.Schemas)
PlanNextStep(planPath string, genConfigPath string)
Diagnostics(diags tfdiags.Diagnostics)
@ -91,7 +91,7 @@ func (v *OperationHuman) EmergencyDumpState(stateFile *statefile.File) error {
return nil
}
func (v *OperationHuman) Plan(plan *plans.Plan, schemas *opentf.Schemas) {
func (v *OperationHuman) Plan(plan *plans.Plan, schemas *tofu.Schemas) {
outputs, changed, drift, attrs, err := jsonplan.MarshalForRenderer(plan, schemas)
if err != nil {
v.view.streams.Eprintf("Failed to marshal plan to json: %s", err)
@ -209,7 +209,7 @@ func (v *OperationJSON) EmergencyDumpState(stateFile *statefile.File) error {
// Log a change summary and a series of "planned" messages for the changes in
// the plan.
func (v *OperationJSON) Plan(plan *plans.Plan, schemas *opentf.Schemas) {
func (v *OperationJSON) Plan(plan *plans.Plan, schemas *tofu.Schemas) {
for _, dr := range plan.DriftedResources {
// In refresh-only mode, we output all resources marked as drifted,
// including those which have moved without other changes. In other plan

View File

@ -12,11 +12,11 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/lang/globalref"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/zclconf/go-cty/cty"
)
@ -81,11 +81,11 @@ func TestOperation_emergencyDumpState(t *testing.T) {
func TestOperation_planNoChanges(t *testing.T) {
tests := map[string]struct {
plan func(schemas *opentf.Schemas) *plans.Plan
plan func(schemas *tofu.Schemas) *plans.Plan
wantText string
}{
"nothing at all in normal mode": {
func(schemas *opentf.Schemas) *plans.Plan {
func(schemas *tofu.Schemas) *plans.Plan {
return &plans.Plan{
UIMode: plans.NormalMode,
Changes: plans.NewChanges(),
@ -94,7 +94,7 @@ func TestOperation_planNoChanges(t *testing.T) {
"no differences, so no changes are needed.",
},
"nothing at all in refresh-only mode": {
func(schemas *opentf.Schemas) *plans.Plan {
func(schemas *tofu.Schemas) *plans.Plan {
return &plans.Plan{
UIMode: plans.RefreshOnlyMode,
Changes: plans.NewChanges(),
@ -103,7 +103,7 @@ func TestOperation_planNoChanges(t *testing.T) {
"OpenTF has checked that the real remote objects still match",
},
"nothing at all in destroy mode": {
func(schemas *opentf.Schemas) *plans.Plan {
func(schemas *tofu.Schemas) *plans.Plan {
return &plans.Plan{
UIMode: plans.DestroyMode,
Changes: plans.NewChanges(),
@ -112,7 +112,7 @@ func TestOperation_planNoChanges(t *testing.T) {
"No objects need to be destroyed.",
},
"no drift detected in normal noop": {
func(schemas *opentf.Schemas) *plans.Plan {
func(schemas *tofu.Schemas) *plans.Plan {
addr := addrs.Resource{
Mode: addrs.ManagedResourceMode,
Type: "test_resource",
@ -153,7 +153,7 @@ func TestOperation_planNoChanges(t *testing.T) {
"No changes",
},
"drift detected in normal mode": {
func(schemas *opentf.Schemas) *plans.Plan {
func(schemas *tofu.Schemas) *plans.Plan {
addr := addrs.Resource{
Mode: addrs.ManagedResourceMode,
Type: "test_resource",
@ -200,7 +200,7 @@ func TestOperation_planNoChanges(t *testing.T) {
"Objects have changed outside of OpenTF",
},
"drift detected in refresh-only mode": {
func(schemas *opentf.Schemas) *plans.Plan {
func(schemas *tofu.Schemas) *plans.Plan {
addr := addrs.Resource{
Mode: addrs.ManagedResourceMode,
Type: "test_resource",
@ -241,7 +241,7 @@ func TestOperation_planNoChanges(t *testing.T) {
"If you were expecting these changes then you can apply this plan",
},
"move-only changes in refresh-only mode": {
func(schemas *opentf.Schemas) *plans.Plan {
func(schemas *tofu.Schemas) *plans.Plan {
addr := addrs.Resource{
Mode: addrs.ManagedResourceMode,
Type: "test_resource",
@ -290,7 +290,7 @@ func TestOperation_planNoChanges(t *testing.T) {
"test_resource.anywhere has moved to test_resource.somewhere",
},
"drift detected in destroy mode": {
func(schemas *opentf.Schemas) *plans.Plan {
func(schemas *tofu.Schemas) *plans.Plan {
return &plans.Plan{
UIMode: plans.DestroyMode,
Changes: plans.NewChanges(),

View File

@ -7,14 +7,14 @@ import (
"fmt"
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// The Plan view is used for the plan command.
type Plan interface {
Operation() Operation
Hooks() []opentf.Hook
Hooks() []tofu.Hook
Diagnostics(diags tfdiags.Diagnostics)
HelpPrompt()
@ -51,8 +51,8 @@ func (v *PlanHuman) Operation() Operation {
return NewOperation(arguments.ViewHuman, v.inAutomation, v.view)
}
func (v *PlanHuman) Hooks() []opentf.Hook {
return []opentf.Hook{
func (v *PlanHuman) Hooks() []tofu.Hook {
return []tofu.Hook{
NewUiHook(v.view),
}
}
@ -77,8 +77,8 @@ func (v *PlanJSON) Operation() Operation {
return &OperationJSON{view: v.view}
}
func (v *PlanJSON) Hooks() []opentf.Hook {
return []opentf.Hook{
func (v *PlanJSON) Hooks() []tofu.Hook {
return []tofu.Hook{
newJSONHook(v.view),
}
}

View File

@ -9,10 +9,10 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/zclconf/go-cty/cty"
)
@ -130,17 +130,17 @@ func testPlanWithDatasource(t *testing.T) *plans.Plan {
return plan
}
func testSchemas() *opentf.Schemas {
func testSchemas() *tofu.Schemas {
provider := testProvider()
return &opentf.Schemas{
return &tofu.Schemas{
Providers: map[addrs.Provider]providers.ProviderSchema{
addrs.NewDefaultProvider("test"): provider.GetProviderSchema(),
},
}
}
func testProvider() *opentf.MockProvider {
p := new(opentf.MockProvider)
func testProvider() *tofu.MockProvider {
p := new(tofu.MockProvider)
p.ReadResourceFn = func(req providers.ReadResourceRequest) providers.ReadResourceResponse {
return providers.ReadResourceResponse{NewState: req.PriorState}
}

View File

@ -8,9 +8,9 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/command/views/json"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// The Refresh view is used for the refresh command.
@ -18,7 +18,7 @@ type Refresh interface {
Outputs(outputValues map[string]*states.OutputValue)
Operation() Operation
Hooks() []opentf.Hook
Hooks() []tofu.Hook
Diagnostics(diags tfdiags.Diagnostics)
HelpPrompt()
@ -65,8 +65,8 @@ func (v *RefreshHuman) Operation() Operation {
return NewOperation(arguments.ViewHuman, v.inAutomation, v.view)
}
func (v *RefreshHuman) Hooks() []opentf.Hook {
return []opentf.Hook{
func (v *RefreshHuman) Hooks() []tofu.Hook {
return []tofu.Hook{
v.countHook,
NewUiHook(v.view),
}
@ -101,8 +101,8 @@ func (v *RefreshJSON) Operation() Operation {
return &OperationJSON{view: v.view}
}
func (v *RefreshJSON) Hooks() []opentf.Hook {
return []opentf.Hook{
func (v *RefreshJSON) Hooks() []tofu.Hook {
return []tofu.Hook{
newJSONHook(v.view),
}
}

View File

@ -15,15 +15,15 @@ import (
"github.com/opentofu/opentofu/internal/command/jsonprovider"
"github.com/opentofu/opentofu/internal/command/jsonstate"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
type Show interface {
// Display renders the plan, if it is available. If plan is nil, it renders the statefile.
Display(config *configs.Config, plan *plans.Plan, planJSON *cloudplan.RemotePlanJSON, stateFile *statefile.File, schemas *opentf.Schemas) int
Display(config *configs.Config, plan *plans.Plan, planJSON *cloudplan.RemotePlanJSON, stateFile *statefile.File, schemas *tofu.Schemas) int
// Diagnostics renders early diagnostics, resulting from argument parsing.
Diagnostics(diags tfdiags.Diagnostics)
@ -46,7 +46,7 @@ type ShowHuman struct {
var _ Show = (*ShowHuman)(nil)
func (v *ShowHuman) Display(config *configs.Config, plan *plans.Plan, planJSON *cloudplan.RemotePlanJSON, stateFile *statefile.File, schemas *opentf.Schemas) int {
func (v *ShowHuman) Display(config *configs.Config, plan *plans.Plan, planJSON *cloudplan.RemotePlanJSON, stateFile *statefile.File, schemas *tofu.Schemas) int {
renderer := jsonformat.Renderer{
Colorize: v.view.colorize,
Streams: v.view.streams,
@ -131,7 +131,7 @@ type ShowJSON struct {
var _ Show = (*ShowJSON)(nil)
func (v *ShowJSON) Display(config *configs.Config, plan *plans.Plan, planJSON *cloudplan.RemotePlanJSON, stateFile *statefile.File, schemas *opentf.Schemas) int {
func (v *ShowJSON) Display(config *configs.Config, plan *plans.Plan, planJSON *cloudplan.RemotePlanJSON, stateFile *statefile.File, schemas *tofu.Schemas) int {
// Prefer to display a pre-built JSON plan, if we got one; then, fall back
// to building one ourselves.
if planJSON != nil {

View File

@ -14,12 +14,12 @@ import (
"github.com/opentofu/opentofu/internal/command/arguments"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/initwd"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/terminal"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/zclconf/go-cty/cty"
)
@ -34,7 +34,7 @@ func TestShowHuman(t *testing.T) {
plan *plans.Plan
jsonPlan *cloudplan.RemotePlanJSON
stateFile *statefile.File
schemas *opentf.Schemas
schemas *tofu.Schemas
wantExact bool
wantString string
}{
@ -179,7 +179,7 @@ func TestShowJSON(t *testing.T) {
view.Configure(&arguments.View{NoColor: true})
v := NewShow(arguments.ViewJSON, view)
schemas := &opentf.Schemas{
schemas := &tofu.Schemas{
Providers: map[addrs.Provider]providers.ProviderSchema{
addrs.NewDefaultProvider("test"): {
ResourceTypes: map[string]providers.Schema{

View File

@ -15,11 +15,11 @@ import (
"github.com/opentofu/opentofu/internal/command/views/json"
"github.com/opentofu/opentofu/internal/configs"
"github.com/opentofu/opentofu/internal/moduletest"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/plans"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/tfdiags"
"github.com/opentofu/opentofu/internal/tofu"
)
// Test renders outputs for test executions.
@ -140,7 +140,7 @@ func (t *TestHuman) Run(run *moduletest.Run, file *moduletest.File) {
// We're going to be more verbose about what we print, here's the plan
// or the state depending on the type of run we did.
schemas := &opentf.Schemas{
schemas := &tofu.Schemas{
Providers: run.Verbose.Providers,
Provisioners: run.Verbose.Provisioners,
}
@ -402,7 +402,7 @@ func (t *TestJSON) Run(run *moduletest.Run, file *moduletest.File) {
if run.Verbose != nil {
schemas := &opentf.Schemas{
schemas := &tofu.Schemas{
Providers: run.Verbose.Providers,
Provisioners: run.Verbose.Provisioners,
}

View File

@ -8,7 +8,7 @@ import (
"net/rpc"
"github.com/hashicorp/go-plugin"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tofu"
)
// UIInput is an implementation of terraform.UIInput that communicates
@ -17,7 +17,7 @@ type UIInput struct {
Client *rpc.Client
}
func (i *UIInput) Input(ctx context.Context, opts *opentf.InputOpts) (string, error) {
func (i *UIInput) Input(ctx context.Context, opts *tofu.InputOpts) (string, error) {
var resp UIInputInputResponse
err := i.Client.Call("Plugin.Input", opts, &resp)
if err != nil {
@ -39,11 +39,11 @@ type UIInputInputResponse struct {
// UIInputServer is a net/rpc compatible structure for serving
// a UIInputServer. This should not be used directly.
type UIInputServer struct {
UIInput opentf.UIInput
UIInput tofu.UIInput
}
func (s *UIInputServer) Input(
opts *opentf.InputOpts,
opts *tofu.InputOpts,
reply *UIInputInputResponse) error {
value, err := s.UIInput.Input(context.Background(), opts)
*reply = UIInputInputResponse{

View File

@ -9,18 +9,18 @@ import (
"testing"
"github.com/hashicorp/go-plugin"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestUIInput_impl(t *testing.T) {
var _ opentf.UIInput = new(UIInput)
var _ tofu.UIInput = new(UIInput)
}
func TestUIInput_input(t *testing.T) {
client, server := plugin.TestRPCConn(t)
defer client.Close()
i := new(opentf.MockUIInput)
i := new(tofu.MockUIInput)
i.InputReturnString = "foo"
err := server.RegisterName("Plugin", &UIInputServer{
@ -32,7 +32,7 @@ func TestUIInput_input(t *testing.T) {
input := &UIInput{Client: client}
opts := &opentf.InputOpts{
opts := &tofu.InputOpts{
Id: "foo",
}

View File

@ -6,7 +6,7 @@ package plugin
import (
"net/rpc"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tofu"
)
// UIOutput is an implementatin of terraform.UIOutput that communicates
@ -21,7 +21,7 @@ func (o *UIOutput) Output(v string) {
// UIOutputServer is the RPC server for serving UIOutput.
type UIOutputServer struct {
UIOutput opentf.UIOutput
UIOutput tofu.UIOutput
}
func (s *UIOutputServer) Output(

View File

@ -7,18 +7,18 @@ import (
"testing"
"github.com/hashicorp/go-plugin"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/tofu"
)
func TestUIOutput_impl(t *testing.T) {
var _ opentf.UIOutput = new(UIOutput)
var _ tofu.UIOutput = new(UIOutput)
}
func TestUIOutput_input(t *testing.T) {
client, server := plugin.TestRPCConn(t)
defer client.Close()
o := new(opentf.MockUIOutput)
o := new(tofu.MockUIOutput)
err := server.RegisterName("Plugin", &UIOutputServer{
UIOutput: o,

View File

@ -15,9 +15,9 @@ import (
"github.com/opentofu/opentofu/internal/addrs"
"github.com/opentofu/opentofu/internal/configs/configschema"
"github.com/opentofu/opentofu/internal/initwd"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/providers"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tofu"
_ "github.com/opentofu/opentofu/internal/logging"
)
@ -261,7 +261,7 @@ func TestSession_stateless(t *testing.T) {
func testSession(t *testing.T, test testSessionTest) {
t.Helper()
p := &opentf.MockProvider{}
p := &tofu.MockProvider{}
p.GetProviderSchemaResponse = &providers.GetProviderSchemaResponse{
ResourceTypes: map[string]providers.Schema{
"test_instance": {
@ -281,7 +281,7 @@ func testSession(t *testing.T, test testSessionTest) {
}
// Build the TF context
ctx, diags := opentf.NewContext(&opentf.ContextOpts{
ctx, diags := tofu.NewContext(&tofu.ContextOpts{
Providers: map[addrs.Provider]providers.Factory{
addrs.NewDefaultProvider("test"): providers.FactoryFixed(p),
},
@ -294,7 +294,7 @@ func testSession(t *testing.T, test testSessionTest) {
if state == nil {
state = states.NewState()
}
scope, diags := ctx.Eval(config, state, addrs.RootModuleInstance, &opentf.EvalOpts{})
scope, diags := ctx.Eval(config, state, addrs.RootModuleInstance, &tofu.EvalOpts{})
if diags.HasErrors() {
t.Fatalf("failed to create scope: %s", diags.Err())
}

View File

@ -12,10 +12,10 @@ import (
uuid "github.com/hashicorp/go-uuid"
"github.com/opentofu/opentofu/internal/backend/local"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/states/statemgr"
"github.com/opentofu/opentofu/internal/tofu"
)
// State implements the State interfaces in the state package to handle
@ -166,7 +166,7 @@ func (s *State) refreshState() error {
}
// statemgr.Persister impl.
func (s *State) PersistState(schemas *opentf.Schemas) error {
func (s *State) PersistState(schemas *tofu.Schemas) error {
s.mu.Lock()
defer s.mu.Unlock()

View File

@ -16,9 +16,9 @@ import (
multierror "github.com/hashicorp/go-multierror"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/tofu"
)
// Filesystem is a full state manager that uses a file in the local filesystem
@ -226,7 +226,7 @@ func (s *Filesystem) writeState(state *states.State, meta *SnapshotMeta) error {
// PersistState is an implementation of Persister that does nothing because
// this type's Writer implementation does its own persistence.
func (s *Filesystem) PersistState(schemas *opentf.Schemas) error {
func (s *Filesystem) PersistState(schemas *tofu.Schemas) error {
return nil
}

View File

@ -7,9 +7,9 @@ package statemgr
// operations done against full state managers.
import (
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/states/statefile"
"github.com/opentofu/opentofu/internal/tofu"
"github.com/opentofu/opentofu/version"
)
@ -48,7 +48,7 @@ func RefreshAndRead(mgr Storage) (*states.State, error) {
// out quickly with a user-facing error. In situations where more control
// is required, call WriteState and PersistState on the state manager directly
// and handle their errors.
func WriteAndPersist(mgr Storage, state *states.State, schemas *opentf.Schemas) error {
func WriteAndPersist(mgr Storage, state *states.State, schemas *tofu.Schemas) error {
err := mgr.WriteState(state)
if err != nil {
return err

View File

@ -4,8 +4,8 @@
package statemgr
import (
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tofu"
)
// LockDisabled implements State and Locker but disables state locking.
@ -33,7 +33,7 @@ func (s *LockDisabled) RefreshState() error {
return s.Inner.RefreshState()
}
func (s *LockDisabled) PersistState(schemas *opentf.Schemas) error {
func (s *LockDisabled) PersistState(schemas *tofu.Schemas) error {
return s.Inner.PersistState(schemas)
}

View File

@ -6,8 +6,8 @@ package statemgr
import (
version "github.com/hashicorp/go-version"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tofu"
)
// Persistent is a union of the Refresher and Persistent interfaces, for types
@ -81,7 +81,7 @@ type Refresher interface {
// state. For example, when representing state in an external JSON
// representation.
type Persister interface {
PersistState(*opentf.Schemas) error
PersistState(*tofu.Schemas) error
}
// PersistentMeta is an optional extension to Persistent that allows inspecting

View File

@ -7,8 +7,8 @@ import (
"errors"
"sync"
"github.com/opentofu/opentofu/internal/opentf"
"github.com/opentofu/opentofu/internal/states"
"github.com/opentofu/opentofu/internal/tofu"
)
// NewFullFake returns a full state manager that really only supports transient
@ -65,7 +65,7 @@ func (m *fakeFull) RefreshState() error {
return m.t.WriteState(m.fakeP.State())
}
func (m *fakeFull) PersistState(schemas *opentf.Schemas) error {
func (m *fakeFull) PersistState(schemas *tofu.Schemas) error {
return m.fakeP.WriteState(m.t.State())
}
@ -131,7 +131,7 @@ func (m *fakeErrorFull) RefreshState() error {
return errors.New("fake state manager error")
}
func (m *fakeErrorFull) PersistState(schemas *opentf.Schemas) error {
func (m *fakeErrorFull) PersistState(schemas *tofu.Schemas) error {
return errors.New("fake state manager error")
}

Some files were not shown because too many files have changed in this diff Show More