Skip to content

Commit

Permalink
rename runcopts to runctypes
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Valarezo <[email protected]>
  • Loading branch information
jessvalarezo committed Nov 10, 2017
1 parent 807f4d2 commit 0961807
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 69 deletions.
4 changes: 2 additions & 2 deletions Protobuild.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ ignore_files = [

# Lock down runc config
[[descriptors]]
prefix = "github.com/containerd/containerd/linux/runcopts"
target = "linux/runcopts/next.pb.txt"
prefix = "github.com/containerd/containerd/linux/runctypes"
target = "linux/runctypes/next.pb.txt"
ignore_files = [
"google/protobuf/descriptor.proto",
"gogoproto/gogo.proto"
Expand Down
8 changes: 4 additions & 4 deletions container_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/containerd/cgroups"
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/linux/runcopts"
"github.com/containerd/containerd/linux/runctypes"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"golang.org/x/sys/unix"
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestShimInCgroup(t *testing.T) {
defer cg.Delete()

task, err := container.NewTask(ctx, empty(), func(_ context.Context, client *Client, r *TaskInfo) error {
r.Options = &runcopts.CreateOptions{
r.Options = &runctypes.CreateOptions{
ShimCgroup: path,
}
return nil
Expand Down Expand Up @@ -887,7 +887,7 @@ func TestContainerRuntimeOptions(t *testing.T) {
ctx, id,
WithNewSpec(withImageConfig(image), withExitStatus(7)),
withNewSnapshot(id, image),
WithRuntime("io.containerd.runtime.v1.linux", &runcopts.RuncOptions{Runtime: "no-runc"}),
WithRuntime("io.containerd.runtime.v1.linux", &runctypes.RuncOptions{Runtime: "no-runc"}),
)
if err != nil {
t.Error(err)
Expand Down Expand Up @@ -1040,7 +1040,7 @@ func testUserNamespaces(t *testing.T, readonlyRootFS bool) {
defer container.Delete(ctx, WithSnapshotCleanup)

task, err := container.NewTask(ctx, Stdio, func(_ context.Context, client *Client, r *TaskInfo) error {
r.Options = &runcopts.CreateOptions{
r.Options = &runctypes.CreateOptions{
IoUid: 1000,
IoGid: 1000,
}
Expand Down
14 changes: 7 additions & 7 deletions linux/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"path/filepath"

"github.com/containerd/containerd/events/exchange"
"github.com/containerd/containerd/linux/runcopts"
"github.com/containerd/containerd/linux/runctypes"
"github.com/containerd/containerd/linux/shim"
"github.com/containerd/containerd/linux/shim/client"
"github.com/pkg/errors"
Expand Down Expand Up @@ -72,32 +72,32 @@ type bundle struct {
}

// ShimOpt specifies shim options for initialization and connection
type ShimOpt func(*bundle, string, *runcopts.RuncOptions) (shim.Config, client.Opt)
type ShimOpt func(*bundle, string, *runctypes.RuncOptions) (shim.Config, client.Opt)

// ShimRemote is a ShimOpt for connecting and starting a remote shim
func ShimRemote(shimBinary, daemonAddress, cgroup string, nonewns, debug bool, exitHandler func()) ShimOpt {
return func(b *bundle, ns string, ropts *runcopts.RuncOptions) (shim.Config, client.Opt) {
return func(b *bundle, ns string, ropts *runctypes.RuncOptions) (shim.Config, client.Opt) {
return b.shimConfig(ns, ropts),
client.WithStart(shimBinary, b.shimAddress(ns), daemonAddress, cgroup, nonewns, debug, exitHandler)
}
}

// ShimLocal is a ShimOpt for using an in process shim implementation
func ShimLocal(exchange *exchange.Exchange) ShimOpt {
return func(b *bundle, ns string, ropts *runcopts.RuncOptions) (shim.Config, client.Opt) {
return func(b *bundle, ns string, ropts *runctypes.RuncOptions) (shim.Config, client.Opt) {
return b.shimConfig(ns, ropts), client.WithLocal(exchange)
}
}

// ShimConnect is a ShimOpt for connecting to an existing remote shim
func ShimConnect() ShimOpt {
return func(b *bundle, ns string, ropts *runcopts.RuncOptions) (shim.Config, client.Opt) {
return func(b *bundle, ns string, ropts *runctypes.RuncOptions) (shim.Config, client.Opt) {
return b.shimConfig(ns, ropts), client.WithConnect(b.shimAddress(ns))
}
}

// NewShimClient connects to the shim managing the bundle and tasks creating it if needed
func (b *bundle) NewShimClient(ctx context.Context, namespace string, getClientOpts ShimOpt, runcOpts *runcopts.RuncOptions) (*client.Client, error) {
func (b *bundle) NewShimClient(ctx context.Context, namespace string, getClientOpts ShimOpt, runcOpts *runctypes.RuncOptions) (*client.Client, error) {
cfg, opt := getClientOpts(b, namespace, runcOpts)
return client.New(ctx, cfg, opt)
}
Expand All @@ -120,7 +120,7 @@ func (b *bundle) shimAddress(namespace string) string {
return filepath.Join(string(filepath.Separator), "containerd-shim", namespace, b.id, "shim.sock")
}

func (b *bundle) shimConfig(namespace string, runcOptions *runcopts.RuncOptions) shim.Config {
func (b *bundle) shimConfig(namespace string, runcOptions *runctypes.RuncOptions) shim.Config {
var (
criuPath string
runtimeRoot string
Expand Down
4 changes: 2 additions & 2 deletions linux/runcopts/next.pb.txt → linux/runctypes/next.pb.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
file {
name: "github.com/containerd/containerd/linux/runcopts/runc.proto"
name: "github.com/containerd/containerd/linux/runctypes/runc.proto"
package: "containerd.linux.runc"
dependency: "gogoproto/gogo.proto"
message_type {
Expand Down Expand Up @@ -176,7 +176,7 @@ file {
}
}
options {
go_package: "github.com/containerd/containerd/linux/runcopts;runcopts"
go_package: "github.com/containerd/containerd/linux/runctypes;runctypes"
}
syntax: "proto3"
}
80 changes: 40 additions & 40 deletions linux/runcopts/runc.pb.go → linux/runctypes/runc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion linux/runcopts/runc.proto → linux/runctypes/runc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package containerd.linux.runc;

import "gogoproto/gogo.proto";

option go_package = "github.com/containerd/containerd/linux/runcopts;runcopts";
option go_package = "github.com/containerd/containerd/linux/runctypes;runctypes";

message RuncOptions {
string runtime = 1;
Expand Down
8 changes: 4 additions & 4 deletions linux/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/events/exchange"
"github.com/containerd/containerd/identifiers"
"github.com/containerd/containerd/linux/runcopts"
"github.com/containerd/containerd/linux/runctypes"
client "github.com/containerd/containerd/linux/shim"
shim "github.com/containerd/containerd/linux/shim/v1"
"github.com/containerd/containerd/log"
Expand Down Expand Up @@ -193,7 +193,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
if err != nil {
return nil, err
}
cgroup = v.(*runcopts.CreateOptions).ShimCgroup
cgroup = v.(*runctypes.CreateOptions).ShimCgroup
}
exitHandler := func() {
log.G(ctx).WithField("id", id).Info("shim reaped")
Expand Down Expand Up @@ -493,7 +493,7 @@ func (r *Runtime) getRuntime(ctx context.Context, ns, id string) (*runc.Runc, er
}, nil
}

func (r *Runtime) getRuncOptions(ctx context.Context, id string) (*runcopts.RuncOptions, error) {
func (r *Runtime) getRuncOptions(ctx context.Context, id string) (*runctypes.RuncOptions, error) {
var container containers.Container

if err := r.db.View(func(tx *bolt.Tx) error {
Expand All @@ -510,7 +510,7 @@ func (r *Runtime) getRuncOptions(ctx context.Context, id string) (*runcopts.Runc
if err != nil {
return nil, err
}
ropts, ok := v.(*runcopts.RuncOptions)
ropts, ok := v.(*runctypes.RuncOptions)
if !ok {
return nil, errors.New("invalid runtime options format")
}
Expand Down
10 changes: 5 additions & 5 deletions linux/shim/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

"github.com/containerd/console"
"github.com/containerd/containerd/identifiers"
"github.com/containerd/containerd/linux/runcopts"
"github.com/containerd/containerd/linux/runctypes"
shimapi "github.com/containerd/containerd/linux/shim/v1"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
Expand Down Expand Up @@ -67,13 +67,13 @@ func (s *Service) newInitProcess(context context.Context, r *shimapi.CreateTaskR
if err := identifiers.Validate(r.ID); err != nil {
return nil, errors.Wrapf(err, "invalid task id")
}
var options runcopts.CreateOptions
var options runctypes.CreateOptions
if r.Options != nil {
v, err := typeurl.UnmarshalAny(r.Options)
if err != nil {
return nil, err
}
options = *v.(*runcopts.CreateOptions)
options = *v.(*runctypes.CreateOptions)
}

rootfs := filepath.Join(s.config.Path, "rootfs")
Expand Down Expand Up @@ -332,13 +332,13 @@ func (p *initProcess) Stdin() io.Closer {
}

func (p *initProcess) checkpoint(context context.Context, r *shimapi.CheckpointTaskRequest) error {
var options runcopts.CheckpointOptions
var options runctypes.CheckpointOptions
if r.Options != nil {
v, err := typeurl.UnmarshalAny(r.Options)
if err != nil {
return err
}
options = *v.(*runcopts.CheckpointOptions)
options = *v.(*runctypes.CheckpointOptions)
}
var actions []runc.CheckpointAction
if !options.Exit {
Expand Down
4 changes: 2 additions & 2 deletions linux/shim/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/containerd/containerd/api/types/task"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/events"
"github.com/containerd/containerd/linux/runcopts"
"github.com/containerd/containerd/linux/runctypes"
shimapi "github.com/containerd/containerd/linux/shim/v1"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/namespaces"
Expand Down Expand Up @@ -364,7 +364,7 @@ func (s *Service) ListPids(ctx context.Context, r *shimapi.ListPidsRequest) (*sh
}
for _, p := range s.processes {
if p.Pid() == int(pid) {
d := &runcopts.ProcessDetails{
d := &runctypes.ProcessDetails{
ExecID: p.ID(),
}
a, err := typeurl.MarshalAny(d)
Expand Down
4 changes: 2 additions & 2 deletions task_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"syscall"

"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/linux/runcopts"
"github.com/containerd/containerd/linux/runctypes"
"github.com/containerd/containerd/mount"
)

Expand All @@ -22,7 +22,7 @@ func WithRootFS(mounts []mount.Mount) NewTaskOpts {

// WithExit causes the task to exit after a successful checkpoint
func WithExit(r *CheckpointTaskInfo) error {
r.Options = &runcopts.CheckpointOptions{
r.Options = &runctypes.CheckpointOptions{
Exit: true,
}
return nil
Expand Down

0 comments on commit 0961807

Please sign in to comment.