8000 Wrong behavior saving project variables when environment scopes are configured. · Issue #1125 · python-gitlab/python-gitlab · GitHub
[go: up one dir, main page]

Skip to content
Wrong behavior saving project variables when environment scopes are configured.  #1125
Closed
@bymarshall

Description

@bymarshall

Description of the problem, including code/CLI snippet

If environment scopes are used in project variables, modifying and saving a project variable with a specific "environment_scope" is always altering the variable with the last defined scope.

Example:

>>> variables = project.variables.list()
>>> for variable in variables:
...     print("key: %s scope: %s" % (variable.key, variable.environment_scope))
... 
key: SCOPE_VARIABLE scope: qa
key: SCOPE_VARIABLE scope: prod
key: SCOPE_VARIABLE scope: test
>>> for variable in variables:
...    if variable.environment_scope == "prod":
...        variable.value="new_value"
...        variable.save()
...        print(variable.attributes)
... 
{'variable_type': 'env_var', 'key': 'SCOPE_VARIABLE', 'value': 'new_value', 'protected': False, 'masked': False, 'environment_scope': 'test', 'project_id': 123}

The variable with scope "prod" has not been modified, instead the variable with scope "test" is altered.

Expected Behavior

The variable with the specified scope should be updated.

Actual Behavior

The last scope defined for the variable is always taking precedence over the scope of the current variable that is going to be updated..

Specifications

  • python-gitlab version: 2.3.1
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 13.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0