From 360242ccbdaa7159463cfb3373ac9abff6c5c4c9 Mon Sep 17 00:00:00 2001 From: Jason Montleon Date: Wed, 23 Feb 2022 16:35:47 -0500 Subject: [PATCH] Add support for using an http-proxy with tunnel-api (#73) --- cmd/tunnel-api/tunnel-api.go | 13 ++++++++++++- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cmd/tunnel-api/tunnel-api.go b/cmd/tunnel-api/tunnel-api.go index a02bad7..2d44943 100644 --- a/cmd/tunnel-api/tunnel-api.go +++ b/cmd/tunnel-api/tunnel-api.go @@ -24,7 +24,10 @@ type TunnelAPIOptions struct { Namespace string SourceImage string DestinationImage string - + ProxyHost string + ProxyPort string + ProxyUser string + ProxyPass string sourceContext *clientcmdapi.Context destinationContext *clientcmdapi.Context } @@ -65,6 +68,10 @@ func addFlagsForTunnelAPIOptions(t *TunnelAPIOptions, cmd *cobra.Command) { cmd.Flags().StringVar(&t.Namespace, "namespace", "", "The namespace of the pvc which is to be transferred, if empty it will try to use the openvpn namespace") cmd.Flags().StringVar(&t.SourceImage, "source-image", "", "The container image to use on the source cluster. Defaults to quay.io/konveyor/openvpn:latest") cmd.Flags().StringVar(&t.DestinationImage, "destination-image", "", "The container image to use on the destination cluster. Defaults to quay.io/konveyor/openvpn:latest") + cmd.Flags().StringVar(&t.ProxyHost, "proxy-host", "", "The hostname of an http-proxy to use on the source cluster for connecting to the destination cluster") + cmd.Flags().StringVar(&t.ProxyPort, "proxy-port", "", "The port the http-proxy is listening on. If no specified it will default to 3128") + cmd.Flags().StringVar(&t.ProxyUser, "proxy-user", "", "The username for the http-proxy. If specified you must also specify a password or it will be ignored.") + cmd.Flags().StringVar(&t.ProxyPass, "proxy-pass", "", "The password for the http-proxy. If specified you must also specify a username or it will be ignored.") } func (t *TunnelAPIOptions) Complete(c *cobra.Command, args []string) error { @@ -166,6 +173,10 @@ func (t *TunnelAPIOptions) run() error { tunnel.Options.Namespace = t.Namespace tunnel.Options.ClientImage = t.SourceImage tunnel.Options.ServerImage = t.DestinationImage + tunnel.Options.ProxyHost = t.ProxyHost + tunnel.Options.ProxyPort = t.ProxyPort + tunnel.Options.ProxyUser = t.ProxyUser + tunnel.Options.ProxyPass = t.ProxyPass err = tunnel_api.Openvpn(tunnel) if err != nil { diff --git a/go.mod b/go.mod index 515d32f..9e3e4ea 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.16 require ( github.com/ghodss/yaml v1.0.0 github.com/jarcoal/httpmock v1.0.8 - github.com/konveyor/crane-lib v0.0.5 + github.com/konveyor/crane-lib v0.0.6 github.com/mitchellh/mapstructure v1.4.1 github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5 github.com/openshift/api v0.0.0-20210625082935-ad54d363d274 diff --git a/go.sum b/go.sum index 3f562ee..3b4e658 100644 --- a/go.sum +++ b/go.sum @@ -461,8 +461,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konveyor/crane-lib v0.0.5 h1:qDpSvCJTy76lat1p03EuPW4EDsC+Yy3k/zhVzEJozEc= -github.com/konveyor/crane-lib v0.0.5/go.mod h1:C0H3dr85YlsaAt1Av7zFu4IPdwG4+SW7wEBFE+1udTw= +github.com/konveyor/crane-lib v0.0.6 h1:09lamezZq1L+//tEeVU1GDRDfoFJ2vLAMDM6Fc6AuR4= +github.com/konveyor/crane-lib v0.0.6/go.mod h1:C0H3dr85YlsaAt1Av7zFu4IPdwG4+SW7wEBFE+1udTw= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=