xco-sk / eck-custom-resources

Kubernetes operator for Indices, Index Templates, Roles, Users and other Elasticsearch and Kibana related resources.
Apache License 2.0
36 stars 8 forks source link

allow yaml instead of json body #57

Open an-tex opened 1 year ago

an-tex commented 1 year ago

currently to e.g. create a snapshot repository you'd write

apiVersion: es.eck.github.com/v1alpha1
kind: SnapshotRepository
metadata:
  name: snapshotrepository-sample
spec:
  targetInstance:
    name: elasticsearch-quickstart
  body: |
    {
      "type": "fs",
      "settings": {
        "location": "/tmp/"
      }
    }

meaning the actual configuration is written in json. the downside of this approach is that you can't use tools like kustomize to e.g. define a base snapshot repository with it's settings and then override it only partially in an overlay. to overcome this limitation one could allow (untyped) yaml and just transform it to the same json.

then you could define sth like:

apiVersion: es.eck.github.com/v1alpha1
kind: SnapshotRepository
metadata:
  name: snapshotrepository-sample
spec:
  targetInstance:
    name: elasticsearch-quickstart
  settings: # or some better name?
    type: fs
    settings:
      location: "/tmp"
xco-sk commented 1 year ago

Hello, thanks for the idea, and yeah, it's a valid point for the yaml. The original idea behind the json was the simplicity of creating the resources - just taking the json from the ES/Kibana REST API and pasting it into the yaml but, well it does have its limits. I will check what's possible in terms of schema definition and backward compatibility (this one shouldn't be that bad, as you mention, we can easily translate between json and yaml, but again I need to find out what's possible with schema definition).