kelseyhightower / confd

Manage local application configuration files using templates and data from etcd or consul
MIT License
8.35k stars 1.41k forks source link

Raw JSON to file #535

Closed sgrunt91 closed 6 years ago

sgrunt91 commented 7 years ago

Hi,

I'm trying to create config file from Rancher Metadata API. I'm inspiring myself from this project: https://github.com/objectpartners/rancher-container-conf

But I just want directly json of the API to the file. This because the application which will use the generated config file need JSON syntax.

I can have with curl:


curl --header 'Accept: application/json' http://rancher-metadata/2015-07-25/self/service/metadata/config/content
{"blabla":{"blublu":{"blibli":[],"bloblo":{"nyark":["firstName","name","birthName"]}}}}

But I don't understand what to put in template instead of getv to just get raw JSON data (like curl).

This is my rancher-compose.yml file, if this could help you to understand me:

version: '2'
services:
  app:
    metadata:
      config:
        path: /config/app.conf  
        content:  
          blabla:
            blublu:
              blibli: []
              bloblo:
                nyark:
                - firstName
                - name
                - birthName
    scale: 1
    start_on_create: true

I could just use a curl container to create a file, but I would benefit of confd dynamic update.

Do you understand me ? Is it insane ? :)

Thanks a lot if you try to help me!

Best Regards,

bacongobbler commented 7 years ago

https://github.com/kelseyhightower/confd/blob/master/docs/templates.md#json

HeavyHorst commented 7 years ago

I think something like consul-templates toJSON could be useful in this case. https://github.com/hashicorp/consul-template#tojson

sgrunt91 commented 7 years ago

Hi, Thanks both of you for your quick reply!

I don't think json template is useful in my case, or I don't really understand how to use it.

So, what I understand is that there is no solution for me with confd ? :)

Regards,