Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3711f19

Browse files
author
Gauvain Pocentek
committed
Add sudo support
1 parentc579c80 commit3711f19

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

‎docs/api-usage.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,13 @@ Use the ``all`` parameter to get all the items:
117117
..code-block::python
118118
119119
all_groups= gl.groups.list(all=True)
120+
121+
Sudo
122+
====
123+
124+
If you have the administrator status, you can use ``sudo`` to act as another
125+
user. For example:
126+
127+
..code-block::python
128+
129+
p= gl.projects.create({'name':'awesome_project'},sudo='user1')

‎docs/cli.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,9 @@ Define the status of a commit (as would be done from a CI tool for example):
189189
--commit-id a43290c --state success --name ci/jenkins \
190190
--target-url http://server/build/123 \
191191
--description "Jenkins build succeeded"
192+
193+
Use sudo to act as another user (admin only):
194+
195+
..code-block::console
196+
197+
$ gitlab project create --name user_project1 --sudo username

‎gitlab/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def _populate_sub_parser_by_class(cls, sub_parser):
7373
[sub_parser_action.add_argument("--%s"%x.replace('_','-'),
7474
required=True)
7575
forxincls.requiredUrlAttrs]
76+
sub_parser_action.add_argument("--sudo",required=False)
7677

7778
ifaction_name==LIST:
7879
[sub_parser_action.add_argument("--%s"%x.replace('_','-'),

‎gitlab/objects.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def _data_for_gitlab(self, extra_parameters={}, update=False):
227227
else:
228228
attributes=itertools.chain(self.requiredCreateAttrs,
229229
self.optionalCreateAttrs)
230+
attributes=list(attributes)+ ['sudo','page','per_page']
230231
forattributeinattributes:
231232
ifhasattr(self,attribute):
232233
data[attribute]=getattr(self,attribute)

‎tools/python_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@
9898
'namespace_id':group1.id})
9999
gr2_project=gl.projects.create({'name':'gr2_project',
100100
'namespace_id':group2.id})
101+
sudo_project=gl.projects.create({'name':'sudo_project'},sudo=user1.name)
101102

102-
assert(len(gl.projects.all())==3)
103+
assert(len(gl.projects.all())==4)
103104
assert(len(gl.projects.owned())==2)
104105
assert(len(gl.projects.search("admin"))==1)
105106

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp