Skip to content

Commit

Permalink
remove containerd as dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit da8a7e5)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Sep 25, 2023
1 parent bcfcdd3 commit 9c23d8e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 795 deletions.
24 changes: 20 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
"os/exec"
"sync"

"github.com/containerd/containerd"
"github.com/containerd/containerd/oci"
types "github.com/containerd/nri/types/v1"

oci "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -74,13 +74,29 @@ type Sandbox struct {
Labels map[string]string
}

// process is a subset of containerd's Process interface.
type process interface {
// ID of the process
ID() string
// Pid is the system specific process id
Pid() uint32
}

// Task is ta subset of containerd's Task interface.
type Task interface {
process

// Spec returns the current OCI specification for the task
Spec(context.Context) (*oci.Spec, error)
}

// Invoke the ConfList of nri plugins
func (c *Client) Invoke(ctx context.Context, task containerd.Task, state types.State) ([]*types.Result, error) {
func (c *Client) Invoke(ctx context.Context, task Task, state types.State) ([]*types.Result, error) {
return c.InvokeWithSandbox(ctx, task, state, nil)
}

// InvokeWithSandbox invokes the ConfList of nri plugins
func (c *Client) InvokeWithSandbox(ctx context.Context, task containerd.Task, state types.State, sandbox *Sandbox) ([]*types.Result, error) {
func (c *Client) InvokeWithSandbox(ctx context.Context, task Task, state types.State, sandbox *Sandbox) ([]*types.Result, error) {
if len(c.conf.Plugins) == 0 {
return nil, nil
}
Expand Down
10 changes: 1 addition & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ module github.com/containerd/nri
go 1.14

require (
// when updating containerd, adjust the replace rules accordingly
github.com/containerd/containerd v1.5.0-beta.3
github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d
github.com/pkg/errors v0.9.1
)

replace (
github.com/gogo/googleapis => github.com/gogo/googleapis v1.3.2
github.com/golang/protobuf => github.com/golang/protobuf v1.3.5
google.golang.org/genproto => google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63
google.golang.org/grpc => google.golang.org/grpc v1.27.1
)
Loading

0 comments on commit 9c23d8e

Please sign in to comment.