github.com/Kevinklinger/open_terraform@v0.11.12-beta1/backend/cli.go (about)

     1  package backend
     2  
     3  import (
     4  	"github.com/hashicorp/terraform/terraform"
     5  	"github.com/mitchellh/cli"
     6  	"github.com/mitchellh/colorstring"
     7  )
     8  
     9  // CLI is an optional interface that can be implemented to be initialized
    10  // with information from the Terraform CLI. If this is implemented, this
    11  // initialization function will be called with data to help interact better
    12  // with a CLI.
    13  //
    14  // This interface was created to improve backend interaction with the
    15  // official Terraform CLI while making it optional for API users to have
    16  // to provide full CLI interaction to every backend.
    17  //
    18  // If you're implementing a Backend, it is acceptable to require CLI
    19  // initialization. In this case, your backend should be coded to error
    20  // on other methods (such as State, Operation) if CLI initialization was not
    21  // done with all required fields.
    22  type CLI interface {
    23  	Backend
    24  
    25  	// CLIInit is called once with options. The options passed to this
    26  	// function may not be modified after calling this since they can be
    27  	// read/written at any time by the Backend implementation.
    28  	//
    29  	// This may be called before or after Configure is called, so if settings
    30  	// here affect configurable settings, care should be taken to handle
    31  	// whether they should be overwritten or not.
    32  	CLIInit(*CLIOpts) error
    33  }
    34  
    35  // CLIOpts are the options passed into CLIInit for the CLI interface.
    36  //
    37  // These options represent the functionality the CLI exposes and often
    38  // maps to meta-flags available on every CLI (such as -input).
    39  //
    40  // When implementing a backend, it isn't expected that every option applies.
    41  // Your backend should be documented clearly to explain to end users what
    42  // options have an affect and what won't. In some cases, it may even make sense
    43  // to error in your backend when an option is set so that users don't make
    44  // a critically incorrect assumption about behavior.
    45  type CLIOpts struct {
    46  	// CLI and Colorize control the CLI output. If CLI is nil then no CLI
    47  	// output will be done. If CLIColor is nil then no coloring will be done.
    48  	CLI      cli.Ui
    49  	CLIColor *colorstring.Colorize
    50  
    51  	// StatePath is the local path where state is read from.
    52  	//
    53  	// StateOutPath is the local path where the state will be written.
    54  	// If this is empty, it will default to StatePath.
    55  	//
    56  	// StateBackupPath is the local path where a backup file will be written.
    57  	// If this is empty, no backup will be taken.
    58  	StatePath       string
    59  	StateOutPath    string
    60  	StateBackupPath string
    61  
    62  	// ContextOpts are the base context options to set when initializing a
    63  	// Terraform context. Many of these will be overridden or merged by
    64  	// Operation. See Operation for more details.
    65  	ContextOpts *terraform.ContextOpts
    66  
    67  	// Input will ask for necessary input prior to performing any operations.
    68  	//
    69  	// Validation will perform validation prior to running an operation. The
    70  	// variable naming doesn't match the style of others since we have a func
    71  	// Validate.
    72  	Input      bool
    73  	Validation bool
    74  
    75  	// RunningInAutomation indicates that commands are being run by an
    76  	// automated system rather than directly at a command prompt.
    77  	//
    78  	// This is a hint not to produce messages that expect that a user can
    79  	// run a follow-up command, perhaps because Terraform is running in
    80  	// some sort of workflow automation tool that abstracts away the
    81  	// exact commands that are being run.
    82  	RunningInAutomation bool
    83  }