diff --git a/d3b_dff_cli/cli.py b/d3b_dff_cli/cli.py index 2c5ad9e..ecf27f4 100644 --- a/d3b_dff_cli/cli.py +++ b/d3b_dff_cli/cli.py @@ -151,8 +151,10 @@ def create_parser(): create_ticket_parser.add_argument( "-auth", help="Base64 encoded Jira username and password", - required=True, + required=False, ) + create_ticket_parser.add_argument("-user", help="Jira username", required=False) + create_ticket_parser.add_argument("-key", help="Jira API key", required=False) create_ticket_parser.add_argument( "-jira_url", help="Jira url", diff --git a/d3b_dff_cli/modules/jira/create_ticket.py b/d3b_dff_cli/modules/jira/create_ticket.py index 7f2f6e1..76606d4 100644 --- a/d3b_dff_cli/modules/jira/create_ticket.py +++ b/d3b_dff_cli/modules/jira/create_ticket.py @@ -5,6 +5,7 @@ import logging import time from datetime import datetime +from base64 import b64encode logger = logging.getLogger() logger.setLevel(logging.INFO) @@ -328,9 +329,21 @@ def get_transfer_key(epic_key, headers, jira_url): def main(args): """Main function.""" + + # figure out if we have args.user and args.key or args.auth + auth = None + + if args.user and args.key: + auth = b64encode(f"{args.user}:{args.key}".encode()).decode() + elif args.auth: + auth = args.auth + else: + logger.error("No authentication provided") + raise ValueError("No authentication provided") + headers = { "Content-Type": "application/json", - "Authorization": f"Basic {args.auth}", + "Authorization": f"Basic {auth}", } # get issue type id from project diff --git a/d3b_dff_cli/version.py b/d3b_dff_cli/version.py index 4eb28e3..e931652 100644 --- a/d3b_dff_cli/version.py +++ b/d3b_dff_cli/version.py @@ -1 +1 @@ -__version__ = '3.0.0' +__version__ = '3.0.0' \ No newline at end of file