@@ -42,6 +42,8 @@ const (
4242var appendPathOnce sync.Once
4343
4444// New nri client
45+ //
46+ // Deprecated: NRI 0.1.0-style plugins should only be used through the v010-adapter plugin
4547func New () (* Client , error ) {
4648 conf , err := loadConfig (DefaultConfPath )
4749 if err != nil {
@@ -60,12 +62,28 @@ func New() (*Client, error) {
6062 }, nil
6163}
6264
65+ // Plugins returns a slice of the configured plugin names. This can be used by
66+ // the runtime to detect which plugins are configured.
67+ //
68+ // Deprecated: NRI 0.1.0-style plugins should only be used through the v010-adapter plugin
69+ func (c * Client ) Plugins () []string {
70+ names := make ([]string , 0 )
71+ for _ , p := range c .conf .Plugins {
72+ names = append (names , p .Type )
73+ }
74+ return names
75+ }
76+
6377// Client for calling nri plugins
78+ //
79+ // Deprecated: NRI 0.1.0-style plugins should only be used through the v010-adapter plugin
6480type Client struct {
6581 conf * types.ConfigList
6682}
6783
6884// Sandbox information
85+ //
86+ // Deprecated: NRI 0.1.0-style plugins should only be used through the v010-adapter plugin
6987type Sandbox struct {
7088 // ID of the sandbox
7189 ID string
@@ -82,6 +100,8 @@ type process interface {
82100}
83101
84102// Task is a subset of containerd's Task interface.
103+ //
104+ // Deprecated: NRI 0.1.0-style plugins should only be used through the v010-adapter plugin
85105type Task interface {
86106 process
87107
@@ -90,11 +110,15 @@ type Task interface {
90110}
91111
92112// Invoke the ConfList of nri plugins
113+ //
114+ // Deprecated: NRI 0.1.0-style plugins should only be used through the v010-adapter plugin
93115func (c * Client ) Invoke (ctx context.Context , task Task , state types.State ) ([]* types.Result , error ) {
94116 return c .InvokeWithSandbox (ctx , task , state , nil )
95117}
96118
97119// InvokeWithSandbox invokes the ConfList of nri plugins
120+ //
121+ // Deprecated: NRI 0.1.0-style plugins should only be used through the v010-adapter plugin
98122func (c * Client ) InvokeWithSandbox (ctx context.Context , task Task , state types.State , sandbox * Sandbox ) ([]* types.Result , error ) {
99123 if len (c .conf .Plugins ) == 0 {
100124 return nil , nil
@@ -129,7 +153,7 @@ func (c *Client) InvokeWithSandbox(ctx context.Context, task Task, state types.S
129153 return r .Results , nil
130154}
131155
132- func (c * Client ) invokePlugin (ctx context.Context , name string , r * types.Request ) (* types.Result , error ) {
156+ func (c * Client ) invokePlugin (ctx context.Context , name string , r * types.Request ) (* types.Result , error ) { //nolint:staticcheck
133157 payload , err := json .Marshal (r )
134158 if err != nil {
135159 return nil , err
@@ -154,28 +178,28 @@ func (c *Client) invokePlugin(ctx context.Context, name string, r *types.Request
154178 return nil , err
155179 }
156180 }
157- var result types.Result
181+ var result types.Result //nolint:staticcheck
158182 if err := json .Unmarshal (out , & result ); err != nil {
159183 return nil , fmt .Errorf ("failed to unmarshal plugin output %s: %w" , msg , err )
160184 }
161- if result .Err () != nil {
162- return nil , result .Err ()
185+ if result .Err () != nil { //nolint:staticcheck
186+ return nil , result .Err () //nolint:staticcheck
163187 }
164188 return & result , nil
165189}
166190
167- func loadConfig (path string ) (* types.ConfigList , error ) {
191+ func loadConfig (path string ) (* types.ConfigList , error ) { //nolint:staticcheck
168192 f , err := os .Open (path )
169193 if err != nil {
170194 // if we don't have a config list on disk, create a new one for use
171195 if os .IsNotExist (err ) {
172- return & types.ConfigList {
196+ return & types.ConfigList { //nolint:staticcheck
173197 Version : Version ,
174198 }, nil
175199 }
176200 return nil , err
177201 }
178- var c types.ConfigList
202+ var c types.ConfigList //nolint:staticcheck
179203 err = json .NewDecoder (f ).Decode (& c )
180204 f .Close ()
181205 if err != nil {
@@ -184,8 +208,8 @@ func loadConfig(path string) (*types.ConfigList, error) {
184208 return & c , nil
185209}
186210
187- func createSpec (spec * oci.Spec ) (* types.Spec , error ) {
188- s := types.Spec {
211+ func createSpec (spec * oci.Spec ) (* types.Spec , error ) { //nolint:staticcheck
212+ s := types.Spec { //nolint:staticcheck
189213 Namespaces : make (map [string ]string ),
190214 Annotations : spec .Annotations ,
191215 }
0 commit comments