1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add GALAXY_TOKEN config option (#34621)

This change lets user store token in configuration file or environment to
prevent exposing the secret on the command line.
This commit is contained in:
Tristan de Cacqueray 2018-01-16 15:37:50 +00:00 committed by Adam Miller
parent 92b3d79283
commit 576335e53d
2 changed files with 13 additions and 3 deletions

View file

@ -545,14 +545,17 @@ class GalaxyCLI(CLI):
""" """
# Authenticate with github and retrieve a token # Authenticate with github and retrieve a token
if self.options.token is None: if self.options.token is None:
login = GalaxyLogin(self.galaxy) if C.GALAXY_TOKEN:
github_token = login.create_github_token() github_token = C.GALAXY_TOKEN
else:
login = GalaxyLogin(self.galaxy)
github_token = login.create_github_token()
else: else:
github_token = self.options.token github_token = self.options.token
galaxy_response = self.api.authenticate(github_token) galaxy_response = self.api.authenticate(github_token)
if self.options.token is None: if self.options.token is None and C.GALAXY_TOKEN is None:
# Remove the token we created # Remove the token we created
login.remove_github_token() login.remove_github_token()

View file

@ -1230,6 +1230,13 @@ GALAXY_SERVER:
ini: ini:
- {key: server, section: galaxy} - {key: server, section: galaxy}
yaml: {key: galaxy.server} yaml: {key: galaxy.server}
GALAXY_TOKEN:
default: null
description: "GitHub personnal access token"
env: [{name: ANSIBLE_GALAXY_TOKEN}]
ini:
- {key: token, section: galaxy}
yaml: {key: galaxy.token}
HOST_KEY_CHECKING: HOST_KEY_CHECKING:
name: Check host keys name: Check host keys
default: True default: True