container_create: read ctr annotations for hooks first

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2018-02-12 11:20:48 +01:00
parent ebb88f9a67
commit c3f1e7aec2
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9

View file

@ -757,6 +757,18 @@ func (s *Server) setupOCIHooks(specgen *generate.Generator, sb *sandbox.Sandbox,
} }
} }
for _, annotationRegex := range hook.Annotations { for _, annotationRegex := range hook.Annotations {
for _, annotation := range containerConfig.GetAnnotations() {
match, err := regexp.MatchString(annotationRegex, annotation)
if err != nil {
logrus.Errorf("Invalid regex %q:%q", annotationRegex, err)
continue
}
if match {
if err := addHook(hook); err != nil {
return err
}
}
}
for _, annotation := range sb.Annotations() { for _, annotation := range sb.Annotations() {
match, err := regexp.MatchString(annotationRegex, annotation) match, err := regexp.MatchString(annotationRegex, annotation)
if err != nil { if err != nil {