Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invert relationship between Executor and Ansible commands #126

Merged
merged 60 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
cf4cc5c
remove resultsFunc from the Executor interface
apenella Sep 3, 2023
d6a58aa
remove execution capability from AnsiblePlaybookCmd. It generates the…
apenella Nov 17, 2023
9ec968b
remove execution capability from AnsibleAdhocCmd. It generates the co…
apenella Nov 17, 2023
2d7558b
create executable package to wrap os.exec
apenella Nov 17, 2023
0912e87
create result packages to manages to command outputs
apenella Nov 17, 2023
33319b8
create decorator to set the configurations settings to Ansible execution
apenella Nov 17, 2023
d73a2d5
create decorators to manage the stdout callback for ansible executions
apenella Nov 17, 2023
c1b5e4b
remove the write and showduration attributs from ExecutorTimeMeasurement
apenella Nov 17, 2023
b960f02
invert executor-ansiblecmd relationship. Executor requires ansiblecmd…
apenella Nov 17, 2023
3ab1984
tidy go modules
apenella Nov 17, 2023
7e766a1
remove package pkg/stdoutcallback
apenella Nov 17, 2023
439be27
create helper to generate code for the configuration package
apenella Nov 17, 2023
c884467
adapt examples to use executor as main component to execute ansible c…
apenella Nov 17, 2023
bd7ed40
remove ansible configuration functions and const from options package…
apenella Nov 17, 2023
7f59c1f
add the changes related to the inversion of responsabilities on execu…
apenella Nov 18, 2023
42e8c91
enable default execute options tests
apenella Jan 3, 2024
e5c6969
docs: upgrade guide changes on Executor interface
apenella Jan 18, 2024
39d3bcd
docs: update changes on the Executor interface section
apenella Jan 19, 2024
7c91a13
docs: upgrade guide changes on the defaultexecute struct
apenella Jan 19, 2024
1bd7038
docs: upgrade guide 2.x: changes on ansible commands
apenella Jan 26, 2024
b03d05b
docs: draft upgrade guide 2.x
apenella Jan 26, 2024
4b80325
docs: reviewed upgrade_guide_to_2.x with prerelease-1
apenella Feb 2, 2024
c9ae253
explain what motivated the changes in executor interface
apenella Feb 9, 2024
de70b30
docs: working in readme
apenella Feb 9, 2024
54025e7
docs: readme. execute package
apenella Feb 11, 2024
0ccae37
docs: readme. review getting-started guide
apenella Feb 12, 2024
549a983
docs: readme. customizing execution
apenella Feb 16, 2024
7eca5a2
docs: readme. customizing execution
apenella Feb 16, 2024
984f5c0
docs: readme. review document
apenella Feb 17, 2024
ae69e1c
fix conflict
apenella Feb 18, 2024
089c539
update modules
apenella Feb 18, 2024
eb59bc2
docs: readme. add inventory package
apenella Feb 18, 2024
ceb813e
adapt inventory commands to executor interface introduced in v2.0.0
apenella Feb 18, 2024
68484e6
update dependencies
apenella Feb 18, 2024
5106222
Bump golang.org/x/crypto from 0.8.0 to 0.17.0
dependabot[bot] Dec 19, 2023
641f9ff
Release notes v1.3.0
apenella Jan 19, 2024
f2000e4
update installation instructions
apenella Jan 19, 2024
8dcf150
docs: align Inventory title
apenella Jan 24, 2024
f84985d
update dependencies
apenella Feb 18, 2024
e73d3cd
docs: upgrade guide. how to migrate ansibleinventorycmd
apenella Feb 19, 2024
a17a0cf
rename the executor ExecutorWithAnsibleConfigurationSettings to Ansib…
apenella Feb 19, 2024
5aabb7d
Do not use AnsiblePlaybookCmd to test DefaultExecutor
apenella Feb 19, 2024
11777c4
Define the executor AnsibleAdhocExecute for basic purposes
apenella Feb 19, 2024
96705e1
Define the executor AnsibleInventoryExecute for basic purposes
apenella Feb 19, 2024
02b2be4
Define the executor AnsiblePlaybookExecute for basic purposes
apenella Feb 19, 2024
ddc3347
rename Options attribute to PlaybookOptions
apenella Feb 19, 2024
e255ea8
rename Options attribute to AdhocOptions
apenella Feb 19, 2024
19d6c47
rename Options attribute to InventoryOptions
apenella Feb 19, 2024
d74558b
update release notes
apenella Feb 19, 2024
210afe8
docs: readme. include specific command executors description
apenella Feb 20, 2024
e40ba72
add tests to specific command executors
apenella Feb 21, 2024
1dbda2f
Define all adhoc options to ansibleAdhocOptions struct
apenella Feb 26, 2024
36ef1f7
Define all ansible-playbook options to ansiblePlaybookOptions struct
apenella Feb 27, 2024
17cb02a
remove options package
apenella Feb 27, 2024
ec53a5d
docs: remove references to options package elements
apenella Feb 27, 2024
8e0fe26
Use options pattern to setup AnsibleWithConfigurationSettingsExecute …
apenella Feb 28, 2024
e9c7ae0
create the workflowexecute component
apenella Feb 29, 2024
33b9a2d
small improvements proposed by linter
apenella Feb 29, 2024
9a3f4de
Include workflow package to the readme
apenella Feb 29, 2024
2fe6b27
2.0.0-rc.1: release notes
apenella Feb 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,75 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v2.0.0-rc.1

