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

Commit

Permalink
Merge pull request #566 from bergwolf/owner
Browse files Browse the repository at this point in the history
add owner field to list and state cmd
  • Loading branch information
laijs authored Aug 21, 2017
2 parents 06d70c1 + 85ce405 commit 164d08d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
8 changes: 5 additions & 3 deletions cli/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
)

const formatOptions = `table or json`
const defaultOwner = "root"

// containerState represents the platform agnostic pieces relating to a
// running container's status and state
Expand Down Expand Up @@ -67,14 +68,15 @@ in json format:
switch context.String("format") {
case "", "table":
w := tabwriter.NewWriter(os.Stdout, 12, 1, 3, ' ', 0)
fmt.Fprint(w, "ID\tPID\tSTATUS\tBUNDLE\tCREATED\n")
fmt.Fprint(w, "ID\tPID\tSTATUS\tBUNDLE\tCREATED\tOWNER\n")
for _, item := range s {
fmt.Fprintf(w, "%s\t%d\t%s\t%s\t%s\n",
fmt.Fprintf(w, "%s\t%d\t%s\t%s\t%s\t%s\n",
item.ID,
item.InitProcessPid,
item.Status,
item.Bundle,
item.Created.Format(time.RFC3339Nano))
item.Created.Format(time.RFC3339Nano),
defaultOwner)
}
if err := w.Flush(); err != nil {
fatal(err)
Expand Down
3 changes: 3 additions & 0 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ func main() {
if err := app.Run(os.Args); err != nil {
glog.Errorf("app.Run(os.Args) failed with err: %#v", err)
fmt.Fprintf(os.Stderr, "%v\n", err)
cli.HandleExitCoder(err)
// non-standard errors
os.Exit(22)
}
}

Expand Down
2 changes: 1 addition & 1 deletion cli/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
var psCommand = cli.Command{
Name: "ps",
Usage: "ps displays the processes running inside a container",
ArgsUsage: `<container-id> [ps options]`, Flags: []cli.Flag{
ArgsUsage: `<container-id>`, Flags: []cli.Flag{
cli.StringFlag{
Name: "format, f",
Value: "table",
Expand Down
3 changes: 3 additions & 0 deletions cli/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type cState struct {
Status string `json:"status"`
// Created is the unix timestamp for the creation time of the container in UTC
Created time.Time `json:"created"`
// Owner is the user who creates the container, currently must be root
Owner string `json:"owner"`
}

var stateCommand = cli.Command{
Expand Down Expand Up @@ -102,6 +104,7 @@ func getContainer(context *cli.Context, name string) (*cState, error) {
Bundle: state.Bundle,
Rootfs: filepath.Join(state.Bundle, "rootfs"),
Created: time.Unix(state.ContainerCreateTime, 0),
Owner: defaultOwner,
}
return s, nil
}
Expand Down
1 change: 1 addition & 0 deletions tests/bats-integration/ps.bats
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function teardown() {

@test "ps -e -x" {
# ps is not supported, it requires cgroups
skip "runv ps does not support ps options"
requires root

# start busybox detached
Expand Down

0 comments on commit 164d08d

Please sign in to comment.