godaddy / kubernetes-client

Simplified Kubernetes API client for Node.js.
MIT License
961 stars 192 forks source link

Adding data to configMap errors #668

Open sonisaurabh19 opened 4 years ago

sonisaurabh19 commented 4 years ago

This is the configMap I am trying to update and add data to:

kind: ConfigMap
apiVersion: v1
metadata:
  name: my-config-map
data:
  users.json: |-
  [
    {
      name: 'user-one',
      age: 10
    }
  ]

I tried the following code, but it fails:

const addToConfig = {
  data: {
    "users.json": {
      name: 'user-two',
      age: 12
    }
  }
}

await kubeclient.api.v1.namespaces('my-namespace').configmaps('my-config-map').patch({ body: addToConfig})

How can I use the API to update the configMap and append data to the users.json array?