Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(action): add configurable HTTP timeout flag (#19798)
p0nyfa8d9426df89
diff --git a/action/command/root.go b/action/command/root.goindex 56ac79c28f..442e16f6c8 100644--- a/action/command/root.go+++ b/action/command/root.go@@ -3,6 +3,7 @@ package commandimport ("context""log/slog"+ "time""github.com/pkg/errors""github.com/spf13/cobra"@@ -23,6 +24,7 @@ func NewRootCommand(w *world.World) *cobra.Command {// bytebase-action flagscmd.PersistentFlags().StringVar(&w.Output, "output", "", "Output file location. The output file is a JSON file with the created resource names")cmd.PersistentFlags().StringVar(&w.URL, "url", "https://demo.bytebase.com", "Bytebase URL")+ cmd.PersistentFlags().DurationVar(&w.Timeout, "timeout", 120*time.Second, "HTTP timeout for API requests (e.g. 120s, 5m)")cmd.PersistentFlags().StringVar(&w.ServiceAccount, "service-account", "", "Bytebase Service account")cmd.PersistentFlags().StringVar(&w.ServiceAccountSecret, "service-account-secret", "", "Bytebase Service account secret")cmd.PersistentFlags().StringVar(&w.AccessToken, "access-token", "", "Bytebase access token (alternative to service account auth, e.g. from workload identity exchange)")@@ -56,10 +58,15 @@ func rootPreRun(w *world.World) func(cmd *cobra.Command, args []string) error {// NewClientFromWorld creates a Client using the authentication method configured in World.func NewClientFromWorld(w *world.World) (*Client, error) {+ clientOptions := DefaultClientOptions()+ if w.Timeout > 0 {+ clientOptions.Timeout = w.Timeout+ }+if w.AccessToken != "" {- return NewClientWithAccessToken(w.URL, w.AccessToken)+ return createClient(w.URL, w.AccessToken, "", "", clientOptions)}- return NewClient(w.URL, w.ServiceAccount, w.ServiceAccountSecret)+ return NewClientWithOptions(w.URL, w.ServiceAccount, w.ServiceAccountSecret, clientOptions)}func CheckVersionCompatibility(w *world.World, client *Client, cliVersion string) {diff --git a/action/world/world.go b/action/world/world.goindex c5ca9a97c4..fd7f82404a 100644--- a/action/world/world.go+++ b/action/world/world.go@@ -19,6 +19,7 @@ type World struct {// bytebase-action flagsOutput stringURL string+ Timeout time.DurationServiceAccount stringServiceAccountSecret stringAccessToken string // Alternative to service account auth, e.g. from workload identity exchange