mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-24 22:27:24 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -139,36 +139,33 @@ def main():
|
|||
user=dict(required=True),
|
||||
password=dict(no_log=True),
|
||||
token=dict(no_log=True),
|
||||
action=dict(
|
||||
required=True, choices=['latest_release', 'create_release']),
|
||||
tag=dict(type='str'),
|
||||
target=dict(type='str'),
|
||||
name=dict(type='str'),
|
||||
body=dict(type='str'),
|
||||
draft=dict(type='bool', default=False),
|
||||
prerelease=dict(type='bool', default=False),
|
||||
action=dict(required=True, choices=["latest_release", "create_release"]),
|
||||
tag=dict(type="str"),
|
||||
target=dict(type="str"),
|
||||
name=dict(type="str"),
|
||||
body=dict(type="str"),
|
||||
draft=dict(type="bool", default=False),
|
||||
prerelease=dict(type="bool", default=False),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
mutually_exclusive=(('password', 'token'),),
|
||||
required_if=[('action', 'create_release', ['tag']),
|
||||
('action', 'create_release', ['password', 'token'], True)],
|
||||
mutually_exclusive=(("password", "token"),),
|
||||
required_if=[("action", "create_release", ["tag"]), ("action", "create_release", ["password", "token"], True)],
|
||||
)
|
||||
|
||||
if not HAS_GITHUB_API:
|
||||
module.fail_json(msg=missing_required_lib('github3.py >= 1.0.0a3'),
|
||||
exception=GITHUB_IMP_ERR)
|
||||
module.fail_json(msg=missing_required_lib("github3.py >= 1.0.0a3"), exception=GITHUB_IMP_ERR)
|
||||
|
||||
repo = module.params['repo']
|
||||
user = module.params['user']
|
||||
password = module.params['password']
|
||||
login_token = module.params['token']
|
||||
action = module.params['action']
|
||||
tag = module.params.get('tag')
|
||||
target = module.params.get('target')
|
||||
name = module.params.get('name')
|
||||
body = module.params.get('body')
|
||||
draft = module.params.get('draft')
|
||||
prerelease = module.params.get('prerelease')
|
||||
repo = module.params["repo"]
|
||||
user = module.params["user"]
|
||||
password = module.params["password"]
|
||||
login_token = module.params["token"]
|
||||
action = module.params["action"]
|
||||
tag = module.params.get("tag")
|
||||
target = module.params.get("target")
|
||||
name = module.params.get("name")
|
||||
body = module.params.get("body")
|
||||
draft = module.params.get("draft")
|
||||
prerelease = module.params.get("prerelease")
|
||||
|
||||
# login to github
|
||||
try:
|
||||
|
|
@ -191,40 +188,42 @@ def main():
|
|||
# https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#githubs-token-formats
|
||||
#
|
||||
# Test if we're actually logged in, but skip this check for some token prefixes
|
||||
SKIPPED_TOKEN_PREFIXES = ['ghs_']
|
||||
SKIPPED_TOKEN_PREFIXES = ["ghs_"]
|
||||
if password or (login_token and not any(login_token.startswith(prefix) for prefix in SKIPPED_TOKEN_PREFIXES)):
|
||||
gh_obj.me()
|
||||
except github3.exceptions.AuthenticationFailed as e:
|
||||
module.fail_json(msg=f'Failed to connect to GitHub: {e}',
|
||||
details=f"Please check username and password or token for repository {repo}")
|
||||
module.fail_json(
|
||||
msg=f"Failed to connect to GitHub: {e}",
|
||||
details=f"Please check username and password or token for repository {repo}",
|
||||
)
|
||||
except github3.exceptions.GitHubError as e:
|
||||
module.fail_json(msg=f'GitHub API error: {e}',
|
||||
details=f"Please check username and password or token for repository {repo}")
|
||||
module.fail_json(
|
||||
msg=f"GitHub API error: {e}", details=f"Please check username and password or token for repository {repo}"
|
||||
)
|
||||
|
||||
repository = gh_obj.repository(user, repo)
|
||||
|
||||
if not repository:
|
||||
module.fail_json(msg=f"Repository {user}/{repo} doesn't exist")
|
||||
|
||||
if action == 'latest_release':
|
||||
if action == "latest_release":
|
||||
release = repository.latest_release()
|
||||
if release:
|
||||
module.exit_json(tag=release.tag_name)
|
||||
else:
|
||||
module.exit_json(tag=None)
|
||||
|
||||
if action == 'create_release':
|
||||
if action == "create_release":
|
||||
release_exists = repository.release_from_tag(tag)
|
||||
if release_exists:
|
||||
module.exit_json(changed=False, msg=f"Release for tag {tag} already exists.")
|
||||
|
||||
release = repository.create_release(
|
||||
tag, target, name, body, draft, prerelease)
|
||||
release = repository.create_release(tag, target, name, body, draft, prerelease)
|
||||
if release:
|
||||
module.exit_json(changed=True, tag=release.tag_name)
|
||||
else:
|
||||
module.exit_json(changed=False, tag=None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue