Repository: incubator-airflow Updated Branches: refs/heads/master ef6dd1b29 -> 8c1695633
[AIRFLOW-725] Use keyring to store credentials for JIRA Now allows to store the credentials in the keyring of the OS. Retains backwards compatibility. Closes #1966 from bolkedebruin/DEV_KEYRING Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/8c169563 Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/8c169563 Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/8c169563 Branch: refs/heads/master Commit: 8c169563335371562a617436575b90d3fb4d0882 Parents: ef6dd1b Author: Bolke de Bruin <[email protected]> Authored: Sun Feb 26 17:41:00 2017 -0500 Committer: Jeremiah Lowin <[email protected]> Committed: Sun Feb 26 17:41:00 2017 -0500 ---------------------------------------------------------------------- dev/airflow-pr | 21 +++++++++++++++++++-- dev/requirements.txt | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/8c169563/dev/airflow-pr ---------------------------------------------------------------------- diff --git a/dev/airflow-pr b/dev/airflow-pr index cf8c0cb..c7f75a0 100755 --- a/dev/airflow-pr +++ b/dev/airflow-pr @@ -51,6 +51,12 @@ except ImportError: print("Could not find the click library. Run 'sudo pip install click' to install.") sys.exit(-1) +try: + import keyring +except ImportError: + print("Could not find the keyring library. Run 'sudo pip install keyring' to install.") + sys.exit(-1) + # Location of your Airflow git development area AIRFLOW_GIT_LOCATION = os.environ.get( "AIRFLOW_GIT", @@ -77,6 +83,7 @@ BRANCH_PREFIX = "PR_TOOL" TMP_CREDENTIALS = {} + class PRToolError(Exception): pass @@ -460,6 +467,10 @@ def fix_version_from_branch(branch, versions): return versions[-1] +def register(username, password): + """ Use this function to register a JIRA account in your OS' keyring """ + keyring.set_password('airflow-pr', username, password) + def validate_jira_id(jira_id): if not jira_id: return @@ -542,13 +553,19 @@ def resolve_jira_issue(comment=None, jira_id=None, merge_branches=None): click.echo( 'Set a JIRA_USERNAME env var to avoid this prompt in the future.') TMP_CREDENTIALS['JIRA_USERNAME'] = JIRA_USERNAME + if JIRA_USERNAME and not JIRA_PASSWORD: + JIRA_PASSWORD = keyring.get_password("airflow-pr", JIRA_USERNAME) + if JIRA_PASSWORD: + click.echo("Obtained password from keyring. To reset remove it there.") if not JIRA_PASSWORD: JIRA_PASSWORD = click.prompt( click.style('Password for Airflow JIRA', fg='blue', bold=True), type=str, hide_input=True) - click.echo( - 'Set a JIRA_PASSWORD env var to avoid this prompt in the future.') + if JIRA_USERNAME and JIRA_PASSWORD: + if click.confirm(click.style("Would you like to store your password " + "in your keyring?", fg='blue', bold=True)): + register(JIRA_USERNAME, JIRA_PASSWORD) TMP_CREDENTIALS['JIRA_PASSWORD'] = JIRA_PASSWORD try: http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/8c169563/dev/requirements.txt ---------------------------------------------------------------------- diff --git a/dev/requirements.txt b/dev/requirements.txt index e4a3481..29a8941 100644 --- a/dev/requirements.txt +++ b/dev/requirements.txt @@ -1,2 +1,3 @@ click>=6.6,<7 jira>=1.0.7,<2 +keyring==10.1
