Updated w/ license

Added license
Added TODO for a “latest” state
Removed pending “latest” state work
reviewable/pr18780/r1
Chris Schmidt 10 years ago
parent 344713365f
commit 7e26d715d3

@ -6,7 +6,18 @@
# Built using https://github.com/hamnis/useful-scripts/blob/master/python/download-maven-artifact # Built using https://github.com/hamnis/useful-scripts/blob/master/python/download-maven-artifact
# as a reference and starting point. # as a reference and starting point.
# #
# This module is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# #
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
__author__ = 'cschmidt' __author__ = 'cschmidt'
@ -98,7 +109,6 @@ EXAMPLES = '''
- download_artifact: group_id=com.company artifact_id=web-app extension=war repository_url=https://repo.company.com/maven target=/var/lib/tomcat7/webapps/web-app.war - download_artifact: group_id=com.company artifact_id=web-app extension=war repository_url=https://repo.company.com/maven target=/var/lib/tomcat7/webapps/web-app.war
''' '''
class Artifact(object): class Artifact(object):
def __init__(self, group_id, artifact_id, version, classifier=None, extension=jar): def __init__(self, group_id, artifact_id, version, classifier=None, extension=jar):
if not group_id: if not group_id:
@ -311,7 +321,7 @@ def main():
repository_url = dict(default=None), repository_url = dict(default=None),
username = dict(default=None), username = dict(default=None),
password = dict(default=None), password = dict(default=None),
state = dict(default="latest", choices=["present","absent"]), state = dict(default="latest", choices=["present","absent"]), # TODO - Implement a "latest" state
target = dict(default=None), target = dict(default=None),
) )
) )
@ -346,12 +356,8 @@ def main():
os.makedirs(path) os.makedirs(path)
if prev_state == "present": if prev_state == "present":
if state == "latest": module.exit_json(target=target, state=state, changed=False)
artifact_uri = downloader.find_uri_for_artifact(artifact)
if downloader.verify_md5(target, artifact_uri + ".md5"):
module.exit_json(target=target, state=state, changed=False)
else:
module.exit_json(target=target, state=state, changed=False)
try: try:
if downloader.download(artifact, target): if downloader.download(artifact, target):
module.exit_json(state=state, target=target, group_id=group_id, artifact_id=artifact_id, version=version, classifier=classifier, extension=extension, repository_url=repository_url, changed=True) module.exit_json(state=state, target=target, group_id=group_id, artifact_id=artifact_id, version=version, classifier=classifier, extension=extension, repository_url=repository_url, changed=True)

Loading…
Cancel
Save