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:
parent
92b3d79283
commit
576335e53d
2 changed files with 13 additions and 3 deletions
|
@ -545,14 +545,17 @@ class GalaxyCLI(CLI):
|
|||
"""
|
||||
# Authenticate with github and retrieve a token
|
||||
if self.options.token is None:
|
||||
login = GalaxyLogin(self.galaxy)
|
||||
github_token = login.create_github_token()
|
||||
if C.GALAXY_TOKEN:
|
||||
github_token = C.GALAXY_TOKEN
|
||||
else:
|
||||
login = GalaxyLogin(self.galaxy)
|
||||
github_token = login.create_github_token()
|
||||
else:
|
||||
github_token = self.options.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
|
||||
login.remove_github_token()
|
||||
|
||||
|
|
|
@ -1230,6 +1230,13 @@ GALAXY_SERVER:
|
|||
ini:
|
||||
- {key: server, section: galaxy}
|
||||
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:
|
||||
name: Check host keys
|
||||
default: True
|
||||
|
|
Loading…
Reference in a new issue