Skip to content

Commit

Permalink
Add support for BOSH_ALL_PROXY env var
Browse files Browse the repository at this point in the history
  • Loading branch information
sneal committed Oct 29, 2024
1 parent f7131c1 commit 82866ed
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 645 deletions.
21 changes: 8 additions & 13 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ import (
"strings"
"time"

boshhttp "github.com/cloudfoundry/bosh-utils/httpclient"
"golang.org/x/net/context"
"golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials"
)

//Client used to communicate with BOSH
// Client used to communicate with BOSH
type Client struct {
config Config
Endpoint Endpoint
}

//Config is used to configure the creation of a client
// Config is used to configure the creation of a client
type Config struct {
BOSHAddress string
Username string
Expand Down Expand Up @@ -50,10 +51,10 @@ type request struct {
obj interface{}
}

//DefaultConfig configuration for client
// DefaultConfig configuration for client
func DefaultConfig() *Config {
return &Config{
BOSHAddress: "https://192.168.50.4:25555",
BOSHAddress: "https://192.168.50.4:25555", // bosh-lite default IP:PORT
Username: "admin",
Password: "admin",
HttpClient: http.DefaultClient,
Expand Down Expand Up @@ -84,21 +85,15 @@ func NewClient(config *Config) (*Client, error) {
config.Password = defConfig.Password
}

//Save the configured HTTP Client timeout for later
// Save the configured HTTP Client timeout for later
var timeout time.Duration
if config.HttpClient != nil {
timeout = config.HttpClient.Timeout
}

// Skip TLS cert validation and respect BOSH_ALL_PROXY env var
config.HttpClient = boshhttp.CreateDefaultClientInsecureSkipVerify()
endpoint := &Endpoint{}
config.HttpClient = &http.Client{
Timeout: timeout,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: config.SkipSslValidation,
},
},
}

authType, err := getAuthType(config.BOSHAddress, config.HttpClient)
if err != nil {
Expand Down
29 changes: 20 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
module github.com/cloudfoundry-community/gogobosh

go 1.17
go 1.22.0

toolchain go1.23.2

require (
github.com/cloudfoundry/bosh-utils v0.0.500
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab
github.com/martini-contrib/render v0.0.0-20150707142108-ec18f8345a11
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.27.1
golang.org/x/net v0.7.0
github.com/onsi/gomega v1.34.1
golang.org/x/net v0.30.0
golang.org/x/oauth2 v0.5.0
)

require (
code.cloudfoundry.org/tlsconfig v0.7.0 // indirect
github.com/cloudfoundry/go-socks5 v0.0.0-20240831012420-2590b55236ee // indirect
github.com/cloudfoundry/socks5-proxy v0.2.127 // indirect
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
github.com/pivotal-cf/paraphernalia v0.0.0-20180203224945-a64ae2051c20 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 82866ed

Please sign in to comment.