Skip to content

Empty manifests should result in empty output #364

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

Merged
merged 4 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ func NewGenerateCommand() *cobra.Command {
return err
}

if len(manifests) == 0 {
return fmt.Errorf("No manifests")
}

for _, manifest := range manifests {

template, err := kube.NewTemplate(manifest, cmdConfig.Backend)
Expand Down
2 changes: 1 addition & 1 deletion cmd/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestMain(t *testing.T) {
t.Fatal(err)
}

expected := "No manifests"
expected := ""
if !strings.Contains(string(out), expected) {
t.Fatalf("expected to contain: %s but got %s", expected, out)
}
Expand Down
20 changes: 20 additions & 0 deletions docs/howitworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,23 @@ spec:
annotations:
checksum/secret: <path:secrets/data/db#certs | sha256sum>
```

### Error Handling

#### Detecting errors in chained commands

By default argocd-vault-plugin will read valid kubernetes YAMLs and replace variables with values from Vault.
If a previous command failed and outputs nothing to stdout and AVP reads the input from stdin with
the `-` argument, AVP will forward an empty YAML output downstream. To catch and prevent accientental errors
in chained commands, please use the `-o pipefail` bash option like so:

```bash
$ sh -c '((>&2 echo "some error" && exit 1) | argocd-vault-plugin generate - | kubectl diff -f -); echo $?;'
some error
0

$ set -o pipefail
$ sh -c '((>&2 echo "some error" && exit 1) | argocd-vault-plugin generate - | kubectl diff -f -); echo $?;'
some error
1
```