<p>I need apply a oc patch to the following deploy, changing de value of &quot;image&quot;. But I can´t do that, caused by an error:</p>
<p>DEPLOY YML:</p>
<pre><code>root@oc-jump-pod:/# oc get  deploy deploy-test -o json
{
    &quot;apiVersion&quot;: &quot;extensions/v1beta1&quot;,
    &quot;kind&quot;: &quot;Deployment&quot;,
    &quot;metadata&quot;: {
        &quot;annotations&quot;: {
            &quot;deployment.kubernetes.io/revision&quot;: &quot;3&quot;,
            &quot;meta.helm.sh/release-name&quot;: &quot;teste&quot;,
            &quot;meta.helm.sh/release-namespace&quot;: &quot;sda-test&quot;
        },
        &quot;creationTimestamp&quot;: &quot;2020-05-25T07:01:14Z&quot;,
        &quot;generation&quot;: 23,
        &quot;labels&quot;: {
            &quot;app.kubernetes.io/instance&quot;: &quot;test&quot;,
            &quot;app.kubernetes.io/managed-by&quot;: &quot;Helm&quot;,
            &quot;app.kubernetes.io/name&quot;: &quot;test&quot;,
            &quot;app.kubernetes.io/version&quot;: &quot;latest&quot;,
            &quot;helm.sh/chart&quot;: &quot;test-1.0.0&quot;
        },
        &quot;name&quot;: &quot;test&quot;,
        &quot;namespace&quot;: &quot;test-1&quot;,
        &quot;resourceVersion&quot;: &quot;19316664&quot;,
        &quot;selfLink&quot;: &quot;/apis/extensions/v1beta1/namespaces/test/deployments/test&quot;,
        &quot;uid&quot;: &quot;863d7397&quot;
    },
    &quot;spec&quot;: {
        &quot;progressDeadlineSeconds&quot;: 600,
        &quot;replicas&quot;: 1,
        &quot;revisionHistoryLimit&quot;: 10,
        &quot;selector&quot;: {
            &quot;matchLabels&quot;: {
                &quot;app.kubernetes.io/instance&quot;: &quot;test&quot;,
                &quot;app.kubernetes.io/name&quot;: &quot;test&quot;
            }
        },
        &quot;strategy&quot;: {
            &quot;rollingUpdate&quot;: {
                &quot;maxSurge&quot;: &quot;25%&quot;,
                &quot;maxUnavailable&quot;: &quot;25%&quot;
            },
            &quot;type&quot;: &quot;RollingUpdate&quot;
        },
        &quot;template&quot;: {
            &quot;metadata&quot;: {
                &quot;creationTimestamp&quot;: null,
                &quot;labels&quot;: {
                    &quot;app.kubernetes.io/instance&quot;: &quot;test&quot;,
                    &quot;app.kubernetes.io/name&quot;: &quot;test&quot;
                }
            },
            &quot;spec&quot;: {
                &quot;containers&quot;: [
                    {
                        &quot;env&quot;: [
                            {
                                &quot;name&quot;: &quot;APP_NAME&quot;,
                                &quot;value&quot;: &quot;test&quot;
                            },
                            {
                                &quot;name&quot;: &quot;JAVA_OPTS_EXT&quot;,
                                &quot;value&quot;: &quot;-Djava.security.egd=file:/dev/./urandom -Dcom.sun.net.ssl.checkRevocation=false  -Djavax.net.ssl.trustStore=/etc/truststore/jssecacerts -Djavax.net.ssl.trustStorePassword=changeit&quot;
                            },
                            {
                                &quot;name&quot;: &quot;SPRING_CLOUD_CONFIG_PROFILE&quot;,
                                &quot;value&quot;: &quot;pre&quot;
                            },
                            {
                                &quot;name&quot;: &quot;TZ&quot;,
                                &quot;value&quot;: &quot;Europe/Madrid&quot;
                            },
                            {
                                &quot;name&quot;: &quot;WILY_MOM_PORT&quot;,
                                &quot;value&quot;: &quot;5001&quot;
                            },
                            {
                                &quot;name&quot;: &quot;spring_application_name&quot;,
                                &quot;value&quot;: &quot;test&quot;
                            },
                            {
                                &quot;name&quot;: &quot;spring_cloud_config_uri&quot;,
                                &quot;value&quot;: &quot;https://config.test.svc.cluster.local&quot;
                            }
                        ],
                        &quot;image&quot;: &quot;registry.sdi.dev.weu.azure.paas.cloudcenter.corp/test-dev/test-java:0.0.2&quot;,
                        &quot;imagePullPolicy&quot;: &quot;Always&quot;,
                        &quot;name&quot;: &quot;test&quot;,
                        &quot;ports&quot;: [
                            {
                                &quot;containerPort&quot;: 8080,
                                &quot;protocol&quot;: &quot;TCP&quot;
                            }
  ],
                        &quot;resources&quot;: {
                        ...

</code></pre>
<p>I´m triying the following:</p>
<pre><code>root@oc-jump-pod:/# oc patch deploy push-engine --type='json' -p='{&quot;spec&quot;:{&quot;template&quot;:{&quot;metadata&quot;:{&quot;spec&quot;:{&quot;containers&quot;:{&quot;image&quot;:&quot;registry.sdi.
dev.weu.azure.paas.cloudcenter.corp/test-dev/test:0.0.1&quot;}}}}}}'
Error from server (BadRequest): json: cannot unmarshal object into Go value of type jsonpatch.Patch
</code></pre>
<p>and this to get the value</p>
<pre><code>root@oc-jump-pod:/# oc get deploy push-engine -o=jsonpath='{..image}'
registry.sdi.dev.weu.azure.paas.cloudcenter.corp/test-dev/test-java:0.0.2
</code></pre>
<p>I need do that, to change the tag of the image from 0.0.2 to 0.0.1 (or others). Probably I don´t understand oc patch yet, actually I do the change manually on the oc console. But this method, is rude and not follow the CI/CD.</p>

<p>The correct JSON Patch document for your <code>Deployment</code> may look like this:</p>
<pre><code>[
    {
        &quot;op&quot;: &quot;replace&quot;,
        &quot;path&quot;: &quot;/spec/template/spec/containers/0/image&quot;,
        &quot;value&quot;: &quot;registry.sdi.dev.weu.azure.paas.cloudcenter.corp/test-dev/test:0.0.1&quot;
    }
]
</code></pre>
<p>Your example is not going to work as it doesn't reflect the structure of your original <code>yaml</code> file. Note that it contains <strong>arrays</strong> <code>[...]</code> and you treated it as if it contained only <strong>maps</strong> <code>{...}</code>.</p>
<p>Your final <code>oc patch</code> command may look as follows:</p>
<pre><code>oc patch deploy push-engine --type='json' -p '[{ &quot;op&quot;: &quot;replace&quot;, &quot;path&quot;: &quot;/spec/template/spec/containers/0/image&quot;, &quot;value&quot;: &quot;registry.sdi.dev.weu.azure.paas.cloudcenter.corp/test-dev/test:0.0.1&quot; }]'
</code></pre>
