Skip to content

Commit

Permalink
feat: added environment variable passthrough (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
madhuravius authored Jul 22, 2022
1 parent 5bc8d7f commit 71ac5eb
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/test_data/01_basic_flow_will_pass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ steps:
description: starting the example flow
command: echo
args:
- Starting
- Starting on ${TERM}
- label: waiting
command: sleep
description: sleeping for 1 second
Expand Down
15 changes: 15 additions & 0 deletions docs/02_yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ By default, `clingy init` will place a `.clingy.yaml` file in your present worki
* `label` - a label to label the entire clingy workflow
* `description` - provide a description for the clingy workflow

## Environment variables

If you have environment variables you wish to pass into the YAML, you can do so with the following
`${ENVIRONMENT_VARIABLE}` in your YAML. For example:

```yaml
steps:
- command: <INSERT A COMMAND HERE>
args:
- ${ENVIRONMENT_VARIABLE_HERE} # should correctly be substituted on use
```
There is an example in [this file](https://github.com/madhuravius/clingy/blob/main/cmd/test_data/01_basic_flow_will_pass.yaml)
utilizing `${TERM}`.

## Steps

### Command
Expand Down
Binary file modified docs/example-outputs/html-simple/0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example-outputs/html-simple/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example-outputs/html-simple/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example-outputs/html-simple/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example-outputs/images-only/0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example-outputs/images-only/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example-outputs/images-only/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example-outputs/images-only/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions lib/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ func ParseClingyFile(logger *log.Logger, fileName string) (*ClingyTemplate, erro
return nil, err
}

// hydrate the yaml data from environment variables in parent context
data = []byte(os.ExpandEnv(string(data)))

var clingyData ClingyTemplate
if err = yaml.Unmarshal(data, &clingyData); err != nil {
return nil, err
Expand Down

0 comments on commit 71ac5eb

Please sign in to comment.