Skip to content

Commit

Permalink
Add support for using an http-proxy with tunnel-api (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontleon authored Feb 23, 2022
1 parent 41f24cd commit 360242c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
13 changes: 12 additions & 1 deletion cmd/tunnel-api/tunnel-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 360242c

Please sign in to comment.