@@ -57,63 +57,80 @@ func Get() *Service {
5757func (s * Service ) parseServices () {
5858 s .Services = make ([]util.Service , 0 )
5959
60- for label , services := range s .App .Services {
61- if util .IsValidServiceType (label ) || label == "user-provided" {
62- for _ , service := range services {
63- // try to figure out if user-provided service binding can be handled
64- if service .Label == "user-provided" {
65- // can it be identified as a custom postgres binding?
66- if postgres .IsPostgresBinding (& service ) {
67- service .Label = "postgres"
68- } else if mysql .IsMySQLBinding (& service ) { // or a mysql binding?
69- service .Label = "mysql"
70- } else if redis .IsRedisBinding (& service ) { // or a redis binding?
71- service .Label = "redis"
72- } else {
73- continue // cannot handle service binding
60+ for _ , services := range s .App .Services {
61+ for _ , service := range services {
62+ // exclude S3 storage service, don't try to parse it as a service for backups
63+ if service .Name == config .Get ().S3 .ServiceName ||
64+ (service .Label == config .Get ().S3 .ServiceLabel && service .Label != "user-provided" ) {
65+ continue
66+ }
67+
68+ // if it is an unrecognized type/label or user-provided service
69+ // then try to figure out if it can be identified as a supported service type
70+ if ! util .IsValidServiceType (service .Label ) || service .Label == "user-provided" {
71+ // can it be identified as a custom postgres binding?
72+ if postgres .IsPostgresBinding (& service ) {
73+ service .Label = "postgres"
74+ } else if mysql .IsMySQLBinding (& service ) { // or a mysql binding?
75+ service .Label = "mysql"
76+ } else if redis .IsRedisBinding (& service ) { // or a redis binding?
77+ service .Label = "redis"
78+ } else {
79+ // try to guess it via service tags as a last resort
80+ var identified bool
81+ for _ , tag := range service .Tags {
82+ if util .IsValidServiceType (tag ) {
83+ identified = true
84+ service .Label = tag
85+ break
86+ }
87+ }
88+ if ! identified {
89+ log .Errorf ("unsupported service type [%s]: could not identify [%s]" , service .Label , service .Name )
90+ continue // cannot handle this service binding
7491 }
7592 }
93+ }
7694
77- // read timeout for service
78- timeout := config .Get ().Services [service .Name ].Timeout
79- if timeout .Seconds () <= 1 {
80- timeout .Duration = 1 * time .Hour // default
81- }
95+ // read timeout for service
96+ timeout := config .Get ().Services [service .Name ].Timeout
97+ if timeout .Seconds () <= 1 {
98+ timeout .Duration = 1 * time .Hour // default
99+ }
82100
83- // read crontab schedule for service
84- schedule := config .Get ().Services [service .Name ].Schedule
85- if len (schedule ) == 0 {
86- // create a random schedule for daily backup as a fallback
87- schedule = fmt .Sprintf ("%d %d %d * * *" , rand .Intn (59 ), rand .Intn (59 ), rand .Intn (23 ))
88- }
101+ // read crontab schedule for service
102+ schedule := config .Get ().Services [service .Name ].Schedule
103+ if len (schedule ) == 0 {
104+ // create a random schedule for daily backup as a fallback
105+ schedule = fmt .Sprintf ("%d %d %d * * *" , rand .Intn (59 ), rand .Intn (59 ), rand .Intn (23 ))
106+ }
89107
90- // read retention days & files, with defaults as fallback
91- retentionDays := config .Get ().Services [service .Name ].Retention .Days
92- retentionFiles := config .Get ().Services [service .Name ].Retention .Files
93- if retentionDays <= 0 {
94- retentionDays = 31 // default
95- }
96- if retentionFiles <= 0 {
97- retentionFiles = 100 // default
98- }
108+ // read retention days & files, with defaults as fallback
109+ retentionDays := config .Get ().Services [service .Name ].Retention .Days
110+ retentionFiles := config .Get ().Services [service .Name ].Retention .Files
111+ if retentionDays <= 0 {
112+ retentionDays = 31 // default
113+ }
114+ if retentionFiles <= 0 {
115+ retentionFiles = 100 // default
116+ }
99117
100- newService := util.Service {
101- Name : service .Name ,
102- Label : service .Label ,
103- Plan : service .Plan ,
104- Tags : service .Tags ,
105- Timeout : timeout .Duration ,
106- Schedule : schedule ,
107- Retention : util.Retention {
108- Days : retentionDays ,
109- Files : retentionFiles ,
110- },
111- DisableColumnStatistics : config .Get ().Services [service .Name ].DisableColumnStatistics ,
112- ForceImport : config .Get ().Services [service .Name ].ForceImport ,
113- LocalBackupPath : config .Get ().Services [service .Name ].LocalBackupPath ,
114- }
115- s .Services = append (s .Services , newService )
118+ newService := util.Service {
119+ Name : service .Name ,
120+ Label : service .Label ,
121+ Plan : service .Plan ,
122+ Tags : service .Tags ,
123+ Timeout : timeout .Duration ,
124+ Schedule : schedule ,
125+ Retention : util.Retention {
126+ Days : retentionDays ,
127+ Files : retentionFiles ,
128+ },
129+ DisableColumnStatistics : config .Get ().Services [service .Name ].DisableColumnStatistics ,
130+ ForceImport : config .Get ().Services [service .Name ].ForceImport ,
131+ LocalBackupPath : config .Get ().Services [service .Name ].LocalBackupPath ,
116132 }
133+ s .Services = append (s .Services , newService )
117134 }
118135 }
119136
0 commit comments