Skip to content

Commit

Permalink
Merge pull request dexidp#2100 from dexidp/mysql-port
Browse files Browse the repository at this point in the history
Fix MySQL connection to use the provided port
  • Loading branch information
sagikazarmark authored Apr 27, 2021
2 parents afa6f1e + e2b56d0 commit 47b0a2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: dex
ports:
- 3306:3306
- 3306
options: --health-cmd "mysql -proot -e \"show databases;\"" --health-interval 10s --health-timeout 5s --health-retries 5

etcd:
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
DEX_MYSQL_USER: root
DEX_MYSQL_PASSWORD: root
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_USER: postgres
DEX_POSTGRES_PASSWORD: postgres
Expand Down
4 changes: 4 additions & 0 deletions storage/sql/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ func (s *MySQL) open(logger log.Logger) (*conn, error) {
if s.Host[0] != '/' {
cfg.Net = "tcp"
cfg.Addr = s.Host

if s.Port != 0 {
cfg.Addr = net.JoinHostPort(s.Host, strconv.Itoa(int(s.Port)))
}
} else {
cfg.Net = "unix"
cfg.Addr = s.Host
Expand Down

0 comments on commit 47b0a2b

Please sign in to comment.