@@ -774,11 +774,10 @@ func (s *composeService) getLinks(ctx context.Context, projectName string, servi
774774 }
775775
776776 for _ , rawLink := range service .Links {
777- linkSplit := strings .Split (rawLink , ":" )
778- linkServiceName := linkSplit [0 ]
779- linkName := linkServiceName
780- if len (linkSplit ) == 2 {
781- linkName = linkSplit [1 ] // linkName if informed like in: "serviceName:linkName"
777+ // linkName if informed like in: "serviceName[:linkName]"
778+ linkServiceName , linkName , ok := strings .Cut (rawLink , ":" )
779+ if ! ok {
780+ linkName = linkServiceName
782781 }
783782 cnts , err := getServiceContainers (linkServiceName )
784783 if err != nil {
@@ -810,11 +809,9 @@ func (s *composeService) getLinks(ctx context.Context, projectName string, servi
810809 }
811810
812811 for _ , rawExtLink := range service .ExternalLinks {
813- extLinkSplit := strings .Split (rawExtLink , ":" )
814- externalLink := extLinkSplit [0 ]
815- linkName := externalLink
816- if len (extLinkSplit ) == 2 {
817- linkName = extLinkSplit [1 ]
812+ externalLink , linkName , ok := strings .Cut (rawExtLink , ":" )
813+ if ! ok {
814+ linkName = externalLink
818815 }
819816 links = append (links , format (externalLink , linkName ))
820817 }
0 commit comments