intellij-kubernetes icon indicating copy to clipboard operation
intellij-kubernetes copied to clipboard

support multi-resource documents in json

Open adietish opened this issue 2 years ago • 0 comments

depends on #549

multi document support is YAML only currently in #549. It would be nice to support the JSON variant, too.

An example of multiple resources in YAML:

---
apiVersion: "v1"
kind: "Secret"
metadata:
  name: "jhipster-grafana-credentials"
  namespace: "default"
data:
  username: "YmluZ29ib25nbw=="
  password: "bHVrZQ=="
---
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
  name: "jhipster-grafana"
  namespace: "default"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: "jhipster-grafana"
  template:
    metadata:
      labels:
        app: "jhipster-grafana"
    spec:
      containers:
        - image: "nginx"
          name: "nginx1"
          ports:
            - containerPort: 80

The same in json is:

{
  "apiVersion": "v1",
  "kind": "List",
  "items": [
    {
        "apiVersion": "v1",
        "kind": "Secret",
        "metadata": {
            "name": "jhipster-grafana-credentials",
            "namespace": "default"
        },
        "data": {
            "username": "YmluZ29ib25nbw==",
            "password": "bHVrZQ=="
        }
    },
    {
        "apiVersion": "apps/v1",
        "kind": "Deployment",
        "metadata": {
            "name": "jhipster-grafana",
            "namespace": "default"
        },
        "spec": {
            "replicas": 1,
            "selector": {
                "matchLabels": {
                    "app": "jhipster-grafana"
                }
            },
            "template": {
                "metadata": {
                    "labels": {
                        "app": "jhipster-grafana"
                    }
                },
                "spec": {
                    "containers": [
                        {
                            "image": "nginx",
                            "name": "nginx1",
                            "ports": [
                                {
                                    "containerPort": 80
                                }
                            ]
                        }
                    ]
                }
              }
        }
    }
  ]
}

kubectl would accept the above json and create the secret & deployment in it.

adietish avatar Jan 19 '23 14:01 adietish