Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CADET-RDM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IBG-1
ModSim
CADET
CADET-RDM
Commits
f167cc3c
Commit
f167cc3c
authored
1 year ago
by
r.jaepel
Browse files
Options
Downloads
Patches
Plain Diff
Switch from GitLab namespace to GitLab groups
parent
2385faed
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cadetrdm/remote_integration.py
+19
-1
19 additions, 1 deletion
cadetrdm/remote_integration.py
with
19 additions
and
1 deletion
cadetrdm/remote_integration.py
+
19
−
1
View file @
f167cc3c
...
...
@@ -44,10 +44,28 @@ class GitLabRemote(Remote):
:return:
Query response
"""
namespace
=
namespace
.
lower
()
token
=
self
.
load_token
([
url
]
+
self
.
url_fallbacks
,
username
)
gl
=
gitlab
.
Gitlab
(
url
,
private_token
=
token
)
# We need the groups list, because for some ineffable reason, gitlab doesn't always give all namespaces.
# This assumes, that the group_id and the corresponding namespace_id are identical. So far this has been true.
gl_groups
=
gl
.
groups
.
list
(
get_all
=
True
)
# We also need the namespace list for the personal namespace.
gl_namespaces
=
gl
.
namespaces
.
list
(
get_all
=
True
)
matching_namespace
=
[
gl_group
for
gl_group
in
gl_groups
+
gl_namespaces
if
gl_group
.
full_path
.
lower
()
==
namespace
]
if
len
(
matching_namespace
)
==
0
:
raise
ValueError
(
f
"
Could not find namespace
{
namespace
}
"
f
"
in
{
[
gl_namespace
.
full_path
for
gl_namespace
in
gl_groups
]
}
"
)
if
len
(
matching_namespace
)
>=
2
:
matching_namespace_id_set
=
set
({
group
.
id
for
group
in
matching_namespace
})
if
len
(
matching_namespace_id_set
)
>
1
:
raise
ValueError
(
f
"
Not unique namespace
{
namespace
}
"
f
"
in
{
[
gl_namespace
.
full_path
.
lower
()
for
gl_namespace
in
gl_groups
]
}
"
)
namespace_id
=
matching_namespace
[
0
].
id
namespace_id
=
gl
.
namespaces
.
list
(
get_all
=
True
,
search
=
namespace
)[
0
].
id
response
=
gl
.
projects
.
create
({
"
name
"
:
name
,
"
namespace_id
"
:
namespace_id
})
return
response
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment