mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Update internal/command/arguments
to use OpenTF in user-provided strings. (#60)
Signed-off-by: Jakub Martin <kubam@spacelift.io>
This commit is contained in:
parent
52a41ab8f7
commit
1312ca390f
@ -83,7 +83,7 @@ func ParseApply(args []string) (*Apply, tfdiags.Diagnostics) {
|
|||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Plan file or auto-approve required",
|
"Plan file or auto-approve required",
|
||||||
"Terraform cannot ask for interactive approval when -json is set. You can either apply a saved plan file, or enable the -auto-approve option.",
|
"OpenTF cannot ask for interactive approval when -json is set. You can either apply a saved plan file, or enable the -auto-approve option.",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,13 +100,13 @@ func ParseApply(args []string) (*Apply, tfdiags.Diagnostics) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ParseApplyDestroy is a special case of ParseApply that deals with the
|
// ParseApplyDestroy is a special case of ParseApply that deals with the
|
||||||
// "terraform destroy" command, which is effectively an alias for
|
// "opentf destroy" command, which is effectively an alias for
|
||||||
// "terraform apply -destroy".
|
// "opentf apply -destroy".
|
||||||
func ParseApplyDestroy(args []string) (*Apply, tfdiags.Diagnostics) {
|
func ParseApplyDestroy(args []string) (*Apply, tfdiags.Diagnostics) {
|
||||||
apply, diags := ParseApply(args)
|
apply, diags := ParseApply(args)
|
||||||
|
|
||||||
// So far ParseApply was using the command line options like -destroy
|
// So far ParseApply was using the command line options like -destroy
|
||||||
// and -refresh-only to determine the plan mode. For "terraform destroy"
|
// and -refresh-only to determine the plan mode. For "opentf destroy"
|
||||||
// we expect neither of those arguments to be set, and so the plan mode
|
// we expect neither of those arguments to be set, and so the plan mode
|
||||||
// should currently be set to NormalMode, which we'll replace with
|
// should currently be set to NormalMode, which we'll replace with
|
||||||
// DestroyMode here. If it's already set to something else then that
|
// DestroyMode here. If it's already set to something else then that
|
||||||
@ -121,13 +121,13 @@ func ParseApplyDestroy(args []string) (*Apply, tfdiags.Diagnostics) {
|
|||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Invalid mode option",
|
"Invalid mode option",
|
||||||
"The -destroy option is not valid for \"terraform destroy\", because this command always runs in destroy mode.",
|
"The -destroy option is not valid for \"opentf destroy\", because this command always runs in destroy mode.",
|
||||||
))
|
))
|
||||||
case plans.RefreshOnlyMode:
|
case plans.RefreshOnlyMode:
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Invalid mode option",
|
"Invalid mode option",
|
||||||
"The -refresh-only option is not valid for \"terraform destroy\".",
|
"The -refresh-only option is not valid for \"opentf destroy\".",
|
||||||
))
|
))
|
||||||
default:
|
default:
|
||||||
// This is a non-ideal error message for if we forget to handle a
|
// This is a non-ideal error message for if we forget to handle a
|
||||||
@ -136,7 +136,7 @@ func ParseApplyDestroy(args []string) (*Apply, tfdiags.Diagnostics) {
|
|||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Invalid mode option",
|
"Invalid mode option",
|
||||||
fmt.Sprintf("The \"terraform destroy\" command doesn't support %s.", apply.Operation.PlanMode),
|
fmt.Sprintf("The \"opentf destroy\" command doesn't support %s.", apply.Operation.PlanMode),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,16 +10,17 @@ import (
|
|||||||
|
|
||||||
"github.com/hashicorp/hcl/v2"
|
"github.com/hashicorp/hcl/v2"
|
||||||
"github.com/hashicorp/hcl/v2/hclsyntax"
|
"github.com/hashicorp/hcl/v2/hclsyntax"
|
||||||
|
|
||||||
"github.com/placeholderplaceholderplaceholder/opentf/internal/addrs"
|
"github.com/placeholderplaceholderplaceholder/opentf/internal/addrs"
|
||||||
"github.com/placeholderplaceholderplaceholder/opentf/internal/plans"
|
"github.com/placeholderplaceholderplaceholder/opentf/internal/plans"
|
||||||
"github.com/placeholderplaceholderplaceholder/opentf/internal/tfdiags"
|
"github.com/placeholderplaceholderplaceholder/opentf/internal/tfdiags"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultParallelism is the limit Terraform places on total parallel
|
// DefaultParallelism is the limit OpenTF places on total parallel
|
||||||
// operations as it walks the dependency graph.
|
// operations as it walks the dependency graph.
|
||||||
const DefaultParallelism = 10
|
const DefaultParallelism = 10
|
||||||
|
|
||||||
// State describes arguments which are used to define how Terraform interacts
|
// State describes arguments which are used to define how OpenTF interacts
|
||||||
// with state.
|
// with state.
|
||||||
type State struct {
|
type State struct {
|
||||||
// Lock controls whether or not the state manager is used to lock state
|
// Lock controls whether or not the state manager is used to lock state
|
||||||
@ -46,7 +47,7 @@ type State struct {
|
|||||||
BackupPath string
|
BackupPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Operation describes arguments which are used to configure how a Terraform
|
// Operation describes arguments which are used to configure how a OpenTF
|
||||||
// operation such as a plan or apply executes.
|
// operation such as a plan or apply executes.
|
||||||
type Operation struct {
|
type Operation struct {
|
||||||
// PlanMode selects one of the mutually-exclusive planning modes that
|
// PlanMode selects one of the mutually-exclusive planning modes that
|
||||||
@ -54,7 +55,7 @@ type Operation struct {
|
|||||||
// only for an operation that produces a plan.
|
// only for an operation that produces a plan.
|
||||||
PlanMode plans.Mode
|
PlanMode plans.Mode
|
||||||
|
|
||||||
// Parallelism is the limit Terraform places on total parallel operations
|
// Parallelism is the limit OpenTF places on total parallel operations
|
||||||
// as it walks the dependency graph.
|
// as it walks the dependency graph.
|
||||||
Parallelism int
|
Parallelism int
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ type Operation struct {
|
|||||||
// their dependencies.
|
// their dependencies.
|
||||||
Targets []addrs.Targetable
|
Targets []addrs.Targetable
|
||||||
|
|
||||||
// ForceReplace addresses cause Terraform to force a particular set of
|
// ForceReplace addresses cause OpenTF to force a particular set of
|
||||||
// resource instances to generate "replace" actions in any plan where they
|
// resource instances to generate "replace" actions in any plan where they
|
||||||
// would normally have generated "no-op" or "update" actions.
|
// would normally have generated "no-op" or "update" actions.
|
||||||
//
|
//
|
||||||
@ -169,7 +170,7 @@ func (o *Operation) Parse() tfdiags.Diagnostics {
|
|||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Incompatible refresh options",
|
"Incompatible refresh options",
|
||||||
"It doesn't make sense to use -refresh-only at the same time as -refresh=false, because Terraform would have nothing to do.",
|
"It doesn't make sense to use -refresh-only at the same time as -refresh=false, because OpenTF would have nothing to do.",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -25,7 +25,7 @@ type Plan struct {
|
|||||||
// OutPath contains an optional path to store the plan file
|
// OutPath contains an optional path to store the plan file
|
||||||
OutPath string
|
OutPath string
|
||||||
|
|
||||||
// GenerateConfigPath tells Terraform that config should be generated for
|
// GenerateConfigPath tells OpenTF that config should be generated for
|
||||||
// unmatched import target paths and which path the generated file should
|
// unmatched import target paths and which path the generated file should
|
||||||
// be written to.
|
// be written to.
|
||||||
GenerateConfigPath string
|
GenerateConfigPath string
|
||||||
|
@ -18,7 +18,7 @@ type Validate struct {
|
|||||||
// Path.
|
// Path.
|
||||||
TestDirectory string
|
TestDirectory string
|
||||||
|
|
||||||
// NoTests indicates that Terraform should not validate any test files
|
// NoTests indicates that OpenTF should not validate any test files
|
||||||
// included with the module.
|
// included with the module.
|
||||||
NoTests bool
|
NoTests bool
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user