From d5a8d1bae3acaa77276d01edd26736c940ab8612 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Fri, 30 Sep 2016 15:48:31 -0700 Subject: [PATCH] Add annotations for pods Signed-off-by: Mrunal Patel --- server/sandbox.go | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/server/sandbox.go b/server/sandbox.go index f1a5583e..764be6ad 100644 --- a/server/sandbox.go +++ b/server/sandbox.go @@ -16,11 +16,12 @@ import ( ) type sandbox struct { - id string - name string - logDir string - labels map[string]string - containers oci.Store + id string + name string + logDir string + labels map[string]string + annotations map[string]string + containers oci.Store } const ( @@ -129,20 +130,28 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest if err != nil { return nil, err } + + // add annotations + annotations := req.GetConfig().GetAnnotations() + annotationsJSON, err := json.Marshal(annotations) + if err != nil { + return nil, err + } g.AddAnnotation("ocid/labels", string(labelsJSON)) + g.AddAnnotation("ocid/annotations", string(annotationsJSON)) g.AddAnnotation("ocid/log_path", logDir) g.AddAnnotation("ocid/name", name) containerName := name + "-infra" g.AddAnnotation("ocid/container_name", containerName) s.addSandbox(&sandbox{ - id: id, - name: name, - logDir: logDir, - labels: labels, - containers: oci.NewMemoryStore(), + id: id, + name: name, + logDir: logDir, + labels: labels, + annotations: annotations, + containers: oci.NewMemoryStore(), }) - annotations := req.GetConfig().GetAnnotations() for k, v := range annotations { g.AddAnnotation(k, v) }