Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Ship Cat container manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wizards
Ship Cat container manager
Commits
903cf117
Commit
903cf117
authored
1 year ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Implemented "shc list"
parent
b375b13d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
shipcat/main.py
+18
-11
18 additions, 11 deletions
shipcat/main.py
with
18 additions
and
11 deletions
shipcat/main.py
+
18
−
11
View file @
903cf117
...
...
@@ -52,15 +52,10 @@ def setup_container(args: argparse.Namespace, require_root: bool, container: Opt
except
ConfigError
as
e
:
die
(
str
(
e
))
if
args
.
as_user
is
None
:
uid
=
0
else
:
uid
=
args
.
as_user
if
require_root
and
uid
!=
0
:
if
require_root
and
args
.
as_user
!=
0
:
die
(
'
This operation must be performed by root
'
)
if
not
check_rights
(
cc
,
uid
,
args
.
as_groups
):
if
not
check_rights
(
cc
,
args
.
as_user
,
args
.
as_groups
):
die
(
'
You do not have permission to operate this container
'
)
return
cc
...
...
@@ -308,6 +303,14 @@ def cmd_rsync(args: argparse.Namespace) -> None:
run_command
(
cmd
)
def
cmd_list
(
args
:
argparse
.
Namespace
)
->
None
:
for
conf
in
Path
(
config
.
container_config_dir
).
iterdir
():
if
conf
.
suffix
==
'
.toml
'
:
cc
=
ContainerConfig
.
load
(
config
,
conf
.
stem
)
if
args
.
all
or
check_rights
(
cc
,
args
.
as_user
,
args
.
as_groups
):
print
(
cc
.
container
)
def
parse_int_list
(
s
:
str
)
->
List
[
int
]:
return
list
(
map
(
int
,
s
.
split
(
'
,
'
)))
...
...
@@ -316,14 +319,11 @@ def main() -> None:
parser
=
argparse
.
ArgumentParser
(
description
=
"
Ship
'
s Cat -- a container management tool
"
,
)
parser
.
add_argument
(
'
--as-user
'
,
type
=
int
,
metavar
=
'
UID
'
,
help
=
'
user ID of requesting user
'
)
parser
.
add_argument
(
'
--as-user
'
,
type
=
int
,
default
=
0
,
metavar
=
'
UID
'
,
help
=
'
user ID of requesting user
'
)
parser
.
add_argument
(
'
--as-groups
'
,
type
=
parse_int_list
,
metavar
=
'
GID,...
'
,
help
=
'
group IDs of requesting user (primary first)
'
)
parser
.
add_argument
(
'
--verbose
'
,
'
-v
'
,
default
=
False
,
action
=
'
store_true
'
,
help
=
'
be chatty and explain what is going on
'
)
subparsers
=
parser
.
add_subparsers
(
help
=
'
action to perform
'
,
dest
=
'
action
'
,
required
=
True
,
metavar
=
'
ACTION
'
)
init_parser
=
subparsers
.
add_parser
(
'
init
'
,
help
=
'
initialize a new container
'
,
description
=
'
Initialize a new container. Should be called by root.
'
)
init_parser
.
add_argument
(
'
name
'
,
help
=
'
name of the container
'
)
create_parser
=
subparsers
.
add_parser
(
'
create
'
,
help
=
'
create a container from an image
'
,
description
=
'
Create a container from an image.
'
)
create_parser
.
add_argument
(
'
name
'
,
help
=
'
name of the container
'
)
...
...
@@ -339,6 +339,12 @@ def main() -> None:
create_parser
.
add_argument
(
'
--tty
'
,
'
-t
'
,
default
=
False
,
action
=
'
store_true
'
,
help
=
'
stdio will be attached to a pseudo-terminal
'
)
create_parser
.
add_argument
(
'
--user
'
,
'
-u
'
,
metavar
=
'
USER[:GROUP]
'
,
help
=
'
user/group to run the command under (default: root)
'
)
init_parser
=
subparsers
.
add_parser
(
'
init
'
,
help
=
'
initialize a new container
'
,
description
=
'
Initialize a new container. Should be called by root.
'
)
init_parser
.
add_argument
(
'
name
'
,
help
=
'
name of the container
'
)
list_parser
=
subparsers
.
add_parser
(
'
list
'
,
help
=
'
list available containers
'
,
description
=
'
List available containers.
'
)
list_parser
.
add_argument
(
'
--all
'
,
'
-a
'
,
default
=
False
,
action
=
'
store_true
'
,
help
=
'
include containers with no permission to operate
'
)
start_parser
=
subparsers
.
add_parser
(
'
rsync
'
,
help
=
'
rsync connection wrapper
'
,
description
=
"""
Connection wrapper for rsync.
...
...
@@ -368,6 +374,7 @@ def main() -> None:
'
enable
'
:
cmd_enable
,
'
exec
'
:
cmd_exec
,
'
init
'
:
cmd_init
,
'
list
'
:
cmd_list
,
'
rsync
'
:
cmd_rsync
,
'
shell
'
:
cmd_shell
,
'
start
'
:
cmd_start
,
...
...
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