mantl / consul-cli

Command line interface to Consul HTTP API
Apache License 2.0
251 stars 67 forks source link

add catalog deregister command #20

Closed jonathancua closed 6 years ago

jonathancua commented 8 years ago

If you try to register a service like this, you can see that you cannot deregister it using the command "consul-cli service deregister redis1", but you can deregister it with the new command that I added.

cat >test <<EOF
{
  "Datacenter": "dc1",
  "Node": "foobar",
  "Address": "192.168.10.10",
  "Service": {
    "ID": "redis1",
    "Service": "redis",
    "Tags": [
      "master",
      "v1"
    ],
    "Address": "127.0.0.1",
    "TaggedAddresses": {
      "wan": "127.0.0.1"
    },
    "Port": 8000
  },
  "Check": {
    "Node": "foobar",
    "CheckID": "service:redis1",
    "Name": "Redis health check",
    "Notes": "Script based health check",
    "Status": "passing",
    "ServiceID": "redis1"
  }
}
EOF
curl -X PUT -d @test http://localhost:8500/v1/catalog/register
echo "This shows the service was registered"
consul-cli catalog service redis
echo "Try to deregister the service, and it does not work"
consul-cli service deregister redis1
consul-cli catalog service redis
echo "Use the catalog deregister command, and the service is gone"
~/git/godev/src/github.com/CiscoCloud/consul-cli/consul-cli catalog deregister redis1 foobar
consul-cli catalog service redis
nmische commented 7 years ago

I would like to see this along with a catalog register command to support registering external services.