v0.6.0
This commit is contained in:
@ -36,27 +36,27 @@ commands:
|
||||
- APP=$VAR
|
||||
```
|
||||
|
||||
Values available for this section:
|
||||
Values available for this section **(case-sensitive)**:
|
||||
|
||||
| name | notes | type | required
|
||||
| --- | --- | --- | --- |
|
||||
| `cmd` | Defines the command to execute | `string` | yes |
|
||||
| `args` | Defines the arguments to the command | `[]string` | no |
|
||||
| `Args` | Defines the arguments to the command | `[]string` | no |
|
||||
| `environment` | Defines evironment variables for the command | `[]string` | no |
|
||||
| `type` | May be `scriptFile` or `script`. Runs script from local machine on remote. Only applicable when `host` is defined. | `string` | no |
|
||||
| `type` | May be `scriptFile`, `script`, or `package`. Runs script from local machine on remote. `Package` is the only one that can be run on local and remote hosts. | `string` | no |
|
||||
| `getOutput` | Command(s) output is in the notification(s) | `bool` | no |
|
||||
| `host` | If not specified, the command will execute locally. | `string` | no |
|
||||
| `scriptEnvFile` | When type is `scriptFile`, the script is appended to this file. | `string` | no |
|
||||
| `shell` | Only applicable when host is not specified | `string` | no |
|
||||
| `hooks` | Hooks are used at the end of the individual command. Must be another command. | `[]string` | no |
|
||||
| `scriptEnvFile` | When type is `scriptFile` or `script`, this file is prepended to the input. | `string` | no |
|
||||
| `shell` | Run the command in the shell | `string` | no |
|
||||
| `hooks` | Hooks are used at the end of the individual command. Must have at least `error`, `success`, or `final`. | `map[string][]string` | no |
|
||||
|
||||
#### cmd
|
||||
|
||||
cmd must be a valid command or script to execute.
|
||||
|
||||
#### args
|
||||
#### Args
|
||||
|
||||
args must be arguments to cmd as they would be on the command-line:
|
||||
args must be arguments to cmd as they would be passed on the command-line:
|
||||
|
||||
```sh
|
||||
cmd [arg1 arg2 ...]
|
||||
@ -65,7 +65,7 @@ cmd [arg1 arg2 ...]
|
||||
Define them in an array:
|
||||
|
||||
```yaml
|
||||
args:
|
||||
Args:
|
||||
- arg1
|
||||
- arg2
|
||||
- arg3
|
||||
@ -94,14 +94,14 @@ If I assign a value to host as `host: web-prod` and don't specify this value in
|
||||
|
||||
### shell
|
||||
|
||||
If shell is defined and host is NOT defined, the command will run in the specified shell.
|
||||
If shell is defined, the command will run in the specified shell.
|
||||
Make sure to escape any shell input.
|
||||
|
||||
### scriptEnvFile
|
||||
|
||||
Path to a file.
|
||||
|
||||
When type is specified, the script is appended to this file.
|
||||
When type is `script` or `scriptFile` , the script is appended to this file.
|
||||
|
||||
This is useful for specifying environment variables or other things so they don't have to be included in the script.
|
||||
|
||||
@ -113,6 +113,8 @@ If `type` is `script`, `cmd` is used as the script.
|
||||
|
||||
If `type` is `scriptFile`, cmd must be a script file.
|
||||
|
||||
If `type` is `package`, there are additional fields that must be specified.
|
||||
|
||||
### environment
|
||||
|
||||
The environment variables support expansion:
|
||||
@ -143,4 +145,8 @@ command:
|
||||
- successcommand
|
||||
final:
|
||||
- donecommand
|
||||
```
|
||||
```
|
||||
|
||||
### packages
|
||||
|
||||
See the [dedicated page](/config/packages) for package configuration.
|
||||
|
77
docs/content/config/packages.md
Normal file
77
docs/content/config/packages.md
Normal file
@ -0,0 +1,77 @@
|
||||
---
|
||||
title: "Packages"
|
||||
weight: 2
|
||||
---
|
||||
|
||||
This is dedicated to `package` commands. The command `type` field must be `package`. Package is a type that allows one to perform package operations. There are several additional options available when `type` is `package`:
|
||||
|
||||
| name | notes | type | required |
|
||||
| --- | --- | --- | --- |
|
||||
| `packageName` | The name of a package to be modified. | `string` | yes |
|
||||
| `packageManager` | The name of the package manger to be used. | `string` | yes |
|
||||
| `packageOperation` | The type of operation to be perform. | `string` | yes |
|
||||
| `packageVersion` | The version of a package to be modified. | `string` | no |
|
||||
|
||||
|
||||
#### example
|
||||
|
||||
The following is an example of a package command:
|
||||
|
||||
```yaml
|
||||
update-docker:
|
||||
type: package
|
||||
shell: zsh
|
||||
packageName: docker-ce
|
||||
packageManager: apt
|
||||
packageOperation: install
|
||||
host: debian-based-host
|
||||
```
|
||||
|
||||
#### packageOperation
|
||||
|
||||
The following package operations are supported:
|
||||
|
||||
- `install`
|
||||
- `remove`
|
||||
- `upgrade`
|
||||
|
||||
#### packageManager
|
||||
|
||||
The following package managers are recognized:
|
||||
|
||||
- `apt`
|
||||
- `yum`
|
||||
- `dnf`
|
||||
|
||||
#### package command args
|
||||
|
||||
You can add additional arguments using the standard `Args` key. This is useful for adding more packages.
|
||||
|
||||
### Development
|
||||
|
||||
The PackageManager interface provides an easy to enforce functions and options. There are two interfaces, `PackageManager` and `ConfigurablePackageManager` in the directory `pkg/pkgman`. Go's import-cycle "feature" caused me to implement functional options using a third interface. `PackageManagerOption`is a function that takes an interface.
|
||||
|
||||
#### PackageManager
|
||||
|
||||
```go
|
||||
// PackageManager is an interface used to define common package commands. This shall be implemented by every package.
|
||||
type PackageManager interface {
|
||||
Install(pkg, version string, args []string) (string, []string)
|
||||
Remove(pkg string, args []string) (string, []string)
|
||||
Upgrade(pkg, version string) (string, []string) // Upgrade a specific package
|
||||
UpgradeAll() (string, []string)
|
||||
|
||||
// Configure applies functional options to customize the package manager.
|
||||
Configure(options ...pkgcommon.PackageManagerOption)
|
||||
}
|
||||
```
|
||||
|
||||
There are a few functional options that should be implemented using the `ConfigurablePackageManager` interface:
|
||||
|
||||
```go
|
||||
// ConfigurablePackageManager defines methods for setting configuration options.
|
||||
type ConfigurablePackageManager interface {
|
||||
SetUseAuth(useAuth bool)
|
||||
SetAuthCommand(authCommand string)
|
||||
}
|
||||
```
|
Reference in New Issue
Block a user