Update runhcs-shim to use go-bindings
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
This commit is contained in:
10
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_create-scratch.go
generated
vendored
Normal file
10
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_create-scratch.go
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
package runhcs
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// CreateScratch creates a scratch vhdx at 'destpath' that is ext4 formatted.
|
||||
func (r *Runhcs) CreateScratch(context context.Context, destpath string) error {
|
||||
return r.runOrError(r.command(context, "create-scratch", "--destpath", destpath))
|
||||
}
|
||||
28
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_list.go
generated
vendored
Normal file
28
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_list.go
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
package runhcs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
irunhcs "github.com/Microsoft/hcsshim/internal/runhcs"
|
||||
)
|
||||
|
||||
// ContainerState is the representation of the containers state at the moment of
|
||||
// query.
|
||||
type ContainerState = irunhcs.ContainerState
|
||||
|
||||
// List containers started by runhcs.
|
||||
//
|
||||
// Note: This is specific to the Runhcs.Root namespace provided in the global
|
||||
// settings.
|
||||
func (r *Runhcs) List(context context.Context) ([]*ContainerState, error) {
|
||||
data, err := cmdOutput(r.command(context, "list", "--format=json"), false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var out []*ContainerState
|
||||
if err := json.Unmarshal(data, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
10
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_pause.go
generated
vendored
Normal file
10
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_pause.go
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
package runhcs
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// Pause suspends all processes inside the container.
|
||||
func (r *Runhcs) Pause(context context.Context, id string) error {
|
||||
return r.runOrError(r.command(context, "pause", id))
|
||||
}
|
||||
20
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_ps.go
generated
vendored
Normal file
20
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_ps.go
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
package runhcs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Ps displays the processes running inside a container.
|
||||
func (r *Runhcs) Ps(context context.Context, id string) ([]int, error) {
|
||||
data, err := cmdOutput(r.command(context, "ps", "--format=json", id), true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: %s", err, data)
|
||||
}
|
||||
var out []int
|
||||
if err := json.Unmarshal(data, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
33
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_resize-tty.go
generated
vendored
Normal file
33
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_resize-tty.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package runhcs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// ResizeTTYOpts is set of options that can be used with the ResizeTTY command.
|
||||
type ResizeTTYOpts struct {
|
||||
// Pid is the process pid (defaults to init pid).
|
||||
Pid *int
|
||||
}
|
||||
|
||||
func (opt *ResizeTTYOpts) args() ([]string, error) {
|
||||
var out []string
|
||||
if opt.Pid != nil {
|
||||
out = append(out, "--pid", strconv.Itoa(*opt.Pid))
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ResizeTTY updates the terminal size for a container process.
|
||||
func (r *Runhcs) ResizeTTY(context context.Context, id string, width, height uint16, opts *ResizeTTYOpts) error {
|
||||
args := []string{"resize-tty"}
|
||||
if opts != nil {
|
||||
oargs, err := opts.args()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
args = append(args, oargs...)
|
||||
}
|
||||
return r.runOrError(r.command(context, append(args, id, strconv.FormatUint(uint64(width), 10), strconv.FormatUint(uint64(height), 10))...))
|
||||
}
|
||||
10
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_resume.go
generated
vendored
Normal file
10
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_resume.go
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
package runhcs
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// Resume resumes all processes that have been previously paused.
|
||||
func (r *Runhcs) Resume(context context.Context, id string) error {
|
||||
return r.runOrError(r.command(context, "resume", id))
|
||||
}
|
||||
20
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_state.go
generated
vendored
Normal file
20
vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_state.go
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
package runhcs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// State outputs the state of a container.
|
||||
func (r *Runhcs) State(context context.Context, id string) (*ContainerState, error) {
|
||||
data, err := cmdOutput(r.command(context, "state", id), true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: %s", err, data)
|
||||
}
|
||||
var out ContainerState
|
||||
if err := json.Unmarshal(data, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
Reference in New Issue
Block a user