-
Notifications
You must be signed in to change notification settings - Fork 318
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
Handling environmentScope as a key for project variables #324
Conversation
bde4157
to
0bf79e8
Compare
2b4ab0b
to
7a01879
Compare
@roidelapluie Could you please provide feedback to get this merged into master? |
f5e2660
to
be0b0d7
Compare
@ringods Could you please provide feedback to get this merged into master? |
Hi all, i've just tested the branch with some existing Gitlab project environment scoped variables and got following error while ...
Error: Unexpected ID format ("project-id:key"). Expected project:key:env
... Is there anything planed on how to transform existing variables with old structure to new one? Should we?
|
I didn't code for this.
I don't know the correct answer to 👆, because there is a matrix of non-trivial cases to consider here:
Based on my (limited) understanding of the TF plugin api, and the missing information in the state file, I suspect that we can't answer these questions to automate a fix. @Nosmoht Can you validate my thinking here? |
Fair question, which i'm unable to answer. Can we get someone from Gitlab into this? |
@Nosmoht here's the relevant gitlab issue. it looks like they're about to release an api update shortly: https://gitlab.com/gitlab-org/gitlab/-/issues/9912 I imagine once that's live the provider will need to be updated to support the new changes. |
Any news here? Gitlab released a fix for environment variables. |
If we are good, lets merge this, we couldn't update our CI variables because of this 😞 |
This probably shouldn't get merged unless and it'll it's checked against the gitlab api changes released recently to address the underlying api issue. people in #213 are saying this resource is currently broke entirely for them. |
Hi @nicholasklick, Thanks for looking into this. As mentioned in the issue description, this implementation applies a brute force approach. Given that the api now supports filtering by environment scope, this implementation is perhaps invalid. |
@techthumb good to know. @sfang97 will be investigating this further and help moving this toward merge. |
@techthumb Thanks for your work on this, a lot of people are looking forward to this being merged! 😄 |
The scope of this issue is getting large:
@sfang97 I don't have the bandwidth ATM to work on this. |
@roidelapluie Could you take a look at this Julien? The current implementation is a brute force approach, which may be a sufficient first iteration to fix the problems people are having. WDYT? |
I am not using that gitlab feature, so I do not know if that really helps or if we want a full solution from the start. |
If you can it would be good to include a new test that creates two different variables using the same key but different scopes. That would verify the new behavior, and the bug reported in #396 in particular. |
@armsnyder @sfang97 how can we work to move this through?
|
I agree with @sfang97 that the current hacky solution of iterating over all variables is good enough. The thing that's missing for me is validating that the provider version upgrade is safe. Changing a resource's ID format is listed as a potentially breaking change by Terraform. It isn't clear to me from Terraform's docs if implementing state migration makes it non-breaking, or if Terraform still wants it to be a major version upgrade. Does anyone know? |
Anyway major version upgrade is not an issue. We can release a 3.0.0 to be safe. |
@armsnyder @roidelapluie @sfang97 I suggest that we merge this and bump to a major version update. |
Seems like there are conflicts now. |
I can take a stab at a new PR, unless @sfang97 or someone else has already started on one. |
@armsnyder Go for it! Thanks for working on this :) |
Is it possible to get the GitLab provider from this PR and run it in my own project? |
@abelmokadem It is possible. You can clone the fork from this PR and build the provider yourself with |
Closing this since we merged #409 |
Gitlab introduced the
environmentScope
attribute to ProjectVariables.Within Gitlab, ProjectVariables are currently keyed by
key
.Since the introduction of
environmentScope
, ProjectVariables should be keyed bykey+environmentScope
.This PR now allows for the provider to be keyed by
key+environmentScope
.The current implementation is a workaround for a bug within Gitlab API.
https://gitlab.com/gitlab-org/gitlab/-/issues/20661
Brute-force approach to workaround the shortcoming of the Gitlab API issue:
Fixes #213
Fixes #298
Fixes #235