Skip to content

Commit df59f53

Browse files
authored
Merge pull request #2852 from Phat3/feat/add_templating_parameter_docker_config
Add the possibility to set a templating driver when creating a new Docker config
2 parents b825867 + aae6be0 commit df59f53

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

docker/api/config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55

66
class ConfigApiMixin:
77
@utils.minimum_version('1.30')
8-
def create_config(self, name, data, labels=None):
8+
def create_config(self, name, data, labels=None, templating=None):
99
"""
1010
Create a config
1111
1212
Args:
1313
name (string): Name of the config
1414
data (bytes): Config data to be stored
1515
labels (dict): A mapping of labels to assign to the config
16+
templating (dict): dictionary containing the name of the
17+
templating driver to be used expressed as
18+
{ name: <templating_driver_name>}
1619
1720
Returns (dict): ID of the newly created config
1821
"""
@@ -24,7 +27,8 @@ def create_config(self, name, data, labels=None):
2427
body = {
2528
'Data': data,
2629
'Name': name,
27-
'Labels': labels
30+
'Labels': labels,
31+
'Templating': templating
2832
}
2933

3034
url = self._url('/configs/create')

tests/integration/api_config_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,16 @@ def test_list_configs(self):
6868
data = self.client.configs(filters={'name': ['favorite_character']})
6969
assert len(data) == 1
7070
assert data[0]['ID'] == config_id['ID']
71+
72+
@requires_api_version('1.37')
73+
def test_create_config_with_templating(self):
74+
config_id = self.client.create_config(
75+
'favorite_character', 'sakuya izayoi',
76+
templating={ 'name': 'golang'}
77+
)
78+
self.tmp_configs.append(config_id)
79+
assert 'ID' in config_id
80+
data = self.client.inspect_config(config_id)
81+
assert data['Spec']['Name'] == 'favorite_character'
82+
assert 'Templating' in data['Spec']
83+
assert data['Spec']['Templating']['Name'] == 'golang'

0 commit comments

Comments
 (0)