@@ -304,6 +304,7 @@ func extractBaseName(id string) string {
304304 return id
305305}
306306
307+ // processResourcesWithServices processes resources with their assigned services
307308// processResourcesWithServices processes resources with their assigned services
308309func (cg * ConfigGenerator ) processResourcesWithServices (config * TraefikConfig ) error {
309310 activeDSConfig , err := cg .configManager .GetActiveDataSourceConfig ()
@@ -445,27 +446,22 @@ func (cg *ConfigGenerator) processResourcesWithServices(config *TraefikConfig) e
445446 }
446447 }
447448
448- // Find the section where serviceReference is set
449- var serviceReference string
450- if mapValueDataEntry .CustomServiceID .Valid && mapValueDataEntry .CustomServiceID .String != "" {
451- // Extract base name without any suffixes
452- baseName := normalizeServiceID (mapValueDataEntry .CustomServiceID .String )
453- // Always add the file provider for custom services
454- serviceReference = fmt .Sprintf ("%s@file" , baseName )
455- } else {
456- // For Docker environments when using Traefik API, prefer docker provider
457- providerSuffix := "docker"
458-
459- // If not using Traefik API as data source, use http provider
460- if activeDSConfig .Type != models .TraefikAPI {
461- providerSuffix = "http"
462- }
463-
464- // Extract base name without any suffixes
465- baseName := normalizeServiceID (info .ServiceID )
466- // Add the appropriate provider suffix
467- serviceReference = fmt .Sprintf ("%s@%s" , baseName , providerSuffix )
468- }
449+ var serviceReference string
450+ if mapValueDataEntry .CustomServiceID .Valid && mapValueDataEntry .CustomServiceID .String != "" {
451+ baseName := normalizeServiceID (mapValueDataEntry .CustomServiceID .String )
452+ serviceReference = fmt .Sprintf ("%s@file" , baseName )
453+ } else {
454+ if strings .Contains (info .ServiceID , "@" ) {
455+ serviceReference = info .ServiceID
456+ } else {
457+ providerSuffix := "docker"
458+ if activeDSConfig .Type != models .TraefikAPI {
459+ providerSuffix = "http"
460+ }
461+ baseName := normalizeServiceID (info .ServiceID )
462+ serviceReference = fmt .Sprintf ("%s@%s" , baseName , providerSuffix )
463+ }
464+ }
469465
470466 log .Printf ("Resource %s (HTTP): Router service set to %s. (SourceType: %s, ActiveDS: %s, CustomSvc: %s)" ,
471467 info .ID ,
@@ -474,9 +470,13 @@ if mapValueDataEntry.CustomServiceID.Valid && mapValueDataEntry.CustomServiceID.
474470 activeDSConfig .Type ,
475471 mapValueDataEntry .CustomServiceID .String )
476472
477- // Make sure we don't have duplicated suffixes in router ID
478473 routerIDBase := extractBaseName (info .ID )
479- routerIDForTraefik := fmt .Sprintf ("%s-auth" , routerIDBase )
474+ var routerIDForTraefik string
475+ if strings .HasSuffix (routerIDBase , "-auth" ) {
476+ routerIDForTraefik = routerIDBase
477+ } else {
478+ routerIDForTraefik = fmt .Sprintf ("%s-auth" , routerIDBase )
479+ }
480480
481481 routerConfig := map [string ]interface {}{
482482 "rule" : fmt .Sprintf ("Host(`%s`)" , info .Host ),
0 commit comments