From 15b157018a736a38343ec5ae57e7884f0903b2d0 Mon Sep 17 00:00:00 2001 From: Marek Aufart Date: Mon, 8 Jan 2024 16:47:21 +0100 Subject: [PATCH] Add env vars defaults for http&https proxy Signed-off-by: Marek Aufart --- cmd/analyze.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/analyze.go b/cmd/analyze.go index bfb5a65..0375936 100644 --- a/cmd/analyze.go +++ b/cmd/analyze.go @@ -61,7 +61,8 @@ type analyzeCommand struct { rules []string jaegerEndpoint string enableDefaultRulesets bool - proxy string + httpProxy string + httpsProxy string noProxy string // tempDirs list of temporary dirs created, used for cleanup @@ -162,8 +163,9 @@ func NewAnalyzeCmd(log logr.Logger) *cobra.Command { analyzeCommand.Flags().BoolVar(&analyzeCmd.overwrite, "overwrite", false, "overwrite output directory") analyzeCommand.Flags().StringVar(&analyzeCmd.jaegerEndpoint, "jaeger-endpoint", "", "jaeger endpoint to collect traces") analyzeCommand.Flags().BoolVar(&analyzeCmd.enableDefaultRulesets, "enable-default-rulesets", true, "run default rulesets with analysis") - analyzeCommand.Flags().StringVar(&analyzeCmd.proxy, "proxy", "", "HTTP&HTTPS proxy string URL") - analyzeCommand.Flags().StringVar(&analyzeCmd.noProxy, "no-proxy", "", "proxy excluded URLs (relevant only with `proxy`)") + analyzeCommand.Flags().StringVar(&analyzeCmd.httpProxy, "http-proxy", os.Getenv("http_proxy"), "HTTP proxy string URL") + analyzeCommand.Flags().StringVar(&analyzeCmd.httpsProxy, "https-proxy", os.Getenv("https_proxy"), "HTTPS proxy string URL") + analyzeCommand.Flags().StringVar(&analyzeCmd.noProxy, "no-proxy", os.Getenv("no_proxy"), "proxy excluded URLs (relevant only with proxy)") return analyzeCommand } @@ -464,10 +466,10 @@ func (a *analyzeCommand) getConfigVolumes() (map[string]string, error) { } // Set proxy to providers - if a.proxy != "" { + if a.httpProxy != "" || a.httpsProxy != "" { proxy := provider.Proxy{ - HTTPProxy: a.proxy, - HTTPSProxy: a.proxy, + HTTPProxy: a.httpProxy, + HTTPSProxy: a.httpsProxy, NoProxy: a.noProxy, } for i := range provConfig {