[PR #10787/3574b3fa backport][stable-11] gitlab_*_variable: support masked-and-hidden variables (#10801)

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

(cherry picked from commit 3574b3fa93)

Co-authored-by: David Phillips <phillid@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2025-09-08 18:54:38 +02:00 committed by GitHub
commit 88f0a4c770
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'),