Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support --template-driver for docker_config (#332) #345

Merged
merged 10 commits into from
May 11, 2022
Merged
Changes from 3 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
18 changes: 17 additions & 1 deletion plugins/modules/docker_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@
choices:
- absent
- present
template_driver:
description:
- Set to C(golang) to use a Golang template file in I(data).
felixfontein marked this conversation as resolved.
Show resolved Hide resolved
type: str
choices:
- golang
felixfontein marked this conversation as resolved.
Show resolved Hide resolved

extends_documentation_fragment:
- community.docker.docker
Expand All @@ -92,6 +98,7 @@
author:
- Chris Houseknecht (@chouseknecht)
- John Hu (@ushuz)
- Sasha Jenner (@sashajenner)
felixfontein marked this conversation as resolved.
Show resolved Hide resolved
'''

EXAMPLES = '''
Expand Down Expand Up @@ -229,6 +236,13 @@ def __init__(self, client, results):
self.force = parameters.get('force')
self.rolling_versions = parameters.get('rolling_versions')
self.versions_to_keep = parameters.get('versions_to_keep')
template_driver = parameters.get('template_driver')
if template_driver:
self.templating = {
'name': template_driver
}
else:
self.templating = None

if self.rolling_versions:
self.version = 0
Expand Down Expand Up @@ -292,7 +306,8 @@ def create_config(self):

try:
if not self.check_mode:
config_id = self.client.create_config(self.name, self.data, labels=labels)
config_id = self.client.create_config(self.name, self.data,
labels=labels, templating=self.templating)
felixfontein marked this conversation as resolved.
Show resolved Hide resolved
self.configs += self.client.configs(filters={'id': config_id})
except APIError as exc:
self.client.fail("Error creating config: %s" % to_native(exc))
Expand Down Expand Up @@ -358,6 +373,7 @@ def main():
force=dict(type='bool', default=False),
rolling_versions=dict(type='bool', default=False),
versions_to_keep=dict(type='int', default=5),
template_driver=dict(type='str', choices=['golang']),
)

required_if = [
Expand Down