@@ -44,9 +44,24 @@ import (
4444)
4545
4646type CloudService struct {
47- Name string
48- Type string
49- Version string
47+ Name string
48+ Type string
49+ Endpoint string
50+ Version string
51+ }
52+
53+ // SetEndpoint validates and sets the endpoint based on the service type.
54+ // It handles special type mappings (e.g., redis-persistent -> redis, oracle-mysql -> mysql)
55+ // and defaults to using the type as the endpoint for standard services.
56+ func (s * CloudService )SetEndpoint () {
57+ switch s .Type {
58+ case "redis-persistent" :
59+ s .Endpoint = "redis"
60+ case "oracle-mysql" :
61+ s .Endpoint = "mysql"
62+ default :
63+ s .Endpoint = s .Type
64+ }
5065}
5166
5267var localNewCmd = & console.Command {
@@ -284,14 +299,23 @@ func parseCLIServices(services []string) ([]*CloudService, error) {
284299parts := strings .Split (config ,":" )
285300if len (parts )== 1 {
286301// service == name
287- service = & CloudService {Name :parts [0 ],Type :parts [0 ],Version :upsun .ServiceLastVersion (parts [1 ])}
302+ service = & CloudService {Name :parts [0 ],Type :parts [0 ],Version :upsun .ServiceLastVersion (parts [0 ])}
288303}else if len (parts )== 2 {
289304service = & CloudService {Name :parts [0 ],Type :parts [1 ],Version :upsun .ServiceLastVersion (parts [1 ])}
290305}else if len (parts )== 3 {
291306service = & CloudService {Name :parts [0 ],Type :parts [1 ],Version :parts [2 ]}
292307}else {
293308return nil ,errors .Errorf ("unable to parse service\" %s\" " ,config )
294309}
310+
311+ // Set endpoint based on type, handling special cases
312+ service .SetEndpoint ()
313+
314+ // For redis-persistent, update version based on the endpoint
315+ if service .Type == "redis-persistent" {
316+ service .Version = upsun .ServiceLastVersion (service .Endpoint )
317+ }
318+
295319cloudServices = append (cloudServices ,service )
296320}
297321return cloudServices ,nil
@@ -315,7 +339,15 @@ func parseDockerComposeServices(dir string) []*CloudService {
315339var s * CloudService
316340switch port .Target {
317341case 3306 :
318- s = & CloudService {Type :"mysql" }
342+ // Distinguish between MySQL and MariaDB based on image name
343+ dbType := "mysql"
344+ if strings .Contains (strings .ToLower (service .Image ),"mariadb" ) {
345+ dbType = "mariadb"
346+ }else if strings .Contains (strings .ToLower (service .Image ),"mysql" ) {
347+ dbType = "oracle-mysql"
348+ }
349+
350+ s = & CloudService {Type :dbType }
319351case 5432 :
320352s = & CloudService {Type :"postgresql" }
321353case 6379 :
@@ -335,6 +367,10 @@ func parseDockerComposeServices(dir string) []*CloudService {
335367if s != nil && ! done {
336368seen [service .Name ]= true
337369s .Name = service .Name
370+
371+ // Set endpoint based on type
372+ s .SetEndpoint ()
373+
338374parts := strings .Split (service .Image ,":" )
339375s .Version = regexp .MustCompile (`\d+(\.\d+)?` ).FindString (parts [len (parts )- 1 ])
340376serviceLastVersion := upsun .ServiceLastVersion (s .Type )