breser / git2consul

Mirrors the contents of a git repository into Consul KVs.
Other
764 stars 164 forks source link

gitconsul deleting all keys from consul #128

Open lpicanco opened 7 years ago

lpicanco commented 7 years ago

I have the following files in my git repository:

application.yml
application-dev.yml

When i update application.yml, git2consul remove the application and application-dev keys from consul KV. I think the problem is this:

https://www.consul.io/docs/commands/kv/delete.html

!> **Trailing slashes are important** in the recursive delete operation, since
Consul performs a greedy match on the provided prefix. If you were to use "foo"
as the key, this would recursively delete any key starting with those letters
such as "foo", "food", and "football" not just "foo". To ensure you are deleting
a folder, always use a trailing slash.

It is not valid to combine the `-cas` option with `-recurse`, since you are
deleting multiple keys under a prefix in a single operation:

Log file

{"name":"git2consul","hostname":"75d604058676","pid":1,"level":10,"msg":"Attempting to read \"/tmp/app-config/config/master/application.yml\"","time":"2016-12-29T16:33:31.996Z","v":0}
{"name":"git2consul","hostname":"75d604058676","pid":1,"level":10,"msg":"Deleting key app-config/config/master/master/application","time":"2016-12-29T16:33:31.997Z","v":0}
{"name":"git2consul","hostname":"75d604058676","pid":1,"level":20,"msg":"Expandable file app-config/config/master/application yielded 42 keys","time":"2016-12-29T16:33:32.010Z","v":0}

My config file

{
  "version": "1.0",
  "logger" : {
    "name": "git2consul",
    "streams": [
      {
        "level": "trace",
        "stream": "process.stdout"
      }
    ]
  },
  "repos" : [{
    "name" : "app/config",
    "expand_keys" : true,
    "url" : "git@bitbucket.org:app/app-config.git",
    "ignore_file_extension": true,
    "expand_keys_diff" : true,
    "branches" : ["master"],
    "hooks": [{
      "type" : "polling",
      "interval" : "1"
    }]
  }
  ]
}

This can be related to #118

eyalzek commented 7 years ago

I was noticing the same behavior and submitted a PR that should fix this. It still requires a review since it might affect something I am not aware of.

https://github.com/Cimpress-MCP/git2consul/pull/152