Skip to content
This repository was archived by the owner on Apr 15, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion consul/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ def register(
tags=None,
check=None,
token=None,
meta=None,
# *deprecated* use check parameter
script=None,
interval=None,
Expand Down Expand Up @@ -848,6 +849,9 @@ def register(
Note this call will return successful even if the token doesn't
have permissions to register this service.

*meta* specifies arbitrary KV metadata linked to the service
formatted as {k1:v1, k2:v2}.

*script*, *interval*, *ttl*, *http*, and *timeout* arguments
are deprecated. use *check* instead.

Expand All @@ -873,7 +877,8 @@ def register(
payload['port'] = port
if tags:
payload['tags'] = tags

if meta:
payload['meta'] = meta
if check:
payload['check'] = check

Expand Down
21 changes: 21 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import collections
import json

import pytest

Expand Down Expand Up @@ -62,6 +63,14 @@ def _should_support_node_meta(c):
)


def _should_support_meta(c):
return (
# agent
lambda **kw: c.agent.service.register('foo', **kw),
lambda **kw: c.agent.service.register('foo', 'bar', **kw),
)


class TestIndex(object):
"""
Tests read requests that should support blocking on an index
Expand Down Expand Up @@ -107,6 +116,18 @@ def test_node_meta(self):
sorted([('node-meta', 'net:1'), ('node-meta', 'env:prod')])


class TestMeta(object):
"""
Tests read requests that should support meta
"""

def test_meta(self):
c = Consul()
for r in _should_support_meta(c):
d = json.loads(r(meta={'env': 'prod', 'net': 1}).data)
assert sorted(d['meta']) == sorted({'env': 'prod', 'net': 1})


class TestCB(object):

def test_status_200_passes(self):
Expand Down