title: Use yq to substitute string in a yaml file
body: <p>I am trying to substitute all substrings in a yaml file with yq.</p>
  <p>File:</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    labels:
      app: &lt;SOME_NAME&gt;
    name: &lt;SOME_NAME&gt;
    namespace: default
  spec:
    progressDeadlineSeconds: 600
    replicas: 1
    revisionHistoryLimit: 10
    selector:
      matchLabels:
        app: &lt;SOME_NAME&gt;
    strategy:
      rollingUpdate:
        maxSurge: 25%
        maxUnavailable: 25%
      type: RollingUpdate
    template:
      metadata:
        labels:
          app: &lt;SOME_NAME&gt;
      spec:
        serviceAccountName: api
        containers:
          - image: some-docker-repo/&lt;SOME_NAME&gt;:latest
  </code></pre>
  <p>Right now I am using command like this:</p>
  <pre><code>yq e '
    .metadata.labels.app = &quot;the-name-to-use&quot; |
    .metadata.name = &quot;the-name-to-use&quot; |
    .spec.selector.matchLabels.app = &quot;the-name-to-use&quot; |
    .spec.template.metadata.labels.app = &quot;the-name-to-use&quot; |
    .spec.template.spec.containers[0].image |= sub(&quot;&lt;SOME_NAME&gt;&quot;, &quot;the-name-to-use&quot;)
  ' template.yaml  &gt; result.yaml
  </code></pre>
  <p>But I am sure it can be done as a one-liner. I tried using different variations of</p>
  <pre><code>yq e '.[] |= sub(&quot;&lt;SOME_NAME&gt;&quot;, &quot;the-name-to-use&quot;)' template.yaml  &gt; result.yaml
  </code></pre>
  <p>but I am getting error like</p>
  <pre><code>Error: cannot substitute with !!map, can only substitute strings. Hint: Most often you'll want to use '|=' over '=' for this operation.
  </code></pre>
  <p>Can you please suggest where I might have missed the point?</p>
  <p>As an extra request, how would it look like if there would be 2 substitutions in template file?</p>
  <p>e.x.  &lt;SOME_NAME_1&gt; and &lt;SOME_NAME_2&gt; that need to be substituted with some_var_1 and some_var_2 respectively.</p>