Version 2.0.0 of *go-ansible* introduces several disruptive changes. Read the upgrade guide carefully before proceeding with the upgrade.

### BREAKING CHANGES

> **Note**
> The latest major version of _go-ansible_, version _2.x_, introduced significant and breaking changes. If you are currently using a version prior to _2.x_, please refer to the [upgrade guide](https://github.com/apenella/go-ansible/blob/master/docs/upgrade_guide_to_2.x.md) for detailed information on how to migrate to version _2.x_.

- The relationship between the executor and `AnsiblePlaybookCmd` / `AnsibleAdhocCmd` / `AnsibleInvetoryCmd` have undergone important changes.
- **Inversion of responsabilities**: The executor is now responsible for executing external commands, while `AnsiblePlaybookCmd`, `AnsibleInventoryCmd` and `AnsibleAdhocCmd` have cut down its responsibilities, primarily focusing on generating the command to be executed.
- **Method and Attribute Removal**: The following methods and attributes have been removed on `AnsiblePlaybookCmd`, `AnsibleInventoryCmd` and `AnsibleAdhocCmd`:
- The `Run` method.
- The `Exec` and `StdoutCallback` attributes.
- **Attributes Renaming**: The `Options` attribute has been renamed to `PlaybookOptions` in `AnsiblePlaybookCmd`, `AdhocOptions` in `AnsibleAdhocCmd` and `InventoryOptions` in `AnsibleInventoryCmd`.
- The `Executor` interface has undergone a significant signature change. This change entails the removal of the following arguments `resultsFunc` and `options`. The current signature is: `Execute(ctx context.Context) error`.
- The `github.com/apenella/go-ansible/pkg/options` package has been removed. After that deletion the attributes from `AnsibleConnectionOptions` and `AnsiblePrivilegeEscalationOptions` attributes have been moved to the `PlaybookOptions`, `AdhocOptions` and `InventoryOptions` structs.
- The `github.com/apenella/go-ansible/pkg/stdoutcallback` package has been removed. Its responsabilities has been absorbed by two distinc packages `github.com/apenella/go-ansible/pkg/execute/result`, which manages the output of the commands, and `github.com/apenella/go-ansible/pkg/execute/stdoutcallback` that enables the setting of the stdout callback.
- The constants `AnsibleForceColorEnv` and `AnsibleHostKeyCheckingEnv` have been removed from the `github.com/apenella/go-ansible/pkg/options` package.
- The functions `AnsibleForceColor`, `AnsibleAvoidHostKeyChecking` and `AnsibleSetEnv` have been removed from the `github.com/apenella/go-ansible/pkg/options` package.
- The methods `WithWrite` and `withshowduration` has been removed from the `ExecutorTimeMeasurement` decorator. Instead, a new method named `Duration` has been introduced for obtaining the duration of the execution.

### Added

- A new _executor_ `AnsibleAdhocExecute` has been introduced. That _executor_ allows you to create an executor to run `ansible` commands using the default settings of `DefaultExecute`. This _executor_ is located in the `github.com/apenella/go-ansible/pkg/execute/adhoc` package.
- A new _executor_ `AnsibleInventoryExecute` has been introduced. That _executor_ allows you to create an executor to run `ansible-inventory` commands using the default settings of `DefaultExecute`. This _executor_ is located in the `github.com/apenella/go-ansible/pkg/execute/inventory` package.
- A new _executor_ `AnsiblePlaybookExecute` has been introduced. That _executor_ allows you to create an executor to run `ansible-playbook` commands using the default settings of `DefaultExecute`. This _executor_ is located in the `github.com/apenella/go-ansible/pkg/execute/playbook` package.
- A new interface `Commander` has been introduced in the `github.com/apenella/go-ansible/pkg/execute` package. This interface defines the criteria for a struct to be compliant in generating execution commands.
- A new interface `Executabler` has been introduced in the `github.com/apenella/go-ansible/pkg/execute` package. This interface defines the criteria for a struct to be compliant in executing external commands.
- A new interface `ExecutorEnvVarSetter` in `github.com/apenella/go-ansible/pkg/execute/configuration` that defines the criteria for a struct to be compliant in setting Ansible configuration.
- A new interface `ExecutorStdoutCallbackSetter` has been introduced in the `github.com/apenella/go-ansible/pkg/execute/stdoutcallback` package. This interface defines the criteria for a struct to be compliant in setting an executor that accepts the stdout callback configuration for Ansible executions.
- A new interface named `ResultsOutputer` has been introduced in the `github.com/apenella/go-ansible/pkg/execute/result` pacakge. This interface defines the criteria for a struct to be compliant in printing execution results.
- A new package `github.com/apenella/go-ansible/internal/executable/os/exec` has been introduced. This package serves as a wrapper for `os.exec`.
- A new package `github.com/apenella/go-ansible/pkg/execute/configuration` that incldues the `ExecutorWithAnsibleConfigurationSettings` struct, which acts as a decorator that facilitates the configuration of Ansible settings within the executor.
- A new package `github.com/apenella/go-ansible/pkg/execute/result/default` has been introduced. This package offers the default component for printing execution results. It supersedes the `DefaultStdoutCallbackResults` function that was previously defined in the `github.com/apenella/go-ansible/pkg/stdoutcallback` package.
- A new package `github.com/apenella/go-ansible/pkg/execute/result/json` has been introduced. This package offers the component for printing execution results from the JSON stdout callback. It supersedes the `JSONStdoutCallbackResults` function that was previously defined in the `github.com/apenella/go-ansible/pkg/stdoutcallback` package.
- A new package `github.com/apenella/go-ansible/pkg/execute/stdoutcallback`. This package offers multiple decorators designed to set the stdout callback for Ansible executions.
- A new package `github.com/apenella/go-ansible/pkg/execute/workflow` has been introduced. This package allows you to define a workflow for executing multiple commands in a sequence.
- An utility to generate the code for the configuration package has been introduced. This utility is located in the `utils/cmd/configGenerator.go`.

### Changed

- The `AnsibleAdhocCmd` struct has been updated to implement the `Commander` interface.
- The `AnsibleInventoryCmd` struct has been updated to implement the `Commander` interface.
- The `AnsiblePlaybookCmd` struct has been updated to implement the `Commander` interface.
- The `AnsiblePlaybookOptions` and `AnsibleAdhocOptions` structs have been updated to include the attributes from `AnsibleConnectionOptions` and `AnsiblePrivilegeEscalationOptions`.
- The `DefaultExecute` struct has been updated to have a new attribute named `Exec` of type `Executabler` that is responsible for executing external commands.
- The `DefaultExecute` struct has been updated to have a new attribute named `Output` of type `ResultsOutputer` that is responsible for printing the execution's output.
- The `DefaultExecute` struct has been updated to implement the `Executor` interface.
- The `DefaultExecute` struct has been updated to implement the `ExecutorEnvVarSetter` interface.
- The `DefaultExecute` struct has been updated to implement the `ExecutorStdoutCallbackSetter` interface.
- The `Options` attribute in `AnsibleAdhocCmd` struct has been renamed to `AdhocOptions`.
- The `Options` attribute in `AnsibleInventoryCmd` struct has been renamed to `InventoryOptions`.
- The `Options` attribute in `AnsiblePlaybookCmd` struct has been renamed to `PlaybookOptions`.
- The examples has been adapted to use executor as the component to execute Ansible commands.
- The package `github.com/apenella/go-ansible/pkg/stdoutcallback/result/transformer` has been moved to `github.com/apenella/go-ansible/pkg/execute/result/transformer`.

### Removed

- The `Exec` attribute has been removed from `AnsiblePlaybookCmd` and `AdhocPlaybookCmd`.
- The `github.com/apenella/go-ansible/pkg/options` package has been removed. After the `AnsibleConnectionOptions` and `AnsiblePrivilegeEscalationOptions` structs are not available anymore.
- The `github.com/apenella/go-ansible/pkg/stdoutcallback` package has been removed.
- The `Run` method has been removed from the `AnsiblePlaybookCmd` and `AdhocPlaybookCmd` structs.
- The `ShowDuration` attribute in the `DefaultExecute` struct has been removed.
- The `StdoutCallback` attribute has been removed from `AnsiblePlaybookCmd` and `AdhocPlaybookCmd`.
- The constants `AnsibleForceColorEnv` and `AnsibleHostKeyCheckingEnv` have been removed from the `github.com/apenella/go-ansible/pkg/options` package.
- The functions `AnsibleForceColor`, `AnsibleAvoidHostKeyChecking` and `AnsibleSetEnv` have been removed from the `github.com/apenella/go-ansible/pkg/options` package.
- The methods `WithWrite` and `withshowduration` have been removed from the `ExecutorTimeMeasurement` decorator.

## v1.3.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ If you would like to contribute code to go-ansible, please follow these steps:

1. Create a new branch for your changes.
2. Make your changes.
3. Submit a pull request.
3. Submit a pull request with a proper description of the introduced changes, features, etc.

Please ensure that your code adheres to our coding standards, that all tests pass before submitting a pull request, and you update the project [README](https://github.com/apenella/go-ansible/blob/master/README.md) and the [RELEASE_NOTES](https://github.com/apenella/go-ansible/blob/master/RELEASE_NOTES.md).

Expand Down
Loading
Loading