@@ -122,9 +122,7 @@ func (s *Service) collectContainers(ctx context.Context) ([]*Container, error) {
122
122
result := []* Container {}
123
123
124
124
for _ , container := range containers {
125
- // Compose add "/" before name, so Name[1] will store actaul name.
126
- name := strings .SplitAfter (container .Names [0 ], "/" )
127
- c , err := New (ctx , client , container .ID , name [1 ])
125
+ c , err := New (ctx , client , container .ID )
128
126
if err != nil {
129
127
return nil , err
130
128
}
@@ -461,11 +459,11 @@ func (s *Service) recreateIfNeeded(ctx context.Context, c *Container, noRecreate
461
459
}
462
460
463
461
func (s * Service ) recreate (ctx context.Context , c * Container ) (* Container , error ) {
464
- name := c .name
462
+ name := c .Name ()
465
463
newName := fmt .Sprintf ("%s_%s" , name , c .container .ID [:12 ])
466
464
logrus .Debugf ("Renaming %s => %s" , name , newName )
467
465
if err := c .Rename (ctx , newName ); err != nil {
468
- logrus .Errorf ("Failed to rename old container %s" , c .name )
466
+ logrus .Errorf ("Failed to rename old container %s" , c .Name () )
469
467
return nil , err
470
468
}
471
469
namer := NewSingleNamer (name )
@@ -475,24 +473,24 @@ func (s *Service) recreate(ctx context.Context, c *Container) (*Container, error
475
473
}
476
474
logrus .Debugf ("Created replacement container %s" , newContainer .container .ID )
477
475
if err := c .Remove (ctx , false ); err != nil {
478
- logrus .Errorf ("Failed to remove old container %s" , c .name )
476
+ logrus .Errorf ("Failed to remove old container %s" , c .Name () )
479
477
return nil , err
480
478
}
481
- logrus .Debugf ("Removed old container %s %s" , c .name , c .container .ID )
479
+ logrus .Debugf ("Removed old container %s %s" , c .Name () , c .container .ID )
482
480
return newContainer , nil
483
481
}
484
482
485
483
// OutOfSync checks if the container is out of sync with the service definition.
486
484
// It looks if the the service hash container label is the same as the computed one.
487
485
func (s * Service ) OutOfSync (ctx context.Context , c * Container ) (bool , error ) {
488
486
if c .ImageConfig () != s .serviceConfig .Image {
489
- logrus .Debugf ("Images for %s do not match %s!=%s" , c .name , c .ImageConfig (), s .serviceConfig .Image )
487
+ logrus .Debugf ("Images for %s do not match %s!=%s" , c .Name () , c .ImageConfig (), s .serviceConfig .Image )
490
488
return true , nil
491
489
}
492
490
493
491
expectedHash := config .GetServiceHash (s .name , s .Config ())
494
492
if c .Hash () != expectedHash {
495
- logrus .Debugf ("Hashes for %s do not match %s!=%s" , c .name , c .Hash (), expectedHash )
493
+ logrus .Debugf ("Hashes for %s do not match %s!=%s" , c .Name () , c .Hash (), expectedHash )
496
494
return true , nil
497
495
}
498
496
0 commit comments