From def5ff3c4b3bea7780f821583a55dba1749b973b Mon Sep 17 00:00:00 2001 From: Danny Canter Date: Fri, 11 Aug 2023 23:24:45 -0700 Subject: [PATCH] Sandbox: Add annotations to controller CreateOptions Following the addition of annotations to the grpc/ttrpc API surface, follow suit with adding annotations to the controller api surface. Signed-off-by: Danny Canter --- sandbox/controller.go | 13 +++++++++++-- sandbox/proxy/controller.go | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sandbox/controller.go b/sandbox/controller.go index 0ee315b93..45264e791 100644 --- a/sandbox/controller.go +++ b/sandbox/controller.go @@ -33,8 +33,9 @@ type CreateOptions struct { // CRI will use this to pass PodSandboxConfig. // Don't confuse this with Runtime options, which are passed at shim instance start // to setup global shim configuration. - Options typeurl.Any - NetNSPath string + Options typeurl.Any + NetNSPath string + Annotations map[string]string } type CreateOpt func(*CreateOptions) error @@ -68,6 +69,14 @@ func WithNetNSPath(netNSPath string) CreateOpt { } } +// WithAnnotations sets the provided annotations for sandbox creation. +func WithAnnotations(annotations map[string]string) CreateOpt { + return func(co *CreateOptions) error { + co.Annotations = annotations + return nil + } +} + type StopOptions struct { Timeout *time.Duration } diff --git a/sandbox/proxy/controller.go b/sandbox/proxy/controller.go index 05b550722..770b561b7 100644 --- a/sandbox/proxy/controller.go +++ b/sandbox/proxy/controller.go @@ -52,7 +52,8 @@ func (s *remoteSandboxController) Create(ctx context.Context, sandboxID string, TypeUrl: options.Options.GetTypeUrl(), Value: options.Options.GetValue(), }, - NetnsPath: options.NetNSPath, + NetnsPath: options.NetNSPath, + Annotations: options.Annotations, }) if err != nil { return errdefs.FromGRPC(err)