Skip to content

Commit

Permalink
Merge pull request #9 from rluisr/accept_internalservererror
Browse files Browse the repository at this point in the history
Accept Internal Server Error / MySQL 8.0.32
  • Loading branch information
rluisr authored May 11, 2023
2 parents df2dd1c + f023759 commit 4395fd9
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 21 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
registries:
github-octocat:
type: git
url: https://github.com
username: rluisr
password: ${{secrets.MY_GITHUB_PERSONAL_TOKEN}}
updates:
- package-ecosystem: gomod
directory: "/"
registries:
- github-octocat
target-branch: "master"
19 changes: 19 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: lint

on:
push:
pull_request:

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
cache: true
- uses: golangci/golangci-lint-action@v3
with:
version: latest
12 changes: 0 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,8 @@ on:
push:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: latest

test:
name: Test
needs: lint
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile_test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18
FROM golang:1.20

WORKDIR /go/src/mysqlrouter-go
COPY . .
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ client for getting mysql-router information.

Supported version
-----------------
- 20190715 (8.0.17 - 8.0.29)
- 20190715 (8.0.17 - 8.0.32)

Enable HTTP Server and REST API
-------------------------------
Expand Down
4 changes: 2 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"crypto/tls"
"crypto/x509"
"github.com/stretchr/testify/assert"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"testing"
)
Expand Down Expand Up @@ -54,7 +54,7 @@ func TestNewClientWithTLS(t *testing.T) {
assert.NoError(t, err)
}

caCert, err := ioutil.ReadFile(caPath)
caCert, err := os.ReadFile(caPath)
if err != nil {
assert.NoError(t, err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rluisr/mysqlrouter-go

go 1.18
go 1.20

require github.com/stretchr/testify v1.6.1

Expand Down
7 changes: 4 additions & 3 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mysqlrouter

import (
"fmt"
"io/ioutil"
"io"
"net/http"
)

Expand Down Expand Up @@ -30,9 +30,10 @@ func (c *Client) request(url string) ([]byte, error) {
}
defer resp.Body.Close()

if resp.StatusCode != 200 {
// We accept InternalServerError because MySQL Router REST API return 500 when route status does not alive. see: https://github.com/rluisr/mysqlrouter_exporter/issues/30#issue-1703518829
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusInternalServerError {
return nil, fmt.Errorf("%s got %d", errStatusCode, resp.StatusCode)
}

return ioutil.ReadAll(resp.Body)
return io.ReadAll(resp.Body)
}
2 changes: 1 addition & 1 deletion test/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=8.0.29
VERSION=8.0.32

0 comments on commit 4395fd9

Please sign in to comment.