A base class for performing a terraform
execution.
Modifiers | Name | Description |
---|---|---|
protected static java.lang.String |
JSON_FORMAT |
Command-line parameter for JSON output. |
protected static java.lang.String |
NO_COLOR |
Command-line parameter for no colour. |
Constructor and description |
---|
protected AbstractTerraformTask
(java.lang.String cmd, java.util.List<java.lang.Class> configExtensions, java.util.List<TerraformExtensionConfigTypes> terraformConfigExtensions, java.lang.String workspaceName)
|
Type Params | Return Type | Name and description |
---|---|---|
|
protected void |
addBooleanCmdLineOption(TerraformExecSpec execSpec, java.lang.String optionName, boolean value) Adds a boolean command-line option with correct formatting to the execution specification. |
|
protected void |
addSessionCredentialsIfAvailable(TerraformExecSpec spec) |
|
protected void |
addVariableFilesToCmdLine(TerraformExecSpec execSpec, FileCollection collection) Add files containing variables to command-line. |
|
protected void |
addVariablesToCmdLine(TerraformExecSpec execSpec, java.util.Map<java.lang.String, java.lang.String> vars) Adds Terraform variables to execution specification. |
|
protected void |
alwaysOutOfDate() Marks task to always be out of date. |
|
protected TerraformExecSpec |
buildExecSpec() |
|
protected void |
doNotSwitchWorkspace() This task is workspace aware, but workspaces should not be switched |
|
protected void |
doesNotRequireSessionCredentials() This specific task does not interact with state and thus does not require any session credentials. |
|
void |
exec() |
|
Provider<java.io.File> |
getDataDir() |
|
Provider<java.io.File> |
getLogDir() |
|
java.lang.String |
getLogLevel() The level at which Terraform should log to a file. |
|
Provider<java.io.File> |
getReportsDir() |
|
protected Provider<java.util.List<java.io.File>> |
getSecondarySources() Additional sources that are not in the source set directory, but for which changes will require a re-run of the task. |
|
Provider<java.io.File> |
getSourceDir() |
|
protected FileCollection |
getSourceFiles() Files in the source directory that act as input files to determine up to date status. |
|
TerraformSourceDirectorySet |
getSourceSet() |
|
protected java.util.Map<java.lang.String, java.lang.String> |
getTerraformEnvironment() |
|
protected TerraformMajorVersion |
getTerraformMajorVersion() Tries to determine the current terraform version group |
|
protected Provider<java.io.File> |
getWorkingDirForCommand() |
|
java.lang.String |
getWorkspaceName() The workspace name. |
|
protected boolean |
hasWorkspaces() Indicated whether this task is associated with a source set which has workspaces other than just default. |
|
protected java.util.Map<java.lang.String, java.lang.Boolean> |
listWorkspaces() Lists the workspaces as currently known to Terraform |
|
protected java.lang.String |
runWorkspaceSubcommand(java.lang.String cmd, java.lang.String... args) Runs a terraform workspace subcommand. |
|
void |
setLogLevel(java.lang.String lvl) |
|
void |
setLogLevel(org.gradle.api.logging.LogLevel lvl) |
|
void |
setLogProgress(boolean state) Whether to log progress to the directory specified in getLogDir. |
|
void |
setSourceSet(java.lang.Object source) @param source Source set of anything that can be resolved using StringUtils#stringize(Object s)#stringize(Object s) and looked up as a Terraform source set. |
|
protected void |
supportsAutoApprove() To be called from tasks where the command supports auto-approve . |
|
protected void |
supportsColor(boolean withColor = true) To be called from tasks where the command supports no-color . |
|
protected void |
supportsForce() |
|
protected void |
supportsInputs() To be called from tasks where the command supports input . |
|
protected void |
supportsYes() To be called from tasks where the command supports yes . |
|
protected void |
switchWorkspace() Switches workspaces to the correct one if the source set has workspaces and the current workspace is not the correct one. |
|
protected Provider<AbstractTerraformTask> |
taskProvider(java.lang.String command) Provider to another Terraform task. |
|
java.lang.String |
terraformPath(java.lang.Object file) Converts a file path to a format suitable for interpretation by Terraform on the appropriate platform. |
|
void |
unsetLogLevel() |
|
void |
useAwsEnvironment() Adds AWS environmental variables to Terraform runtime environment. |
Command-line parameter for JSON output.
Command-line parameter for no colour.
command
- Command to be executed. See https://www.terraform.io/docs/commands/index.html for details.configExtensions
- Configuration extensions to be added to this task.terraformConfigExtensions
- Configuration extensions that are added to the terraform task extension.workspaceName
- Name of workspace this task is associated with. Set to null
for tasks that are
workspace-agnosticAdds a boolean command-line option with correct formatting to the execution specification.
execSpec
- ExecSpec to configureoptionName
- Name of optionvalue
- Boolean valueAdd files containing variables to command-line.
execSpec
- Specification to be configuredcollection
- Collection of files containing variables.Adds Terraform variables to execution specification.
execSpec
- Specification to be configured.vars
- Map of variables to be added.Marks task to always be out of date. Calls this from the constructor of Terraform task types that should always be out of date.
This task is workspace aware, but workspaces should not be switched
This specific task does not interact with state and thus does not require any session credentials.
The level at which Terraform should log to a file.
null
signifying that logging is switched off.Additional sources that are not in the source set directory, but for which changes will require a re-run of the task. This includes files such as local modules or files that provide variables directly or indirectly.
Files in the source directory that act as input files to determine up to date status.
Tries to determine the current terraform version group
The workspace name.
null
for workspace-agnostic tasks.Indicated whether this task is associated with a source set which has workspaces other than just default.
true
if there are workspaces. If the task is workspace-agnostic it will return false
even if the associated sourceset has workspaces.Lists the workspaces as currently known to Terraform
Runs a terraform workspace
subcommand.
cmd
- Subcommand to run.Whether to log progress to the directory specified in getLogDir.
state
- true
to log progress
source
- Source set of anything that can be resolved using StringUtils#stringize(Object s)#stringize(Object s)
and looked up as a Terraform source set. To be called from tasks where the command supports auto-approve
.
To be called from tasks where the command supports no-color
.
Will get set if --console=plain was provided to Gradle
withColor
- If set to false
, the task will always run without color output. To be called from tasks where the command supports input
.
To be called from tasks where the command supports yes
.
Switches workspaces to the correct one if the source set has workspaces and the current workspace is not the correct one. If no additional workspace or the task is workspace agnostic, then it will do-nothing.
Provider to another Terraform task.
command
- Terraform command.Converts a file path to a format suitable for interpretation by Terraform on the appropriate platform.
file
- Object that can be converted using project.file
.Adds AWS environmental variables to Terraform runtime environment.
Groovy Documentation