gitlab_*_variable: support masked-and-hidden variables (#10787)

* gitlab_*_variable: support masked-and-hidden variables

Support masking and hiding GitLab project and group variables. In the
GitLab API, variables that are hidden are also masked by implication.
Note gitlab_instance_variable is unmodified since instance variables
cannot be hidden.

* gitlab_*_variable: add `hidden` to legacy `vars` syntax

* gitlab_*_variable: address review comments in doc
This commit is contained in:
David Phillips 2025-09-09 04:40:35 +12:00 committed by GitHub
commit 3574b3fa93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 42 additions and 9 deletions

View file

@ -134,7 +134,7 @@ def gitlab_authentication(module, min_version=None):
def filter_returned_variables(gitlab_variables):
# pop properties we don't know
existing_variables = [dict(x.attributes) for x in gitlab_variables]
KNOWN = ['key', 'value', 'masked', 'protected', 'variable_type', 'environment_scope', 'raw']
KNOWN = ['key', 'value', 'masked', 'hidden', 'protected', 'variable_type', 'environment_scope', 'raw']
for item in existing_variables:
for key in list(item.keys()):
if key not in KNOWN:
@ -153,6 +153,7 @@ def vars_to_variables(vars, module):
"value": str(value),
"masked": False,
"protected": False,
"hidden": False,
"raw": False,
"variable_type": "env_var",
}
@ -163,6 +164,7 @@ def vars_to_variables(vars, module):
"name": item,
"value": value.get('value'),
"masked": value.get('masked'),
"hidden": value.get('hidden'),
"protected": value.get('protected'),
"raw": value.get('raw'),
"variable_type": value.get('variable_type'),