server/createSandboxContainer: minor optimization
In case s.ContainerServer.Hooks is nil, newAnnotations variable is not
used, so let's move its initialization inside the `if` block.
@@ -805,6 +805,7 @@ func (s *Server) createSandboxContainer(ctx context.Context, ctr ctrIface.Contai
specgen.AddMount(mnt)
}
+ if s.ContainerServer.Hooks != nil {
newAnnotations := map[string]string{}
for key, value := range containerConfig.GetAnnotations() {
newAnnotations[key] = value
@@ -812,7 +813,7 @@ func (s *Server) createSandboxContainer(ctx context.Context, ctr ctrIface.Contai
for key, value := range sb.Annotations() {
newAnnotations[key] = value
}
- if s.ContainerServer.Hooks != nil {
+
if _, err := s.ContainerServer.Hooks.Hooks(specgen.Config, newAnnotations, len(containerConfig.GetMounts()) > 0); err != nil {
return nil, err
}
