Skip to content

Commit

Permalink
add build keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
ltalirz committed Feb 3, 2021
1 parent 5ff0a58 commit 4317765
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 6 deletions.
31 changes: 25 additions & 6 deletions library/dokku_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
required: True
default: null
aliases: []
version:
description:
- Git tree (tag or branch name). If not provided, default branch is used.
required: False
default: null
aliases: []
build:
description:
- Whether to build the app (only when repository changes)
required: False
default: True
aliases: []
author: Jose Diaz-Gonzalez
"""

Expand Down Expand Up @@ -71,12 +83,17 @@ def dokku_clone(data):
)
return (is_error, has_changed, meta)

if "version" in data and data["version"]:
command = "dokku git:sync {0} {1} {2}".format(
data["app"], data["repository"], data["version"]
)
else:
command = "dokku git:sync {0} {1}".format(data["app"], data["repository"])
command = "dokku git:sync"
if data["build"]:
command += " --build"

command += " {app} {repository}".format(
app=data["app"], repository=data["repository"]
)

if data["version"]:
command += command + " {version}".format(version=data["version"])

try:
subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
is_error = False
Expand All @@ -93,6 +110,8 @@ def main():
fields = {
"app": {"required": True, "type": "str"},
"repository": {"required": True, "type": "str"},
"version": {"required": False, "type": "str"},
"build": {"required": False, "type": "bool"},
}

module = AnsibleModule(argument_spec=fields, supports_check_mode=False)
Expand Down
35 changes: 35 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
- name: Bare include (free-form)
include_vars: ../../defaults/main.yml

# Testing dokku_global_cert
- name: Check that dokku_global_cert module can parse output
dokku_global_cert:
state: absent

# Testing dokku_hostname
- name: Get dokku_hostname # noqa 301
command: dokku domains:report --global
register: dokku_domains
Expand All @@ -21,3 +23,36 @@
msg: |
hostname 'test.domain' not found in output of 'dokku domains':
{{ dokku_domains.stdout }}
# Testing dokku_clone
- name: clone example_app
dokku_clone:
app: example_app
repository: https://github.com/heroku/node-js-getting-started
version: b10a4d7a20a6bbe49655769c526a2b424e0e5d0b

- name: Get list of apps # noqa 301
command: dokku apps:list
register: dokku_apps

- name: Check that example_app is in list of apps
assert:
that:
- "'example_app' in dokku_apps.stdout"
msg: |
'example_app' not found in output of 'dokku apps:list':
{{ dokku_apps.stdout }}
- name: clone example app again
dokku_clone:
app: node-js-getting-started
repository: https://github.com/heroku/node-js-getting-started
version: b10a4d7a20a6bbe49655769c526a2b424e0e5d0b
register: example_app

- name: Check that re-cloning example app did not change anything
assert:
that:
- not example_app.changed
msg: |
Re-cloning example app resulted in changed status

0 comments on commit 4317765

Please sign in to comment.