mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
gitlab_project_variable/gitlab_group_variable: Add support for 'raw' option (#7132)
feat(gitlab_project_variable): Add support for 'raw' option
This commit is contained in:
parent
4c8c25bc93
commit
e7d8ef4cf9
4 changed files with 99 additions and 6 deletions
3
changelogs/fragments/7132-gitlab-raw-variables.yml
Normal file
3
changelogs/fragments/7132-gitlab-raw-variables.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
minor_changes:
|
||||||
|
- gitlab_project_variable - add support for ``raw`` variables suboption (https://github.com/ansible-collections/community.general/pull/7132).
|
||||||
|
- gitlab_group_variable - add support for ``raw`` variables suboption (https://github.com/ansible-collections/community.general/pull/7132).
|
|
@ -135,6 +135,7 @@ def vars_to_variables(vars, module):
|
||||||
"value": str(value),
|
"value": str(value),
|
||||||
"masked": False,
|
"masked": False,
|
||||||
"protected": False,
|
"protected": False,
|
||||||
|
"raw": False,
|
||||||
"variable_type": "env_var",
|
"variable_type": "env_var",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -145,6 +146,7 @@ def vars_to_variables(vars, module):
|
||||||
"value": value.get('value'),
|
"value": value.get('value'),
|
||||||
"masked": value.get('masked'),
|
"masked": value.get('masked'),
|
||||||
"protected": value.get('protected'),
|
"protected": value.get('protected'),
|
||||||
|
"raw": value.get('raw'),
|
||||||
"variable_type": value.get('variable_type'),
|
"variable_type": value.get('variable_type'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,13 +53,14 @@ options:
|
||||||
type: bool
|
type: bool
|
||||||
vars:
|
vars:
|
||||||
description:
|
description:
|
||||||
- When the list element is a simple key-value pair, set masked and protected to false.
|
- When the list element is a simple key-value pair, masked, raw and protected will be set to false.
|
||||||
- When the list element is a dict with the keys C(value), C(masked) and C(protected), the user can
|
- When the list element is a dict with the keys C(value), C(masked), C(raw) and C(protected), the user can
|
||||||
have full control about whether a value should be masked, protected or both.
|
have full control about whether a value should be masked, raw, protected or both.
|
||||||
- Support for group variables requires GitLab >= 9.5.
|
- Support for group variables requires GitLab >= 9.5.
|
||||||
- Support for environment_scope requires GitLab Premium >= 13.11.
|
- Support for environment_scope requires GitLab Premium >= 13.11.
|
||||||
- Support for protected values requires GitLab >= 9.3.
|
- Support for protected values requires GitLab >= 9.3.
|
||||||
- Support for masked values requires GitLab >= 11.10.
|
- Support for masked values requires GitLab >= 11.10.
|
||||||
|
- Support for raw values requires GitLab >= 15.7.
|
||||||
- A C(value) must be a string or a number.
|
- A C(value) must be a string or a number.
|
||||||
- Field C(variable_type) must be a string with either V(env_var), which is the default, or V(file).
|
- Field C(variable_type) must be a string with either V(env_var), which is the default, or V(file).
|
||||||
- When a value is masked, it must be in Base64 and have a length of at least 8 characters.
|
- When a value is masked, it must be in Base64 and have a length of at least 8 characters.
|
||||||
|
@ -95,6 +96,13 @@ options:
|
||||||
- Wether variable value is protected or not.
|
- Wether variable value is protected or not.
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
|
raw:
|
||||||
|
description:
|
||||||
|
- Wether variable value is raw or not.
|
||||||
|
- Support for raw values requires GitLab >= 15.7.
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
version_added: '7.4.0'
|
||||||
variable_type:
|
variable_type:
|
||||||
description:
|
description:
|
||||||
- Wether a variable is an environment variable (V(env_var)) or a file (V(file)).
|
- Wether a variable is an environment variable (V(env_var)) or a file (V(file)).
|
||||||
|
@ -126,6 +134,38 @@ EXAMPLES = r'''
|
||||||
variable_type: env_var
|
variable_type: env_var
|
||||||
environment_scope: production
|
environment_scope: production
|
||||||
|
|
||||||
|
- name: Set or update some CI/CD variables with raw value
|
||||||
|
community.general.gitlab_group_variable:
|
||||||
|
api_url: https://gitlab.com
|
||||||
|
api_token: secret_access_token
|
||||||
|
group: scodeman/testgroup/
|
||||||
|
purge: false
|
||||||
|
vars:
|
||||||
|
ACCESS_KEY_ID: abc123
|
||||||
|
SECRET_ACCESS_KEY:
|
||||||
|
value: 3214cbad
|
||||||
|
masked: true
|
||||||
|
protected: true
|
||||||
|
raw: true
|
||||||
|
variable_type: env_var
|
||||||
|
environment_scope: '*'
|
||||||
|
|
||||||
|
- name: Set or update some CI/CD variables with expandable value
|
||||||
|
community.general.gitlab_group_variable:
|
||||||
|
api_url: https://gitlab.com
|
||||||
|
api_token: secret_access_token
|
||||||
|
group: scodeman/testgroup/
|
||||||
|
purge: false
|
||||||
|
vars:
|
||||||
|
ACCESS_KEY_ID: abc123
|
||||||
|
SECRET_ACCESS_KEY:
|
||||||
|
value: '$MY_OTHER_VARIABLE'
|
||||||
|
masked: true
|
||||||
|
protected: true
|
||||||
|
raw: false
|
||||||
|
variable_type: env_var
|
||||||
|
environment_scope: '*'
|
||||||
|
|
||||||
- name: Delete one variable
|
- name: Delete one variable
|
||||||
community.general.gitlab_group_variable:
|
community.general.gitlab_group_variable:
|
||||||
api_url: https://gitlab.com
|
api_url: https://gitlab.com
|
||||||
|
@ -199,6 +239,7 @@ class GitlabGroupVariables(object):
|
||||||
"value": var_obj.get('value'),
|
"value": var_obj.get('value'),
|
||||||
"masked": var_obj.get('masked'),
|
"masked": var_obj.get('masked'),
|
||||||
"protected": var_obj.get('protected'),
|
"protected": var_obj.get('protected'),
|
||||||
|
"raw": var_obj.get('raw'),
|
||||||
"variable_type": var_obj.get('variable_type'),
|
"variable_type": var_obj.get('variable_type'),
|
||||||
}
|
}
|
||||||
if var_obj.get('environment_scope') is not None:
|
if var_obj.get('environment_scope') is not None:
|
||||||
|
@ -267,6 +308,8 @@ def native_python_main(this_gitlab, purge, requested_variables, state, module):
|
||||||
item['value'] = str(item.get('value'))
|
item['value'] = str(item.get('value'))
|
||||||
if item.get('protected') is None:
|
if item.get('protected') is None:
|
||||||
item['protected'] = False
|
item['protected'] = False
|
||||||
|
if item.get('raw') is None:
|
||||||
|
item['raw'] = False
|
||||||
if item.get('masked') is None:
|
if item.get('masked') is None:
|
||||||
item['masked'] = False
|
item['masked'] = False
|
||||||
if item.get('environment_scope') is None:
|
if item.get('environment_scope') is None:
|
||||||
|
@ -343,6 +386,7 @@ def main():
|
||||||
value=dict(type='str', no_log=True),
|
value=dict(type='str', no_log=True),
|
||||||
masked=dict(type='bool', default=False),
|
masked=dict(type='bool', default=False),
|
||||||
protected=dict(type='bool', default=False),
|
protected=dict(type='bool', default=False),
|
||||||
|
raw=dict(type='bool', default=False),
|
||||||
environment_scope=dict(type='str', default='*'),
|
environment_scope=dict(type='str', default='*'),
|
||||||
variable_type=dict(type='str', default='env_var', choices=["env_var", "file"])
|
variable_type=dict(type='str', default='env_var', choices=["env_var", "file"])
|
||||||
)),
|
)),
|
||||||
|
|
|
@ -51,11 +51,12 @@ options:
|
||||||
type: bool
|
type: bool
|
||||||
vars:
|
vars:
|
||||||
description:
|
description:
|
||||||
- When the list element is a simple key-value pair, masked and protected will be set to false.
|
- When the list element is a simple key-value pair, masked, raw and protected will be set to false.
|
||||||
- When the list element is a dict with the keys C(value), C(masked) and C(protected), the user can
|
- When the list element is a dict with the keys C(value), C(masked), C(raw) and C(protected), the user can
|
||||||
have full control about whether a value should be masked, protected or both.
|
have full control about whether a value should be masked, raw, protected or both.
|
||||||
- Support for protected values requires GitLab >= 9.3.
|
- Support for protected values requires GitLab >= 9.3.
|
||||||
- Support for masked values requires GitLab >= 11.10.
|
- Support for masked values requires GitLab >= 11.10.
|
||||||
|
- Support for raw values requires GitLab >= 15.7.
|
||||||
- Support for environment_scope requires GitLab Premium >= 13.11.
|
- Support for environment_scope requires GitLab Premium >= 13.11.
|
||||||
- Support for variable_type requires GitLab >= 11.11.
|
- Support for variable_type requires GitLab >= 11.11.
|
||||||
- A C(value) must be a string or a number.
|
- A C(value) must be a string or a number.
|
||||||
|
@ -96,6 +97,13 @@ options:
|
||||||
- Support for protected values requires GitLab >= 9.3.
|
- Support for protected values requires GitLab >= 9.3.
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
|
raw:
|
||||||
|
description:
|
||||||
|
- Wether variable value is raw or not.
|
||||||
|
- Support for raw values requires GitLab >= 15.7.
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
version_added: '7.4.0'
|
||||||
variable_type:
|
variable_type:
|
||||||
description:
|
description:
|
||||||
- Wether a variable is an environment variable (V(env_var)) or a file (V(file)).
|
- Wether a variable is an environment variable (V(env_var)) or a file (V(file)).
|
||||||
|
@ -143,6 +151,38 @@ EXAMPLES = '''
|
||||||
variable_type: env_var
|
variable_type: env_var
|
||||||
environment_scope: '*'
|
environment_scope: '*'
|
||||||
|
|
||||||
|
- name: Set or update some CI/CD variables with raw value
|
||||||
|
community.general.gitlab_project_variable:
|
||||||
|
api_url: https://gitlab.com
|
||||||
|
api_token: secret_access_token
|
||||||
|
project: markuman/dotfiles
|
||||||
|
purge: false
|
||||||
|
vars:
|
||||||
|
ACCESS_KEY_ID: abc123
|
||||||
|
SECRET_ACCESS_KEY:
|
||||||
|
value: 3214cbad
|
||||||
|
masked: true
|
||||||
|
protected: true
|
||||||
|
raw: true
|
||||||
|
variable_type: env_var
|
||||||
|
environment_scope: '*'
|
||||||
|
|
||||||
|
- name: Set or update some CI/CD variables with expandable value
|
||||||
|
community.general.gitlab_project_variable:
|
||||||
|
api_url: https://gitlab.com
|
||||||
|
api_token: secret_access_token
|
||||||
|
project: markuman/dotfiles
|
||||||
|
purge: false
|
||||||
|
vars:
|
||||||
|
ACCESS_KEY_ID: abc123
|
||||||
|
SECRET_ACCESS_KEY:
|
||||||
|
value: '$MY_OTHER_VARIABLE'
|
||||||
|
masked: true
|
||||||
|
protected: true
|
||||||
|
raw: false
|
||||||
|
variable_type: env_var
|
||||||
|
environment_scope: '*'
|
||||||
|
|
||||||
- name: Delete one variable
|
- name: Delete one variable
|
||||||
community.general.gitlab_project_variable:
|
community.general.gitlab_project_variable:
|
||||||
api_url: https://gitlab.com
|
api_url: https://gitlab.com
|
||||||
|
@ -220,6 +260,7 @@ class GitlabProjectVariables(object):
|
||||||
"value": var_obj.get('value'),
|
"value": var_obj.get('value'),
|
||||||
"masked": var_obj.get('masked'),
|
"masked": var_obj.get('masked'),
|
||||||
"protected": var_obj.get('protected'),
|
"protected": var_obj.get('protected'),
|
||||||
|
"raw": var_obj.get('raw'),
|
||||||
"variable_type": var_obj.get('variable_type'),
|
"variable_type": var_obj.get('variable_type'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,6 +331,8 @@ def native_python_main(this_gitlab, purge, requested_variables, state, module):
|
||||||
item['value'] = str(item.get('value'))
|
item['value'] = str(item.get('value'))
|
||||||
if item.get('protected') is None:
|
if item.get('protected') is None:
|
||||||
item['protected'] = False
|
item['protected'] = False
|
||||||
|
if item.get('raw') is None:
|
||||||
|
item['raw'] = False
|
||||||
if item.get('masked') is None:
|
if item.get('masked') is None:
|
||||||
item['masked'] = False
|
item['masked'] = False
|
||||||
if item.get('environment_scope') is None:
|
if item.get('environment_scope') is None:
|
||||||
|
@ -366,6 +409,7 @@ def main():
|
||||||
value=dict(type='str', no_log=True),
|
value=dict(type='str', no_log=True),
|
||||||
masked=dict(type='bool', default=False),
|
masked=dict(type='bool', default=False),
|
||||||
protected=dict(type='bool', default=False),
|
protected=dict(type='bool', default=False),
|
||||||
|
raw=dict(type='bool', default=False),
|
||||||
environment_scope=dict(type='str', default='*'),
|
environment_scope=dict(type='str', default='*'),
|
||||||
variable_type=dict(type='str', default='env_var', choices=["env_var", "file"]),
|
variable_type=dict(type='str', default='env_var', choices=["env_var", "file"]),
|
||||||
)),
|
)),
|
||||||
|
|
Loading…
Reference in a new issue