-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Allow user env vars for GitLab subgroups #17831
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
Conversation
3286c4f to
2c1d74d
Compare
| export namespace UserEnvVar { | ||
| export const DELIMITER = "/"; | ||
| export const WILDCARD_ASTERISK = "*"; | ||
| const WILDCARD_SHARP = "#"; // TODO(gpl) Where does this come from? Bc we have/had patterns as part of URLs somewhere, maybe...? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a mention below https://github.dev/gitpod-io/gitpod/blob/2c1d74d479c10c68081d62c5a5f566ad1acd4e6d/components/gitpod-protocol/src/protocol.ts#L497-L498 not sure if this is still used and how/why a user would pass such a pattern through URL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could not find a mention in docs or tests anywhere. 🤷
I*'m inclined to remove it, but want to do that in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case I'd say let's remove and see who complains 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, after this has landed 👍
|
It seems a bit surprising that a single Edit: going with a lib might be a bit too much, but the supporting and requiring |
Yes, considered that...
...but also felt it's a tad too much as well. 🙃
Hm, so far I only thought about |
|
@svenefftinge I added the |
|
I believe translating the pattern to a regexp (i.e. |
4c8f2a1 to
61f84cb
Compare
|
@svenefftinge I did the regex version in 61f84cb but it a) does not remove that much code, and b) has other problems (escaping the pattern for other regex control characters |
| case WILDCARD_DOUBLE_ASTERISK: | ||
| return ".*"; | ||
| default: | ||
| return s; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asked chatGPT for replacing control patterns:
s.replace(/[-\/\\^$+?.()|[\]{}]/g, '\\$&')
didn't try 🤷
| return false; | ||
| } | ||
|
|
||
| const regexStr = joinRepositoryPattern( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the segments need to be joined using an escaped slash (\/)
Maybe there is less value in having a join function when gong with the regexp approach.
i.e. maybe just inlining .join('\/')?
| } | ||
| }), | ||
| ); | ||
| const regex = new RegExp(regexStr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new RegExp('^' + regexStr + '$')
|
Cool! I find the code much simpler tbh as we no longer have the iteration over two arrays logic |
61f84cb to
996620b
Compare
|
/unhold |
Description
This PR allows to specify environment variable patterns for subgroups in GitLab. This is a long-standing issue that we always avoided to fix, but is now requested/assumed to be working by multiple customers.
We had multiple discussions in the past about deprecating this feature in the first place. However never did so, because it's a very convenient feature, that even if we had better secret support, adds value for users.
For examples of what's possible see the tests here and here.
The docs don't need to be changed, but could use a bit more explanation (see here).
Related Issue(s)
Fixes WEB-353
How to test
Resolution
Permissions 1
gp env -u USER_GROUP_TEST, and see the "cannot delete" error ✔️Permissions 2
and see that it does what you'd expect without errors ✔️
Documentation
Preview status
Gitpod was successfully deployed to your preview environment.
Build Options
Build
Run the build with werft instead of GHA
Run Leeway with
--dont-testPublish
Installer
Add desired feature flags to the end of the line above, space separated
Preview Environment
If enabled this will build
install/previewIf enabled this will create the environment on GCE infra
Valid options are
all,workspace,webapp,ide,jetbrains,vscode,ssh/hold