From 85af942e6369636119b762017d1aec1330e999bb Mon Sep 17 00:00:00 2001 From: Jose Antonio Insua Date: Wed, 25 Feb 2026 17:20:22 +0100 Subject: [PATCH] Make Config.Timeout functional and expose as --timeout flag The Timeout field existed in Config but was never used. httpClient() hardcoded 30 * time.Second. Now httpClient() reads from i.Timeout, and a new --timeout persistent flag (default 30s) is exposed on the root command. Also configurable via IMS_TIMEOUT env var or config file. --- cmd/root.go | 1 + ims/client.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 6915d52..ea2cc4d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -44,6 +44,7 @@ func RootCmd(version string) *cobra.Command { cmd.PersistentFlags().BoolVarP(&imsConfig.ProxyIgnoreTLS, "proxyIgnoreTLS", "T", false, "Ignore TLS certificate verification (only valid when connecting through a proxy).") cmd.PersistentFlags().StringVarP(&configFile, "configFile", "f", "", "Configuration file.") + cmd.PersistentFlags().IntVar(&imsConfig.Timeout, "timeout", 30, "HTTP client timeout in seconds.") cmd.AddCommand( authzCmd(imsConfig), diff --git a/ims/client.go b/ims/client.go index cf77d03..5ab17f8 100644 --- a/ims/client.go +++ b/ims/client.go @@ -22,13 +22,13 @@ func (i Config) httpClient() (*http.Client, error) { t.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} } client := &http.Client{ - Timeout: 30 * time.Second, + Timeout: time.Duration(i.Timeout) * time.Second, Transport: t, } return client, nil } client := &http.Client{ - Timeout: 30 * time.Second, + Timeout: time.Duration(i.Timeout) * time.Second, } return client, nil }