From 61e116b4a2279d970d515f176061f9979da26c80 Mon Sep 17 00:00:00 2001 From: Aleix Penella Date: Fri, 15 Mar 2024 08:03:40 +0100 Subject: [PATCH] Include in readme file and upgrade guide references to command structs constructors --- README.md | 79 +++++++++------- docs/upgrade_guide_to_2.x.md | 125 ++++++++++++++------------ pkg/adhoc/ansibleAdhocOptions_test.go | 1 - 3 files changed, 119 insertions(+), 86 deletions(-) diff --git a/README.md b/README.md index 4c29249..1540daf 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ A _command generator_ or a _commander_ is responsible for generating the command ### Results Handler -A _results handler_ or an _results outputer_ is responsible for managing the output of the command execution. The library includes two output mechanisms: the [DefaultResults](#defaultexecute-struct) and the [JSONStdoutCallbackResults](#jsonstdoutcallbackresults-struct) structs. +A _results handler_ or a _results outputer_ is responsible for managing the output of the command execution. The library includes two output mechanisms: the [DefaultResults](#defaultexecute-struct) and the [JSONStdoutCallbackResults](#jsonstdoutcallbackresults-struct) structs. ## Getting Started @@ -122,7 +122,7 @@ This section will guide you through the step-by-step process of using the _go-an Before proceeding, ensure you have installed the latest version of the _go-ansible_ library. If not, please refer to the [Installation section](#install) for instructions. -To create an application that launches the `ansible-playbook` command you need to create an [AnsiblePlaybookCmd](#ansibleplaybookcmd-struct) struct. This struct generates the _Ansible_ command to be run. Then, you need to execute the command usingng an [executor](#executor). In that guided example, you will use the [DefaultExecute](#defaultexecute-struct) executor, an _executor_ provided by the _go-ansible_ library. +To create an application that launches the `ansible-playbook` command you need to create an [AnsiblePlaybookCmd](#ansibleplaybookcmd-struct) struct. This struct generates the _Ansible_ command to be run. Then, you need to execute the command using an [executor](#executor)](#executor). In that guided example, you will use the [DefaultExecute](#defaultexecute-struct) executor, an _executor_ provided by the _go-ansible_ library. ### Create the _AnsiblePlaybookCmd_ struct @@ -141,10 +141,11 @@ ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{ Finally, create the [AnsiblePlaybookCmd](#ansibleplaybookcmd-struct) struct that generates the command to execute the playbook `site.yml` using the `ansible-playbook` command: ```go -playbookCmd := &playbook.AnsiblePlaybookCmd{ - Playbook: "site.yml", - PlaybookOptions: ansiblePlaybookOptions, -} +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml", "site2.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) + ``` Once the `AnsiblePlaybookCmd` is defined, provide the command to an [executor](#executor) to run the command. @@ -206,6 +207,12 @@ The `github.com/apenella/go-ansible/v2/pkg/adhoc` package facilitates the genera The `AnsibleAdhocCmd` struct enables the generation of _Ansible ad-hoc_ commands. It implements the [Commander](#commander-interface) interface, so its method `Command` returns an array of strings that represents the command to be executed. An executor can use it to create the command to be executed. +The package provides the `NewAnsibleAdhocCmd` function to create a new instance of the `AnsibleAdhocCmd` struct. The function accepts a list of options to customize the ad-hoc command. The following functions are available: + +- `WithAdhocOptions(options *AnsibleAdhocOptions) AdhocOptionsFunc`: Set the ad-hoc options for the command. +- `WithBinary(binary string) AdhocOptionsFunc`: Set the binary for the ad-hoc command. +- `WithPattern(pattern string) AdhocOptionsFunc`: Set the pattern for the ad-hoc command. + The following code snippet demonstrates how to use the `AnsibleAdhocCmd` struct to generate an ad-hoc command: ```go @@ -218,10 +225,10 @@ ansibleAdhocOptions := &adhoc.AnsibleAdhocOptions{ } } -adhocCmd := &adhoc.AnsibleAdhocCmd{ - Pattern: "all", - Options: ansibleAdhocOptions, -} +adhocCmd := adhoc.NewAnsibleAdhocCmd( + adhoc.WithPattern("all"), + adhoc.WithAdhocOptions(ansibleAdhocOptions), +) // Generate the command to be executed cmd, err := adhocCmd.Command() @@ -320,10 +327,10 @@ The snippet below shows how to customize the `DefaultExecute` executor using the ```go // PlaybookCmd is the Commander responsible for generating the command to execute -playbookCmd := &playbook.AnsiblePlaybookCmd{ - Playbook: "site.yml", - PlaygookOptions: ansiblePlaybookOptions, -} +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) // MyExecutabler is an hypothetical implementation of the Executabler interface executabler := &myExecutabler{} @@ -368,10 +375,10 @@ The next code snippet demonstrates how to execute the `ansible-playbook` command ```go // Define the command to execute -playbookCmd := &ansibler.AnsiblePlaybookCmd{ - Playbook: []string{"site.yml"}, - PlaybookOptions: ansiblePlaybookOptions, -} +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) // Define an instance for the new executor and set the options exec := &MyExecutor{ @@ -427,10 +434,10 @@ ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{ Inventory: "127.0.0.1,", } -playbookCmd := &playbook.AnsiblePlaybookCmd{ - Playbooks: []string{"site.yml"}, - PlaybookOptions: ansiblePlaybookOptions, -} +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) exec := configuration.NewAnsibleWithConfigurationSettingsExecute( execute.NewDefaultExecute( @@ -461,10 +468,10 @@ ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{ Inventory: "127.0.0.1,", } -playbookCmd := &playbook.AnsiblePlaybookCmd{ - Playbooks: []string{"site.yml"}, - PlaybookOptions: ansiblePlaybookOptions, -} +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) executorTimeMeasurement := measure.NewExecutorTimeMeasurement( execute.NewDefaultExecute( @@ -695,6 +702,12 @@ The `github.com/apenella/go-ansible/v2/pkg/inventory` package provides the funct The `AnsibleInventoryCmd` struct enables the generation of `ansible-inventory` commands. It implements the [Commander](#commander-interface) interface, so its method `Command` returns an array of strings that represents the command to be executed. An executor can use it to create the command to be executed. +The package provides the `NewAnsibleInventoryCmd` function to create a new instance of the `AnsibleInventoryCmd` struct. The function accepts a list of options to customize the `ansible-inventory` command. The following functions are available: + +- `WithBinary(binary string) InventoryOptionsFunc`: Set the binary for the `ansible-inventory` command. +- `WithInventoryOptions(options *AnsibleInventoryOptions) InventoryOptionsFunc`: Set the inventory options for the command. +- `WithPattern(pattern string) InventoryOptionsFunc`: Set the pattern for the `ansible-inventory` command. + > Note > Unlike other _Ansible_ commands, the `ansible-inventory` command does not provide privilege escalation or connection options, aligning with the functionality of the command itself. @@ -735,6 +748,12 @@ The `github.com/apenella/go-ansible/v2/pkg/playbook` package facilitates the gen The `AnsiblePlaybookCmd` struct enables the generation of _ansible-playbook_ commands. It implements the [Commander](#commander-interface) interface, so its method `Command` returns an array of strings that represents the command to be executed. An executor can use it to create the command to be executed. +The package provides the `NewAnsiblePlaybookCmd` function to create a new instance of the `AnsiblePlaybookCmd` struct. The function accepts a list of options to customize the _ansible-playbook_ command. The following functions are available: + +- `WithBinary(binary string) PlaybookOptionsFunc`: Set the binary for the _ansible-playbook_ command. +- `WithPlaybookOptions(options *AnsiblePlaybookOptions) PlaybookOptionsFunc`: Set the playbook options for the command. +- `WithPlaybooks(playbooks ...string) PlaybookOptionsFunc`: Set the playbooks for the _ansible-playbook_ command. + Next is an example of how to use the `AnsiblePlaybookCmd` struct to generate an _ansible-playbook_ command: ```go @@ -744,10 +763,10 @@ ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{ Inventory: "127.0.0.1,", } -playbookCmd := &playbook.AnsiblePlaybookCmd{ - Playbook: "site.yml", - PlaybookOptions: ansiblePlaybookOptions, -} +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) // Generate the command to be executed cmd, err := playbookCmd.Command() diff --git a/docs/upgrade_guide_to_2.x.md b/docs/upgrade_guide_to_2.x.md index 110aa97..3a3bf77 100644 --- a/docs/upgrade_guide_to_2.x.md +++ b/docs/upgrade_guide_to_2.x.md @@ -6,7 +6,7 @@ This document offers guidance for upgrading from _go-ansible_ _v1.x_ to _v2.x_. The most relevant change is that the package name has been changed from `github.com/apenella/go-ansible` to `github.com/apenella/go-ansible/v2`. So, you need to update your import paths to use the new module name. Another important change to highlight is that command structs no longer execute commands. So, `AnsiblePlaybookCmd` and `AnsibleAdhocCmd` do not require an `Executor` anymore. Instead, the `Executor` is responsible for the command execution. To achieve that, the `Executor` depends on the command structs to generate the commands to execute. -That change is motivated by the need of segregating the command generation from the command execution. Having the `Executor` as the central component of the command execution process allows the `Executor` to be more flexible and customizable. The _go-ansible_ library provides a set of decorator structs to configure the `Executor` with different features, such as stdout callback management, and Ansible configuration settings. +That change is motivated by the need to segregate the command generation from the command execution. Having the `Executor` as the central component of the command execution process allows the `Executor` to be more flexible and customizable. The _go-ansible_ library provides a set of decorator structs to configure the `Executor` with different features, such as stdout callback management, and Ansible configuration settings. Proceed through the following sections to understand the changes in version _2.x_ and learn how to adapt your code accordingly. @@ -53,7 +53,7 @@ The version _v2.x_ introduces several changes in the interfaces used by the _go- ### Added _Cmder_ interface -The `Cmder` interface defined in _github.com/apenella/go-ansible/v2/internal/executable/os/exec_ and it is used to run external commands. The `os/exec` package implements the `Cmder` interface. The [Executabler](#added-executabler-interface)'s `Command` and `CommandContext` methods return a `Cmder` interface. +The `Cmder` interface is defined in _github.com/apenella/go-ansible/v2/internal/executable/os/exec__ and it is used to run external commands. The `os/exec` package implements the `Cmder` interface. The [Executabler](#added-executabler-interface)'s `Command` and `CommandContext` methods return a `Cmder` interface. You can find the definition of the `Cmder` interface below: ```go @@ -101,7 +101,7 @@ type Executabler interface { ### Added _ExecutorEnvVarSetter_ interface -The `ExecutorEnvVarSetter` interface defined in _github.com/apenella/go-ansible/v2/pkg/execute/configuration_ defines an executor interface that you can set environment variables to. It is required by `AnsibleWithConfigurationSettingsExecute` decorator struct. +The `ExecutorEnvVarSetter` interface defined in _github.com/apenella/go-ansible/v2/pkg/execute/configuration_ defines an executor interface to which you can set environment variables. It is required by `AnsibleWithConfigurationSettingsExecute` decorator struct. ```go // ExecutorEnvVarSetter extends the executor interface by adding methods to configure environment variables @@ -191,7 +191,7 @@ Select the appropriate mechanism based on the stdout callback plugin you are usi To replace the _resultsFunc_, introduce an attribute of type `ResultsOutputer` in your executor. Utilize this attribute to print the results output from command execution. For an example of how the `DefaultExecute` struct has been adapted to use a `ResultsOutputer` for printing execution results, refer [Here](#adding-output-attribute-for-printing-execution-results). -You can also read the section [Managing Ansible Stdout Callback](#managing-ansible-stdout-callback) to learn how to benefit of the stdout callback management structs provided by the _go-ansible_ library. +You can also read the section [Managing Ansible Stdout Callback](#managing-ansible-stdout-callback) to learn how to benefit from the stdout callback management structs provided by the _go-ansible_ library. ### Replacing the _options_ argument @@ -208,14 +208,16 @@ In version _v2.x_ you need to instantiate the `DefaultExecute` struct to execute ```go // Define the AnsiblePlaybookCmd and the required options. -playbookCmd := &playbook.AnsiblePlaybookCmd{ - Playbooks: []string{"site.yml", "site2.yml"}, - PlaybookOptions: &playbook.AnsiblePlaybookOptions{ - Connection: "local", - Inventory: "all,", - }, +ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{ + Connection: "local", + Inventory: "all,", } +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml", "site2.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) + // playbookCmd is the Commander responsible for generating the command to execute exec := execute.NewDefaultExecute( execute.WithCmd(playbookCmd), @@ -240,13 +242,16 @@ When instantiating the `DefaultExecute` struct, provide the `Cmd` attribute with ```go // Define the AnsiblePlaybookCmd and the required options. -playbookCmd := &playbook.AnsiblePlaybookCmd{ - Playbooks: []string{"site.yml", "site2.yml"}, - PlaybookOptions: &playbook.AnsiblePlaybookOptions{ - Connection: "local", - Inventory: "all,", - }, +ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{ + Connection: "local", + Inventory: "all,", } + +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml", "site2.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) + // Instanciate a DefaultExecutoe by providing 'playbookCmd' as the Commander. exec := execute.NewDefaultExecute( execute.WithCmd(playbookCmd), @@ -259,20 +264,22 @@ In the above example, `playbookCmd` is of type `Commander`. The `Cmd` value is s The `DefaultExecute` now includes the `Exec` attribute of type `Executabler`. The `Exec` component is responsible for executing external commands. If you do not define the `Exec` attribute, it defaults to using the `OsExec` struct, which wraps the `os/exec` package. -If you need a custom executabler, it must implement the `Executabler` interface. Learn more about the `Executabler` interface [here](#added-executabler-interface). +If you need a custom _executabler_, it must implement the `Executabler` interface. Learn more about the `Executabler` interface [here](#added-executabler-interface). The example below illustrates how to instantiate a `DefaultExecute` struct with a custom `Executabler`: ```go // Define the AnsiblePlaybookCmd and the required options. -playbookCmd := &playbook.AnsiblePlaybookCmd{ - Playbooks: []string{"site.yml", "site2.yml"}, - PlaybookOptions: &playbook.AnsiblePlaybookOptions{ - Connection: "local", - Inventory: "all,", - }, +ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{ + Connection: "local", + Inventory: "all,", } +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml", "site2.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) + // Define a custom Executabler executable := &myCustomExecutabler{} @@ -283,7 +290,7 @@ executor := execute.NewDefaultExecute( ) ``` -In the example, `executable` implements the `Executabler` interface. When creating a new `DefaultExecute`, set the value of `Exec` through the `WithExecutable` function. The `DefaultExecute` will then use executable to execute the command. +In the example, `executable` implements the `Executabler` interface. When creating a new `DefaultExecute`, set the value of `Exec` through the `WithExecutable` function. The `DefaultExecute` will then use the `executable` to execute the command. ### Adding _Output_ attribute for printing execution results @@ -295,13 +302,16 @@ The example below demonstrates how to instantiate a `DefaultExecute` struct with ```go // Define the AnsiblePlaybookCmd and the required options. -playbookCmd := &playbook.AnsiblePlaybookCmd{ - Playbooks: []string{"site.yml", "site2.yml"}, - PlaybookOptions: &playbook.AnsiblePlaybookOptions{ - Connection: "local", - Inventory: "all,", - }, +ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{ + Connection: "local", + Inventory: "all,", } + +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml", "site2.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) + // Define a custom ResultsOutputer output := &myCustomResultsOutputer{} @@ -339,11 +349,11 @@ fmt.Println("Duration: ", exec.Duration().String()) If you configure transformers to modify the output of the execution's results, note that the _transformer_ package in the _go-ansible_ library has been relocated. It was moved from _github.com/apenella/go-ansible/pkg/stdoutcallback/results_ to _github.com/apenella/go-ansible/v2/pkg/execute/result/transformer_. Therefore, ensure that your code is adapted to this updated location. -Refer to section [Changes on the _Transformer_ functions](#changes-on-the-transformer-functions) for more details on how to adapt your code to these changes. +Refer to the section [Changes on](#changes-on-the-transformer-functions) the _Transformer_ functions](#changes-on-the-transformer-functions) for more details on how to adapt your code to these changes. ## Changes on the _AnsiblePlaybookCmd_ struct -The `AnsiblePlaybookCmd` struct has undergone significant changes. It no longer executes commands, instead, it now implements the `Commander` interface, which is responsible for generating commands for execution. This section provides guidance on adapting your code to these changes. +The `AnsiblePlaybookCmd` struct has undergone significant changes. It no longer executes commands, instead, it now implements the `Commander` interface, which is responsible for generating commands for execution. This section guides adapting your code to these changes. ### Renaming the _Options_ attribute @@ -357,14 +367,16 @@ Here's a basic example of running an ansible-playbook command through the `Defau ```go // Define the AnsiblePlaybookCmd and the required options. -playbookCmd := &playbook.AnsiblePlaybookCmd{ - Playbooks: []string{"site.yml", "site2.yml"}, - Options: &playbook.AnsiblePlaybookOptions{ - Connection: "local", - Inventory: "127.0.0.1,", - }, +ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{ + Connection: "local", + Inventory: "127.0.0.1,", } +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml", "site2.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) + // Instanciate a DefaultExecutoe by providing 'playbookCmd' as the Commander exec := execute.NewDefaultExecute( execute.WithCmd(playbookCmd), @@ -387,15 +399,16 @@ Configuring the stdout callback involves setting the environment variable `ANSIB ```go // Define the AnsiblePlaybookCmd and the required options. -playbookCmd := &playbook.AnsiblePlaybookCmd{ - Playbooks: []string{"site.yml", "site2.yml"}, - Connection: "local", - }, - PlaybookOptions: &playbook.AnsiblePlaybookOptions{ - Inventory: "127.0.0.1,", - }, +ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{ + Connection: "local", + Inventory: "127.0.0.1,", } +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml", "site2.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) + // Use the DefaultExecute struct to execute the command exec := execute.NewDefaultExecute( execute.WithCmd(playbookCmd), @@ -443,11 +456,11 @@ Similar to the changes made to the `AnsiblePlaybookCmd` struct, the `AnsibleAdho ## Changes on the _AnsibleInventoryCmd_ struct -The `AnsibleInventoryCmd` have undergone significant changes. It no longer executes commands, instead, it now implements the `Commander` interface, which is responsible for generating commands for execution. To adapt your code to these changes, refer to the guidelines provided in the section [Changes on the _AnsiblePlaybookCmd_ struct](#changes-on-the-ansibleplaybookcmd-struct). +The `AnsibleInventoryCmd` has undergone significant changes. It no longer executes commands, instead, it now implements the `Commander` interface, which is responsible for generating commands for execution. To adapt your code to these changes, refer to the guidelines provided in the section [Changes on the _AnsiblePlaybookCmd_ struct](#changes-on-the-ansibleplaybookcmd-struct). ## Changes on the _Transformer_ functions -In version _v2.0.0_, the _github.com/apenella/go-ansible/pkg/stdoutcallback/results_ package has been removed. This package previously contained the transformer functions responsible for modifying the output lines of the execution's results. This section provides guidance on how to adapt your code to these changes. +In version _v2.0.0_, the _github.com/apenella/go-ansible/pkg/stdoutcallback/results_ package has been removed. This package previously contained the transformer functions responsible for modifying the output lines of the execution's results. This section guides how to adapt your code to these changes. To adapt your code, you should update the imported package to _github.com/apenella/go-ansible/v2/pkg/execute/result/transformer_. This is the new location of the transformer functions. @@ -467,7 +480,7 @@ Configuring the StdoutCallback method involves two steps: - Set the `ANSIBLE_STDOUT_CALLBACK` environment variable to the desired stdout callback plugin name. - Set the method responsible for handling the results output from command execution. The responsibility of setting the StdoutCallback method has shifted to the `Executor` struct, necessitating an adjustment in your code. -To simplify stdout callback configuration, the _go-ansible_ library provides a set of structs dedicated to setting the stdout callback method and results output mechanism. Each struct corresponds to a stdout callback plugin and is available in the _github.com/apenella/go-ansible/v2/pkg/execute/stdoutcallback_ package. The following is a list of available structs: +To simplify the stdout callback configuration, the _go-ansible_ library provides a set of structs dedicated to setting the stdout callback method and results output mechanism. Each struct corresponds to a stdout callback plugin and is available in the _github.com/apenella/go-ansible/v2/pkg/execute/stdoutcallback_ package. The following is a list of available structs: - DebugStdoutCallbackExecute - DefaultStdoutCallbackExecute @@ -506,14 +519,16 @@ Here's an example illustrating how to prepare an executor to set Ansible configu ```go // Define the AnsiblePlaybookCmd and the required options. -playbookCmd := &playbook.AnsiblePlaybookCmd{ - Playbooks: []string{"site.yml", "site2.yml"}, - PlaybookOptions: &playbook.AnsiblePlaybookOptions{ - Connection: "local", - Inventory: "127.0.0.1,", - }, +ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{ + Connection: "local", + Inventory: "127.0.0.1,", } +playbookCmd := playbook.NewAnsiblePlaybookCmd( + playbook.WithPlaybooks("site.yml", "site2.yml"), + playbook.WithPlaybookOptions(ansiblePlaybookOptions), +) + // Instanciate a DefaultExecutoe by providing 'playbookCmd' as the Commander and enabling the Ansible Force Color setting exec := measure.NewExecutorTimeMeasurement( configuration.NewAnsibleWithConfigurationSettingsExecute( @@ -570,7 +585,7 @@ In case you need to enable the _AnsibleHostKeyChecking_ setting, you should use #### Replacing the _AnsibleSetEnv_ function If you used the `AnsibleSetEnv` function to set environment variables for the _executor_, you should replace it by the `AddEnvVar` method. -In case you were using the `AnsibleSetEnv` to set an _Ansible_ configuration setting, it is recommended to use the `AnsibleWithConfigurationSettingsExecute` _executor_ instead. The `AnsibleWithConfigurationSettingsExecute` struct is available in the _github.com/apenella/go-ansible/v2/pkg/execute/configuration_ package, and provides you with multiple functions to configure _Ansible_ settings. +In case you were using the `AnsibleSetEnv` to set an _Ansible_ configuration setting, it is recommended to use the `AnsibleWithConfigurationSettingsExecute` _executor_ instead. The `AnsibleWithConfigurationSettingsExecute` struct is available in the _github.com/apenella/go-ansible/v2/pkg/execute/configuration_ package and provides you with multiple functions to configure _Ansible_ settings. If you were previously using the `AnsibleSetEnv` function to set environment variables for the _executor_, you should replace it with the `AddEnvVar` method. diff --git a/pkg/adhoc/ansibleAdhocOptions_test.go b/pkg/adhoc/ansibleAdhocOptions_test.go index 8df6e26..9e55ab2 100644 --- a/pkg/adhoc/ansibleAdhocOptions_test.go +++ b/pkg/adhoc/ansibleAdhocOptions_test.go @@ -116,7 +116,6 @@ func TestGenerateAnsibleAdhocOptions(t *testing.T) { } assert.Equal(t, expected, opts) - } func TestGenerateExtraVarsCommand(t *testing.T) {