Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: action pkgs (#16804)
p0ny68eee7f01133
diff --git a/action/api.go b/action/command/api.gosimilarity index 99%rename from action/api.gorename to action/command/api.goindex e6561a31ff..57b0d2da59 100644--- a/action/api.go+++ b/action/command/api.go@@ -1,4 +1,4 @@-package main+package commandimport ("bytes"diff --git a/action/azure_devops.go b/action/command/azure_devops.gosimilarity index 98%rename from action/azure_devops.gorename to action/command/azure_devops.goindex 74d901ca59..381629c6df 100644--- a/action/azure_devops.go+++ b/action/command/azure_devops.go@@ -1,4 +1,4 @@-package main+package commandimport ("fmt"diff --git a/action/bitbucket.go b/action/command/bitbucket.gosimilarity index 99%rename from action/bitbucket.gorename to action/command/bitbucket.goindex 48a8d7b9c9..e52b1425c5 100644--- a/action/bitbucket.go+++ b/action/command/bitbucket.go@@ -1,4 +1,4 @@-package main+package commandimport ("bytes"diff --git a/action/check_cmd.go b/action/command/check.gosimilarity index 99%rename from action/check_cmd.gorename to action/command/check.goindex 5f0ba2ef53..cb66b89877 100644--- a/action/check_cmd.go+++ b/action/command/check.go@@ -1,4 +1,4 @@-package main+package commandimport ("log/slog"diff --git a/action/file.go b/action/command/file.gosimilarity index 98%rename from action/file.gorename to action/command/file.goindex e8a3cd05dd..df79817413 100644--- a/action/file.go+++ b/action/command/file.go@@ -1,4 +1,4 @@-package main+package commandimport ("log/slog"diff --git a/action/file_test.go b/action/command/file_test.gosimilarity index 99%rename from action/file_test.gorename to action/command/file_test.goindex 70eebe1c79..c235ff66ac 100644--- a/action/file_test.go+++ b/action/command/file_test.go@@ -1,4 +1,4 @@-package main+package commandimport ("testing"diff --git a/action/gitlab.go b/action/command/gitlab.gosimilarity index 99%rename from action/gitlab.gorename to action/command/gitlab.goindex 719efbddde..4e1f3a7127 100644--- a/action/gitlab.go+++ b/action/command/gitlab.go@@ -1,4 +1,4 @@-package main+package commandimport ("encoding/json"diff --git a/action/platform.go b/action/command/platform.gosimilarity index 98%rename from action/platform.gorename to action/command/platform.goindex a5c96a741e..b2f5c2c630 100644--- a/action/platform.go+++ b/action/command/platform.go@@ -1,4 +1,4 @@-package main+package commandimport "os"diff --git a/action/rollout_cmd.go b/action/command/rollout.gosimilarity index 99%rename from action/rollout_cmd.gorename to action/command/rollout.goindex 2135284ace..c49a5a1e48 100644--- a/action/rollout_cmd.go+++ b/action/command/rollout.go@@ -1,4 +1,4 @@-package main+package commandimport ("context"diff --git a/action/root_cmd.go b/action/command/root.gosimilarity index 76%rename from action/root_cmd.gorename to action/command/root.goindex 08a7ea6225..9a300c5656 100644--- a/action/root_cmd.go+++ b/action/command/root.go@@ -1,4 +1,4 @@-package main+package commandimport ("encoding/json"@@ -99,3 +99,33 @@ func writeOutputJSON(w *world.World) func(cmd *cobra.Command, args []string) errreturn nil}}++func checkVersionCompatibility(client *Client, cliVersion string) {+ if cliVersion == "unknown" {+ slog.Warn("CLI version unknown, unable to check compatibility")+ return+ }++ actuatorInfo, err := client.getActuatorInfo()+ if err != nil {+ slog.Warn("Unable to get server version for compatibility check", "error", err)+ return+ }++ serverVersion := actuatorInfo.Version+ if serverVersion == "" {+ slog.Warn("Server version is empty, unable to check compatibility")+ return+ }++ if cliVersion == "latest" {+ slog.Warn("Using 'latest' CLI version. It is recommended to use a specific version like bytebase-action:" + serverVersion + " to match your Bytebase server version " + serverVersion)+ return+ }++ if cliVersion != serverVersion {+ slog.Warn("CLI version mismatch", "cliVersion", cliVersion, "serverVersion", serverVersion, "recommendation", "use bytebase-action:"+serverVersion+" to match your Bytebase server")+ } else {+ slog.Info("CLI version matches server version", "version", cliVersion)+ }+}diff --git a/action/main.go b/action/main.goindex e6d4758720..1c7d1d7bdd 100644--- a/action/main.go+++ b/action/main.go@@ -9,40 +9,11 @@ import ("syscall""github.com/bytebase/bytebase/action/args"+ "github.com/bytebase/bytebase/action/command""github.com/bytebase/bytebase/action/world""github.com/bytebase/bytebase/backend/common/log")-func checkVersionCompatibility(client *Client, cliVersion string) {- if cliVersion == "unknown" {- slog.Warn("CLI version unknown, unable to check compatibility")- return- }-- actuatorInfo, err := client.getActuatorInfo()- if err != nil {- slog.Warn("Unable to get server version for compatibility check", "error", err)- return- }-- serverVersion := actuatorInfo.Version- if serverVersion == "" {- slog.Warn("Server version is empty, unable to check compatibility")- return- }-- if cliVersion == "latest" {- slog.Warn("Using 'latest' CLI version. It is recommended to use a specific version like bytebase-action:" + serverVersion + " to match your Bytebase server version " + serverVersion)- return- }-- if cliVersion != serverVersion {- slog.Warn("CLI version mismatch", "cliVersion", cliVersion, "serverVersion", serverVersion, "recommendation", "use bytebase-action:"+serverVersion+" to match your Bytebase server")- } else {- slog.Info("CLI version matches server version", "version", cliVersion)- }-}-func main() {slog.Info("bytebase-action version " + args.Version + " built at commit " + args.Gitcommit)ctx, cancel := context.WithCancel(context.Background())@@ -58,7 +29,7 @@ func main() {}()w := world.NewWorld()- cmd := NewRootCommand(w)+ cmd := command.NewRootCommand(w)if err := cmd.ExecuteContext(ctx); err != nil {slog.Error("failed to execute command", log.BBError(err))