Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 164d08d

Browse files
authored
Merge pull request #566 from bergwolf/owner
add owner field to list and state cmd
2 parents 06d70c1 + 85ce405 commit 164d08d

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

cli/list.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
)
1414

1515
const formatOptions = `table or json`
16+
const defaultOwner = "root"
1617

1718
// containerState represents the platform agnostic pieces relating to a
1819
// running container's status and state
@@ -67,14 +68,15 @@ in json format:
6768
switch context.String("format") {
6869
case "", "table":
6970
w := tabwriter.NewWriter(os.Stdout, 12, 1, 3, ' ', 0)
70-
fmt.Fprint(w, "ID\tPID\tSTATUS\tBUNDLE\tCREATED\n")
71+
fmt.Fprint(w, "ID\tPID\tSTATUS\tBUNDLE\tCREATED\tOWNER\n")
7172
for _, item := range s {
72-
fmt.Fprintf(w, "%s\t%d\t%s\t%s\t%s\n",
73+
fmt.Fprintf(w, "%s\t%d\t%s\t%s\t%s\t%s\n",
7374
item.ID,
7475
item.InitProcessPid,
7576
item.Status,
7677
item.Bundle,
77-
item.Created.Format(time.RFC3339Nano))
78+
item.Created.Format(time.RFC3339Nano),
79+
defaultOwner)
7880
}
7981
if err := w.Flush(); err != nil {
8082
fatal(err)

cli/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ func main() {
146146
if err := app.Run(os.Args); err != nil {
147147
glog.Errorf("app.Run(os.Args) failed with err: %#v", err)
148148
fmt.Fprintf(os.Stderr, "%v\n", err)
149+
cli.HandleExitCoder(err)
150+
// non-standard errors
151+
os.Exit(22)
149152
}
150153
}
151154

cli/ps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
var psCommand = cli.Command{
1313
Name: "ps",
1414
Usage: "ps displays the processes running inside a container",
15-
ArgsUsage: `<container-id> [ps options]`, Flags: []cli.Flag{
15+
ArgsUsage: `<container-id>`, Flags: []cli.Flag{
1616
cli.StringFlag{
1717
Name: "format, f",
1818
Value: "table",

cli/state.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ type cState struct {
3232
Status string `json:"status"`
3333
// Created is the unix timestamp for the creation time of the container in UTC
3434
Created time.Time `json:"created"`
35+
// Owner is the user who creates the container, currently must be root
36+
Owner string `json:"owner"`
3537
}
3638

3739
var stateCommand = cli.Command{
@@ -102,6 +104,7 @@ func getContainer(context *cli.Context, name string) (*cState, error) {
102104
Bundle: state.Bundle,
103105
Rootfs: filepath.Join(state.Bundle, "rootfs"),
104106
Created: time.Unix(state.ContainerCreateTime, 0),
107+
Owner: defaultOwner,
105108
}
106109
return s, nil
107110
}

tests/bats-integration/ps.bats

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function teardown() {
4646

4747
@test "ps -e -x" {
4848
# ps is not supported, it requires cgroups
49+
skip "runv ps does not support ps options"
4950
requires root
5051

5152
# start busybox detached

0 commit comments

Comments
 (0)