mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
backend folder
This commit is contained in:
parent
e650bab8d7
commit
5626ac6926
@ -2,9 +2,9 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
// Package backend provides interfaces that the CLI uses to interact with
|
||||
// Terraform. A backend provides the abstraction that allows the same CLI
|
||||
// OpenTF. A backend provides the abstraction that allows the same CLI
|
||||
// to simultaneously support both local and remote operations for seamlessly
|
||||
// using Terraform in a team environment.
|
||||
// using OpenTF in a team environment.
|
||||
package backend
|
||||
|
||||
import (
|
||||
@ -55,7 +55,7 @@ var (
|
||||
// InitFn is used to initialize a new backend.
|
||||
type InitFn func() Backend
|
||||
|
||||
// Backend is the minimal interface that must be implemented to enable Terraform.
|
||||
// Backend is the minimal interface that must be implemented to enable OpenTF.
|
||||
type Backend interface {
|
||||
// ConfigSchema returns a description of the expected configuration
|
||||
// structure for the receiving backend.
|
||||
@ -136,7 +136,7 @@ type HostAlias struct {
|
||||
type Enhanced interface {
|
||||
Backend
|
||||
|
||||
// Operation performs a Terraform operation such as refresh, plan, apply.
|
||||
// Operation performs a OpenTF operation such as refresh, plan, apply.
|
||||
// It is up to the implementation to determine what "performing" means.
|
||||
// This DOES NOT BLOCK. The context returned as part of RunningOperation
|
||||
// should be used to block for completion.
|
||||
@ -153,7 +153,7 @@ type Enhanced interface {
|
||||
// Local implements additional behavior on a Backend that allows local
|
||||
// operations in addition to remote operations.
|
||||
//
|
||||
// This enables more behaviors of Terraform that require more data such
|
||||
// This enables more behaviors of OpenTF that require more data such
|
||||
// as `console`, `import`, `graph`. These require direct access to
|
||||
// configurations, variables, and more. Not all backends may support this
|
||||
// so we separate it out into its own optional interface.
|
||||
@ -183,12 +183,12 @@ type Local interface {
|
||||
//
|
||||
// This type is a weird architectural wart resulting from the overly-general
|
||||
// way our backend API models operations, whereby we behave as if all
|
||||
// Terraform operations have the same inputs and outputs even though they
|
||||
// OpenTF operations have the same inputs and outputs even though they
|
||||
// are actually all rather different. The exact meaning of the fields in
|
||||
// this type therefore vary depending on which OperationType was passed to
|
||||
// Local.Context in order to create an object of this type.
|
||||
type LocalRun struct {
|
||||
// Core is an already-initialized Terraform Core context, ready to be
|
||||
// Core is an already-initialized OpenTF Core context, ready to be
|
||||
// used to run operations such as Plan and Apply.
|
||||
Core *terraform.Context
|
||||
|
||||
@ -217,7 +217,7 @@ type LocalRun struct {
|
||||
Plan *plans.Plan
|
||||
}
|
||||
|
||||
// An operation represents an operation for Terraform to execute.
|
||||
// An operation represents an operation for OpenTF to execute.
|
||||
//
|
||||
// Note that not all fields are supported by all backends and can result
|
||||
// in an error if set. All backend implementations should show user-friendly
|
||||
@ -225,13 +225,13 @@ type LocalRun struct {
|
||||
// backend doesn't support a PlanId being set.
|
||||
//
|
||||
// The operation options are purposely designed to have maximal compatibility
|
||||
// between Terraform and Terraform Servers (a commercial product offered by
|
||||
// between OpenTF and OpenTF Servers (a commercial product offered by
|
||||
// HashiCorp). Therefore, it isn't expected that other implementation support
|
||||
// every possible option. The struct here is generalized in order to allow
|
||||
// even partial implementations to exist in the open, without walling off
|
||||
// remote functionality 100% behind a commercial wall. Anyone can implement
|
||||
// against this interface and have Terraform interact with it just as it
|
||||
// would with HashiCorp-provided Terraform Servers.
|
||||
// against this interface and have OpenTF interact with it just as it
|
||||
// would with HashiCorp-provided OpenTF Servers.
|
||||
type Operation struct {
|
||||
// Type is the operation to perform.
|
||||
Type OperationType
|
||||
@ -315,7 +315,7 @@ type Operation struct {
|
||||
}
|
||||
|
||||
// HasConfig returns true if and only if the operation has a ConfigDir value
|
||||
// that refers to a directory containing at least one Terraform configuration
|
||||
// that refers to a directory containing at least one OpenTF configuration
|
||||
// file.
|
||||
func (o *Operation) HasConfig() bool {
|
||||
return o.ConfigLoader.IsConfigDir(o.ConfigDir)
|
||||
|
@ -60,7 +60,7 @@ func TestReadPathOrContents_TildePath(t *testing.T) {
|
||||
|
||||
func TestRead_PathNoPermission(t *testing.T) {
|
||||
// This skip condition is intended to get this test out of the way of users
|
||||
// who are building and testing Terraform from within a Linux-based Docker
|
||||
// who are building and testing opentf from within a Linux-based Docker
|
||||
// container, where it is common for processes to be running as effectively
|
||||
// root within the container.
|
||||
if u, err := user.Current(); err == nil && u.Uid == "0" {
|
||||
|
@ -12,12 +12,12 @@ import (
|
||||
)
|
||||
|
||||
// CLI is an optional interface that can be implemented to be initialized
|
||||
// with information from the Terraform CLI. If this is implemented, this
|
||||
// with information from the OpenTF CLI. If this is implemented, this
|
||||
// initialization function will be called with data to help interact better
|
||||
// with a CLI.
|
||||
//
|
||||
// This interface was created to improve backend interaction with the
|
||||
// official Terraform CLI while making it optional for API users to have
|
||||
// official OpenTF CLI while making it optional for API users to have
|
||||
// to provide full CLI interaction to every backend.
|
||||
//
|
||||
// If you're implementing a Backend, it is acceptable to require CLI
|
||||
@ -71,7 +71,7 @@ type CLIOpts struct {
|
||||
StateBackupPath string
|
||||
|
||||
// ContextOpts are the base context options to set when initializing a
|
||||
// Terraform context. Many of these will be overridden or merged by
|
||||
// OpenTF context. Many of these will be overridden or merged by
|
||||
// Operation. See Operation for more details.
|
||||
ContextOpts *terraform.ContextOpts
|
||||
|
||||
@ -87,7 +87,7 @@ type CLIOpts struct {
|
||||
// automated system rather than directly at a command prompt.
|
||||
//
|
||||
// This is a hint not to produce messages that expect that a user can
|
||||
// run a follow-up command, perhaps because Terraform is running in
|
||||
// run a follow-up command, perhaps because OpenTF is running in
|
||||
// some sort of workflow automation tool that abstracts away the
|
||||
// exact commands that are being run.
|
||||
RunningInAutomation bool
|
||||
|
@ -6,7 +6,7 @@ package backend
|
||||
//go:generate go run golang.org/x/tools/cmd/stringer -type=OperationType operation_type.go
|
||||
|
||||
// OperationType is an enum used with Operation to specify the operation
|
||||
// type to perform for Terraform.
|
||||
// type to perform for OpenTF.
|
||||
type OperationType uint
|
||||
|
||||
const (
|
||||
|
@ -167,17 +167,17 @@ func ParseVariableValues(vv map[string]UnparsedVariableValue, decls map[string]*
|
||||
|
||||
// By this point we should've gathered all of the required root module
|
||||
// variables from one of the many possible sources. We'll now populate
|
||||
// any we haven't gathered as unset placeholders which Terraform Core
|
||||
// any we haven't gathered as unset placeholders which OpenTF Core
|
||||
// can then react to.
|
||||
for name, vc := range decls {
|
||||
if isDefinedAny(name, ret, undeclared) {
|
||||
continue
|
||||
}
|
||||
|
||||
// This check is redundant with a check made in Terraform Core when
|
||||
// This check is redundant with a check made in OpenTF Core when
|
||||
// processing undeclared variables, but allows us to generate a more
|
||||
// specific error message which mentions -var and -var-file command
|
||||
// line options, whereas the one in Terraform Core is more general
|
||||
// line options, whereas the one in OpenTF Core is more general
|
||||
// due to supporting both root and child module variables.
|
||||
if vc.Required() {
|
||||
diags = diags.Append(&hcl.Diagnostic{
|
||||
@ -198,9 +198,9 @@ func ParseVariableValues(vv map[string]UnparsedVariableValue, decls map[string]*
|
||||
}
|
||||
} else {
|
||||
// We're still required to put an entry for this variable
|
||||
// in the mapping to be explicit to Terraform Core that we
|
||||
// in the mapping to be explicit to OpenTF Core that we
|
||||
// visited it, but its value will be cty.NilVal to represent
|
||||
// that it wasn't set at all at this layer, and so Terraform Core
|
||||
// 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] = &terraform.InputValue{
|
||||
|
Loading…
Reference in New Issue
Block a user