@@ -22,12 +22,15 @@ import (
2222	"github.com/containerd/nri/pkg/api" 
2323)
2424
25+ // BuiltinPlugin implements the NRI API and runs in-process 
26+ // within the container runtime. 
2527type  BuiltinPlugin  struct  {
2628	Base      string 
2729	Index     string 
2830	Handlers  BuiltinHandlers 
2931}
3032
33+ // BuiltinHandlers contains request handlers for the builtin plugin. 
3134type  BuiltinHandlers  struct  {
3235	Configure             func (context.Context , * api.ConfigureRequest ) (* api.ConfigureResponse , error )
3336	Synchronize           func (context.Context , * api.SynchronizeRequest ) (* api.SynchronizeResponse , error )
@@ -48,6 +51,7 @@ type BuiltinHandlers struct {
4851	ValidateContainerAdjustment  func (context.Context , * api.ValidateContainerAdjustmentRequest ) error 
4952}
5053
54+ // Configure implements PluginService of the NRI API. 
5155func  (b  * BuiltinPlugin ) Configure (ctx  context.Context , req  * api.ConfigureRequest ) (* api.ConfigureResponse , error ) {
5256	var  (
5357		rpl  =  & api.ConfigureResponse {}
@@ -110,38 +114,44 @@ func (b *BuiltinPlugin) Configure(ctx context.Context, req *api.ConfigureRequest
110114	return  rpl , err 
111115}
112116
117+ // Synchronize implements PluginService of the NRI API. 
113118func  (b  * BuiltinPlugin ) Synchronize (ctx  context.Context , req  * api.SynchronizeRequest ) (* api.SynchronizeResponse , error ) {
114119	if  b .Handlers .Synchronize  !=  nil  {
115120		return  b .Handlers .Synchronize (ctx , req )
116121	}
117122	return  & api.SynchronizeResponse {}, nil 
118123}
119124
125+ // Shutdown implements PluginService of the NRI API. 
120126func  (b  * BuiltinPlugin ) Shutdown (context.Context , * api.ShutdownRequest ) (* api.ShutdownResponse , error ) {
121127	return  & api.ShutdownResponse {}, nil 
122128}
123129
130+ // CreateContainer implements PluginService of the NRI API. 
124131func  (b  * BuiltinPlugin ) CreateContainer (ctx  context.Context , req  * api.CreateContainerRequest ) (* api.CreateContainerResponse , error ) {
125132	if  b .Handlers .CreateContainer  !=  nil  {
126133		return  b .Handlers .CreateContainer (ctx , req )
127134	}
128135	return  & api.CreateContainerResponse {}, nil 
129136}
130137
138+ // UpdateContainer implements PluginService of the NRI API. 
131139func  (b  * BuiltinPlugin ) UpdateContainer (ctx  context.Context , req  * api.UpdateContainerRequest ) (* api.UpdateContainerResponse , error ) {
132140	if  b .Handlers .UpdateContainer  !=  nil  {
133141		return  b .Handlers .UpdateContainer (ctx , req )
134142	}
135143	return  & api.UpdateContainerResponse {}, nil 
136144}
137145
146+ // StopContainer implements PluginService of the NRI API. 
138147func  (b  * BuiltinPlugin ) StopContainer (ctx  context.Context , req  * api.StopContainerRequest ) (* api.StopContainerResponse , error ) {
139148	if  b .Handlers .StopContainer  !=  nil  {
140149		return  b .Handlers .StopContainer (ctx , req )
141150	}
142151	return  & api.StopContainerResponse {}, nil 
143152}
144153
154+ // StateChange implements PluginService of the NRI API. 
145155func  (b  * BuiltinPlugin ) StateChange (ctx  context.Context , evt  * api.StateChangeEvent ) (* api.StateChangeResponse , error ) {
146156	var  err  error 
147157	switch  evt .Event  {
@@ -182,20 +192,23 @@ func (b *BuiltinPlugin) StateChange(ctx context.Context, evt *api.StateChangeEve
182192	return  & api.StateChangeResponse {}, err 
183193}
184194
195+ // UpdatePodSandbox implements PluginService of the NRI API. 
185196func  (b  * BuiltinPlugin ) UpdatePodSandbox (ctx  context.Context , req  * api.UpdatePodSandboxRequest ) (* api.UpdatePodSandboxResponse , error ) {
186197	if  b .Handlers .UpdatePodSandbox  !=  nil  {
187198		return  b .Handlers .UpdatePodSandbox (ctx , req )
188199	}
189200	return  & api.UpdatePodSandboxResponse {}, nil 
190201}
191202
203+ // PostUpdatePodSandbox is a handler for the PostUpdatePodSandbox event. 
192204func  (b  * BuiltinPlugin ) PostUpdatePodSandbox (ctx  context.Context , req  * api.PostUpdatePodSandboxRequest ) error  {
193205	if  b .Handlers .PostUpdatePodSandbox  !=  nil  {
194206		return  b .Handlers .PostUpdatePodSandbox (ctx , req )
195207	}
196208	return  nil 
197209}
198210
211+ // ValidateContainerAdjustment implements PluginService of the NRI API. 
199212func  (b  * BuiltinPlugin ) ValidateContainerAdjustment (ctx  context.Context , req  * api.ValidateContainerAdjustmentRequest ) (* api.ValidateContainerAdjustmentResponse , error ) {
200213	if  b .Handlers .ValidateContainerAdjustment  !=  nil  {
201214		if  err  :=  b .Handlers .ValidateContainerAdjustment (ctx , req ); err  !=  nil  {
0 commit comments