10
vendor/github.com/containerd/nri/client.go
generated
vendored
10
vendor/github.com/containerd/nri/client.go
generated
vendored
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/oci"
|
||||
@@ -23,15 +24,22 @@ const (
|
||||
Version = "0.1"
|
||||
)
|
||||
|
||||
var appendPathOnce sync.Once
|
||||
|
||||
// New nri client
|
||||
func New() (*Client, error) {
|
||||
conf, err := loadConfig(DefaultConfPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := os.Setenv("PATH", fmt.Sprintf("%s:%s", os.Getenv("PATH"), DefaultBinaryPath)); err != nil {
|
||||
|
||||
appendPathOnce.Do(func() {
|
||||
err = os.Setenv("PATH", fmt.Sprintf("%s:%s", os.Getenv("PATH"), DefaultBinaryPath))
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Client{
|
||||
conf: conf,
|
||||
}, nil
|
||||
|
||||
8
vendor/github.com/containerd/nri/types/v1/types.go
generated
vendored
8
vendor/github.com/containerd/nri/types/v1/types.go
generated
vendored
@@ -81,6 +81,14 @@ type Request struct {
|
||||
Results []*Result `json:"results,omitempty"`
|
||||
}
|
||||
|
||||
// NewPluginError returns a plugin error
|
||||
func NewPluginError(name string, err error) error {
|
||||
return &PluginError{
|
||||
Plugin: name,
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
|
||||
// PluginError for specific plugin execution
|
||||
type PluginError struct {
|
||||
// Plugin name
|
||||
|
||||
Reference in New Issue
Block a user