Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand_keys support for JSON arrays #71

Closed
juicedM3 opened this issue Mar 31, 2016 · 5 comments · May be fixed by #166
Closed

expand_keys support for JSON arrays #71

juicedM3 opened this issue Mar 31, 2016 · 5 comments · May be fixed by #166
Labels

Comments

@juicedM3
Copy link

I loaded the sample git2consul configuration file into git.

{
  "version": "1.0",
  "repos" : [{
    "name" : "sample_configuration",
    "url" : "https://github.com/ryanbreen/git2consul_data.git",
    "branches" : ["dev"],
    "hooks": [{
      "type" : "polling",
      "interval" : "1"
    }]
  }]
}

I configured git2consul to monitor this file and the end result in Consul is only version makes it into Consul:

$ curl "consul.service.consul:8500/v1/kv/poc/master/config/git2consul.json/?recurse&pretty&token=$CONSUL_TOKEN"
[
    {
        "LockIndex": 0,
        "Key": "poc/master/config/git2consul.json/version",
        "Flags": 0,
        "Value": "MS4w",
        "CreateIndex": 1297420,
        "ModifyIndex": 1297420
    }
]
{
  "version": "1.0",
  "local_store": "/tmp/git2consul_cache",
  "halt_on_change": true,
  "logger" : {
    "name" : "git2consul",
    "streams" : [
      {
        "level":  "trace",
        "stream": "process.stdout"
      },
      {
        "level": "debug",
        "type": "rotating-file",
        "path": "/tmp/git2consul.log"
      }
    ]
  },
  "repos": [{
    "name": "poc",
    "url":  "ssh://[email protected]/git2consul.git",
    "expand_keys": true,
    "source_root": "config",
    "branches": ["master"],
    "hooks": [{
      "type": "stash",
      "port": "5051",
      "url": "/gitpoke"
    },
    {
      "type": "polling",
      "interval": "1"
    }]
  }]
}

It would be nice if git2consul could handle arrays. Thanks!

@arthurtsang
Copy link

what is the desired behavior for an array? expand repo[] into repo0, repo1,...? what happens when the array is updated? say delete the first element in the array, repo1 previously will become repo0.

@calvn
Copy link
Contributor

calvn commented Jun 17, 2016

As metioned in the Readme: Any arrays in your JSON file are ignored. Only objects and primitives are transformed into keys.

@arthurtsang
Copy link

Yea, my comments is just to point out it doesn't seem to have any good way to support array.

@calvn
Copy link
Contributor

calvn commented Jun 17, 2016

Ah, gotcha!

@calvn calvn closed this as completed Jun 17, 2016
@calvn
Copy link
Contributor

calvn commented Jun 17, 2016

The reference for this particular case is in here: /lib/consul/index.js#L65. I'm closing because there is no good answer on handling the expected/desired outcome of an array. Aside from the point mentioned by @arthurtsang, arrays can contain repeat values. In that case, what would the the appropriate value to keep - the first, the last, or some other value by a certain criteria?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants