Merge pull request #2100 from dexidp/mysql-port
Fix MySQL connection to use the provided port
This commit is contained in:
commit
47b0a2bdf9
2 changed files with 6 additions and 2 deletions
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
|
@ -26,7 +26,7 @@ jobs:
|
||||||
MYSQL_ROOT_PASSWORD: root
|
MYSQL_ROOT_PASSWORD: root
|
||||||
MYSQL_DATABASE: dex
|
MYSQL_DATABASE: dex
|
||||||
ports:
|
ports:
|
||||||
- 3306:3306
|
- 3306
|
||||||
options: --health-cmd "mysql -proot -e \"show databases;\"" --health-interval 10s --health-timeout 5s --health-retries 5
|
options: --health-cmd "mysql -proot -e \"show databases;\"" --health-interval 10s --health-timeout 5s --health-retries 5
|
||||||
|
|
||||||
etcd:
|
etcd:
|
||||||
|
@ -64,7 +64,7 @@ jobs:
|
||||||
DEX_MYSQL_USER: root
|
DEX_MYSQL_USER: root
|
||||||
DEX_MYSQL_PASSWORD: root
|
DEX_MYSQL_PASSWORD: root
|
||||||
DEX_MYSQL_HOST: 127.0.0.1
|
DEX_MYSQL_HOST: 127.0.0.1
|
||||||
DEX_MYSQL_PORT: 3306
|
DEX_MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
|
||||||
DEX_POSTGRES_DATABASE: postgres
|
DEX_POSTGRES_DATABASE: postgres
|
||||||
DEX_POSTGRES_USER: postgres
|
DEX_POSTGRES_USER: postgres
|
||||||
DEX_POSTGRES_PASSWORD: postgres
|
DEX_POSTGRES_PASSWORD: postgres
|
||||||
|
|
|
@ -242,6 +242,10 @@ func (s *MySQL) open(logger log.Logger) (*conn, error) {
|
||||||
if s.Host[0] != '/' {
|
if s.Host[0] != '/' {
|
||||||
cfg.Net = "tcp"
|
cfg.Net = "tcp"
|
||||||
cfg.Addr = s.Host
|
cfg.Addr = s.Host
|
||||||
|
|
||||||
|
if s.Port != 0 {
|
||||||
|
cfg.Addr = net.JoinHostPort(s.Host, strconv.Itoa(int(s.Port)))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cfg.Net = "unix"
|
cfg.Net = "unix"
|
||||||
cfg.Addr = s.Host
|
cfg.Addr = s.Host
|
||||||
|
|
Reference in a new issue