Skip to content

Commit b27bd05

Browse files
author
Zack Kendall
committed
Add missing description field to Template class
1 parent 3ed1a9c commit b27bd05

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

grafanalib/core.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ class Template(object):
999999
10001000
:param default: the default value for the variable
10011001
:param dataSource: where to fetch the values for the variable from
1002+
:param description: Optional description for the template variable.
10021003
:param label: the variable's human label
10031004
:param name: the variable's name
10041005
:param query: the query users to fetch the valid values of the variable
@@ -1057,6 +1058,7 @@ class Template(object):
10571058
validator=instance_of(int)
10581059
)
10591060
autoMin = attr.ib(default=DEFAULT_MIN_AUTO_INTERVAL)
1061+
description = attr.ib(default=None)
10601062

10611063
def __attrs_post_init__(self):
10621064
if self.type == 'custom':
@@ -1089,6 +1091,7 @@ def to_json_data(self):
10891091
'allValue': self.allValue,
10901092
'current': self._current,
10911093
'datasource': self.dataSource,
1094+
'description': self.description,
10921095
'hide': self.hide,
10931096
'includeAll': self.includeAll,
10941097
'label': self.label,

grafanalib/tests/test_core.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,25 @@ def test_custom_template_dont_override_options():
9696
assert t.to_json_data()['current']['value'] == '1'
9797

9898

99+
def test_template_description():
100+
# Test that description is None by default
101+
t = G.Template(
102+
name='test',
103+
query='1m,5m,10m',
104+
type='interval',
105+
)
106+
assert t.to_json_data()['description'] is None
107+
108+
# Test that description is included when set
109+
t = G.Template(
110+
name='test',
111+
query='1m,5m,10m',
112+
type='interval',
113+
description='This is a test description',
114+
)
115+
assert t.to_json_data()['description'] == 'This is a test description'
116+
117+
99118
def test_table():
100119
t = G.Table(
101120
dataSource='some data source',

0 commit comments

Comments
 (0)