From ae7c7d4eec106ea5b66963f81c526b71a02f86c5 Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Wed, 9 Jun 2021 18:31:06 +0530 Subject: [PATCH] add configurable timeout cli flag --- cmd/helmpush/main.go | 3 +++ pkg/chartmuseum/client.go | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/helmpush/main.go b/cmd/helmpush/main.go index 1864180..51f4eb8 100644 --- a/cmd/helmpush/main.go +++ b/cmd/helmpush/main.go @@ -50,6 +50,7 @@ type ( keyring string dependencyUpdate bool out io.Writer + timeout int64 } config struct { @@ -125,6 +126,7 @@ func newPushCmd(args []string) *cobra.Command { f.BoolVarP(&p.forceUpload, "force", "f", false, "Force upload even if chart version exists") f.BoolVarP(&p.dependencyUpdate, "dependency-update", "d", false, `update dependencies from "requirements.yaml" to dir "charts/" before packaging`) f.BoolVarP(&p.checkHelmVersion, "check-helm-version", "", false, `outputs either "2" or "3" indicating the current Helm major version`) + f.Int64VarP(&p.timeout, "timeout", "t", 30, "The duration (in seconds) Helm will wait to get response from chartmuseum") f.Parse(args) @@ -303,6 +305,7 @@ func (p *pushCmd) push() error { cm.CertFile(p.certFile), cm.KeyFile(p.keyFile), cm.InsecureSkipVerify(p.insecureSkipVerify), + cm.Timeout(p.timeout), ) if err != nil { diff --git a/pkg/chartmuseum/client.go b/pkg/chartmuseum/client.go index 0aeb2fc..606b524 100644 --- a/pkg/chartmuseum/client.go +++ b/pkg/chartmuseum/client.go @@ -27,7 +27,6 @@ func (client *Client) Option(opts ...Option) *Client { func NewClient(opts ...Option) (*Client, error) { var client Client client.Client = &http.Client{} - client.Option(Timeout(30)) client.Option(opts...) client.Timeout = client.opts.timeout