<p>I am working on a way to manipulate the ConfigMap for kubernetes with Mike Farah's yq.</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: game-config
  namespace: default
data:
  game.properties: |
    enemies=aliens
    lives=3
    enemies.cheat=true
    enemies.cheat.level=noGoodRotten
    secret.code.passphrase=UUDDLRLRBABAS
    secret.code.allowed=true
    secret.code.lives=30    
  ui.properties: |
    color.good=purple
    color.bad=yellow
    allow.textmode=true
    how.nice.to.look=fairlyNice  
</code></pre>
<p>I want to update the game.properties value - lives to 999.</p>
<p>However when I try below commands i get the error respectively.</p>
<pre><code>$ yq e '.data.[game.properties]=&quot;enemies=aliens\nlives=3\nenemies.cheat=true\nenemies.cheat.level=noGoodRotten\nsecret.code.passphrase=UUDDLRLRBABAS\nsecret.code.allowed=true\nsecret.code.lives=30    \n&quot;' test-configmap.yaml
Error: Parsing expression: Lexer error: could not match text starting at 1:8 failing at 1:9.
        unmatched text: &quot;g&quot;
</code></pre>
<p>I think the problem is in accessing the data.</p>
<pre><code>$ yq e &quot;.data[0]&quot; test-configmap.yaml
null
$ yq e &quot;.data.[0]&quot; test-configmap.yaml
null
$ yq e &quot;.data.[game.properties]&quot; test-configmap.yaml
Error: Parsing expression: Lexer error: could not match text starting at 1:8 failing at 1:9.
        unmatched text: &quot;g&quot;
</code></pre>
<p>But when I try below I get the values of the data:</p>
<pre><code>yq e &quot;.data.[]&quot; test-configmap.yaml
enemies=aliens
lives=3
enemies.cheat=true
enemies.cheat.level=noGoodRotten
secret.code.passphrase=UUDDLRLRBABAS
secret.code.allowed=true
secret.code.lives=30

color.good=purple
color.bad=yellow
allow.textmode=true
how.nice.to.look=fairlyNice
</code></pre>
<p>It is strange that it doesnt let me access the data name, i.e. game.properties and ui.properties.</p>

Chinmaya Biswal
<p>Looks like I found out how to do it.
So we have to use double quotes for accessing the data field parameters.</p>
<p>Adding my command for reference.</p>
<pre><code>yq e '.data.&quot;game.properties&quot;=&quot;enemies=aliens\nlives=999\nenemies.cheat=true\nenemies.cheat.level=noGoodRotten\nsecret.code.passphrase
=UUDDLRLRBABAS\nsecret.code.allowed=true\nsecret.code.lives=30    \n&quot;' test-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  creationTimestamp: 2016-02-18T18:52:05Z
  name: game-config
  namespace: default
  resourceVersion: &quot;516&quot;
  uid: b4952dc3-d670-11e5-8cd0-68f728db1985
data:
  game.properties: |-
    enemies=aliens\nlives=999\nenemies.cheat=true\nenemies.cheat.level=noGoodRotten\nsecret.code.passphrase=UUDDLRLRBABAS\nsecret.code.allowed=true\nsecret.code.lives=30    \n
  ui.properties: &quot;color.good=purple\ncolor.bad=yellow\nallow.textmode=true\nhow.nice.to.look=fairlyNice  \n&quot;
</code></pre>
