Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: use file suffix to only download the mysql for the platform (#815)

Danny Xu32abe1e189b6
diff --git a/.gitignore b/.gitignore
index 3c405c4dc4..64c0d83804 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,9 @@
*.so
*.dylib
+# MySQL packages
+mysql-*.tar*
+
# Test binary, built with `go test -c`
*.test
diff --git a/resources/mysql/fetch_mysql.sh b/resources/mysql/fetch_mysql.sh
index 95eba15f8f..8e6cad0ab7 100755
--- a/resources/mysql/fetch_mysql.sh
+++ b/resources/mysql/fetch_mysql.sh
@@ -20,25 +20,4 @@ atomic_download() {
fi
}
-mysql_8_0_28_macos11_arm64() {
- if [[ $(uname) = Darwin && $(uname -m) = arm64 ]]; then
- atomic_download mysql-8.0.28-macos11-arm64.tar.gz f1943053b12428e4c0e4ed309a636fd0
- else
- touch mysql-8.0.28-macos11-arm64.tar.gz
- fi
-}
-
-mysql_8_0_28_linux_glibc2_17_x86_64_minimal() {
- if [[ ! $(uname) = Darwin || ! $(uname -m) = arm64 ]]; then
- atomic_download mysql-8.0.28-linux-glibc2.17-x86_64-minimal.tar.xz 55a7759e25cc527416150c8181ce3f6d
- else
- touch mysql-8.0.28-linux-glibc2.17-x86_64-minimal.tar.xz
- fi
-}
-
-mysql() {
- mysql_8_0_28_macos11_arm64
- mysql_8_0_28_linux_glibc2_17_x86_64_minimal
-}
-
-mysql
+atomic_download $1 $2
diff --git a/resources/mysql/mysql.go b/resources/mysql/mysql.go
index f37b0a00a9..fd20c6790f 100644
--- a/resources/mysql/mysql.go
+++ b/resources/mysql/mysql.go
@@ -2,7 +2,6 @@ package mysql
import (
"database/sql"
- "embed"
"fmt"
"io"
"os"
@@ -17,13 +16,6 @@ import (
_ "github.com/go-sql-driver/mysql"
)
-//go:generate ./fetch_mysql.sh
-
-//go:embed mysql-8.0.28-macos11-arm64.tar.gz mysql-8.0.28-linux-glibc2.17-x86_64-minimal.tar.xz
-// To use this package in testing, download the MySQL binary first:
-// go generate ./...
-var resources embed.FS
-
// Instance is MySQL instance installed by bytebase for testing.
type Instance struct {
// basedir is the directory where the mysql binary is installed.
diff --git a/resources/mysql/resources_darwin.go b/resources/mysql/resources_darwin.go
new file mode 100644
index 0000000000..f596392b06
--- /dev/null
+++ b/resources/mysql/resources_darwin.go
@@ -0,0 +1,11 @@
+package mysql
+
+import "embed"
+
+// f1943053b12428e4c0e4ed309a636fd0 is the md5 hash.
+//go:generate ./fetch_mysql.sh mysql-8.0.28-macos11-arm64.tar.gz f1943053b12428e4c0e4ed309a636fd0
+
+//go:embed mysql-8.0.28-macos11-arm64.tar.gz
+// To use this package in testing, download the MySQL binary first:
+// go generate ./...
+var resources embed.FS
diff --git a/resources/mysql/resources_linux.go b/resources/mysql/resources_linux.go
new file mode 100644
index 0000000000..cfb4e00625
--- /dev/null
+++ b/resources/mysql/resources_linux.go
@@ -0,0 +1,11 @@
+package mysql
+
+import "embed"
+
+// 55a7759e25cc527416150c8181ce3f6d is the md5 hash.
+//go:generate ./fetch_mysql.sh mysql-8.0.28-linux-glibc2.17-x86_64-minimal.tar.xz 55a7759e25cc527416150c8181ce3f6d
+
+//go:embed mysql-8.0.28-linux-glibc2.17-x86_64-minimal.tar.xz
+// To use this package in testing, download the MySQL binary first:
+// go generate ./...
+var resources embed.FS