<p>I have a command that generates a secrets file that contains multiple <code>yaml</code> documents separated by <code>---</code> that looks like the following output:</p>
<pre><code>## THE COMMAND THAT RUNS
kubectl kustomize .

## SENDS THE FOLLOWING TO STDOUT
data:
  firebase-dev-credentials.json: |
    MY_BASE_64_CREDENTIALS
kind: Secret
metadata:
  name: nodejs-firebase-credentials-989t6dg7m2
type: Opaque
---
apiVersion: v1
data:
  AGENDA_DATABASE_URL: |
    MY_BASE_64_URL
kind: Secret
metadata:
  name: nodejs-secrets-c229fkh579
type: Opaque
</code></pre>
<p>Now, I have to pipe the <code>yaml</code> document to another command for processing, something like:</p>
<p><code>kubectl kustomize . | kubeseal</code></p>
<p>However, the <code>kubeseal</code> command does not accept multi-document <code>yaml</code>. So I figured I'd need to split the <code>yaml</code> by <code>---</code> and send each individual document to the <code>kubeseal</code> command?</p>
<p>Using <code>bash</code>, what is the preferred approach to accomplish this task?</p>
<p>For example, I suppose I cannot do something simple like this as the <code>stdout</code> is multiline?</p>
<pre><code>export IFS=&quot;;&quot;
sentence=&quot;one;two;three&quot;
for word in $sentence; do
  echo &quot;$word&quot;
done
</code></pre>

Jordan Lewallen
<p>You can pipe through <code>yq eval 'select(di == N)'</code> to select out document N. But really, you wouldn't do this. You would include the already sealed data in your Kustomize config, it's not something you want to run automatically.</p>
