Skip to content

Commit 9f8f17e

Browse files
authored
fix: Empty manifests result in empty output (#364)
1 parent 784da57 commit 9f8f17e

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

cmd/generate.go

-4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ func NewGenerateCommand() *cobra.Command {
7575
return err
7676
}
7777

78-
if len(manifests) == 0 {
79-
return fmt.Errorf("No manifests")
80-
}
81-
8278
for _, manifest := range manifests {
8379

8480
template, err := kube.NewTemplate(manifest, cmdConfig.Backend)

cmd/generate_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestMain(t *testing.T) {
8080
t.Fatal(err)
8181
}
8282

83-
expected := "No manifests"
83+
expected := ""
8484
if !strings.Contains(string(out), expected) {
8585
t.Fatalf("expected to contain: %s but got %s", expected, out)
8686
}

docs/howitworks.md

+20
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,23 @@ spec:
337337
annotations:
338338
checksum/secret: <path:secrets/data/db#certs | sha256sum>
339339
```
340+
341+
### Error Handling
342+
343+
#### Detecting errors in chained commands
344+
345+
By default argocd-vault-plugin will read valid kubernetes YAMLs and replace variables with values from Vault.
346+
If a previous command failed and outputs nothing to stdout and AVP reads the input from stdin with
347+
the `-` argument, AVP will forward an empty YAML output downstream. To catch and prevent accientental errors
348+
in chained commands, please use the `-o pipefail` bash option like so:
349+
350+
```bash
351+
$ sh -c '((>&2 echo "some error" && exit 1) | argocd-vault-plugin generate - | kubectl diff -f -); echo $?;'
352+
some error
353+
0
354+
355+
$ set -o pipefail
356+
$ sh -c '((>&2 echo "some error" && exit 1) | argocd-vault-plugin generate - | kubectl diff -f -); echo $?;'
357+
some error
358+
1
359+
```

0 commit comments

Comments
 (0)