title: Substitute Yaml values with yq by new value as output of bash function which accept current value as input
body: <h3>Overview</h3>
  <ul>
  <li>Something like <a href="https://stackoverflow.com/questions/5777170/substitution-with-sed-bash-function">Substitution with sed + bash function</a>
  But using <code>yq</code></li>
  <li><strong>yq</strong> of <strong>kislyuk</strong> not other <strong>yq</strong> projects <a href="https://github.com/kislyuk/yq" rel="nofollow noreferrer">https://github.com/kislyuk/yq</a> (<code>pip install yq</code>)</li>
  </ul>
  <h3>Details</h3>
  <p>I have this bash function :</p>
  <pre class="lang-sh prettyprint-override"><code>function replace_image_repo() {
    echo &quot;nexus.local/${1}&quot;
  }
  </code></pre>
  <p>On the other side, i have a YAML file:</p>
  <pre class="lang-yaml prettyprint-override"><code># pod.yaml
  kind: Pod
  # ...
  spec:
    containers:
      - name: web
        image: nginx
      - name: logger
        image: abdennour/logger
  </code></pre>
  <p>I am able to replace all value occurences of <code>.image</code> key by a static value:</p>
  <pre class="lang-sh prettyprint-override"><code>yq -y '(.. | .image?) |= &quot;mynewimage&quot;' pod.yaml
  </code></pre>
  <p>And the result is as expected:</p>
  <pre class="lang-yaml prettyprint-override"><code># pod.yaml
  kind: Pod
  # ...
  spec:
    containers:
      - name: web
        image: mynewimage # &lt;-- Replacement done successfully
      - name: logger
        image: mynewimage # &lt;-- Replacement done successfully
  </code></pre>
  <p>However, I want to leverage the bash function above <code>replace_image_repo</code> and call it to <strong>calculate the new value for each occurrence based on the current value</strong> :</p>
  <ul>
  <li><p>for example, <code>nginx</code> must be replaced by the output of <code>$(replace_image_repo nginx)</code> which should be <code>nexus.local/nginx</code>.</p>
  </li>
  <li><p>Is it possible to match the current value ?</p>
  </li>
  <li><p>If so , is it possible a call the Bash function &quot;yq -y '.... $(HERE)'&quot; ?</p>
  </li>
  </ul>