Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow BuildVariables variables options #706

Open
dmlond opened this issue Nov 7, 2024 · 1 comment
Open

allow BuildVariables variables options #706

dmlond opened this issue Nov 7, 2024 · 1 comment

Comments

@dmlond
Copy link

dmlond commented Nov 7, 2024

in BuildVariables, I can create, update, and delete a variable with options that include environment_scope. I can get a variable with a defined environment_scope only if a variable with the same name does not exist with a different environment_scope (including the default scope ''.
If I create the same variable with multiple environment scopes (including the default scope "
"), all of the methods variable, create_variable, update_variable, and remove_variable raise an exception, even if I include options to update_variable and remove_variable.

*** Gitlab::Error::Conflict Exception: Server responded with code 409, message: There are multiple variables with provided parameters. Please use 'filter[environment_scope]'. Request URI: https://gitlab.dhe.duke.edu/api/v4/projects/7370/variables/FOO

nil

Gitlab ensures that the same variable can be defined with different environment scopes, so that a job that runs in one environment can use different values for the same variables (this is a 12factor design principle).

I am able to use the underlying client methods with ?filter[environment_scope]:

variable_scope='review-*'
g.create_variable(project_id, "FOO", "something")
g.create_variable(project_id, "FOO", environment_scope:variable_scope)
g.get("/projects/#{g.url_encode project_id}/variables/FOO?filter[environment_scope]=#{variable_scope}")
g.put("/projects/#{g.url_encode project_id}/variables/FOO?filter[environment_scope]=#{variable_scope}", options.merge(value: "NEW"))
g.delete("/projects/#{g.url_encode project_id}/variables/FOO?filter[environment_scope]=#{variable_scope}")
@dmlond
Copy link
Author

dmlond commented Nov 7, 2024

ok, so I can update and remove a variable with an environment_scope using

g.update_variable(project_id, "FOO", "NEW", 'filter[environment_scope]':variable_scope)
g.remove_variable(project_id, "FOO", 'filter[environment_scope]':variable_scope)

So, really, the issue is that I cannot call

g.variable(project_id, key, 'filter[environment_scope]':variable_scope)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant