Merge "Allow remotedirect to ignore http*_proxy settings"
This commit is contained in:
commit
21c7c166ff
@ -226,4 +226,9 @@ type RemoteDirect struct {
|
|||||||
// Ignore SSL certificate check. This options is useful for remote APIs
|
// Ignore SSL certificate check. This options is useful for remote APIs
|
||||||
// with non-trusted or self-signed SSL certificates
|
// with non-trusted or self-signed SSL certificates
|
||||||
Insecure bool `json:"insecure,omitempty"`
|
Insecure bool `json:"insecure,omitempty"`
|
||||||
|
// Allow remotedirect requests to be proxied. This defaults to false
|
||||||
|
// because in general, most users will want to communicate directly
|
||||||
|
// with redfish and other bmc urls directly even if the environment
|
||||||
|
// has a proxy set
|
||||||
|
UseProxy bool `json:"useproxy,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ func NewRedfishRemoteDirectClient(ctx context.Context,
|
|||||||
ephNodeID string,
|
ephNodeID string,
|
||||||
isoPath string,
|
isoPath string,
|
||||||
insecure bool,
|
insecure bool,
|
||||||
|
useproxy bool,
|
||||||
) (RemoteDirect, error) {
|
) (RemoteDirect, error) {
|
||||||
if remoteURL == "" {
|
if remoteURL == "" {
|
||||||
return RemoteDirect{},
|
return RemoteDirect{},
|
||||||
@ -113,15 +114,25 @@ func NewRedfishRemoteDirectClient(ctx context.Context,
|
|||||||
UserAgent: "airshipctl/client",
|
UserAgent: "airshipctl/client",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// see https://github.com/golang/go/issues/26013
|
||||||
|
// We clone the default transport to ensure when we customize the transport
|
||||||
|
// that we are providing it sane timeouts and other defaults that we would
|
||||||
|
// normally get when not overriding the transport
|
||||||
|
defaultTransportCopy := (http.DefaultTransport.(*http.Transport))
|
||||||
|
transport := defaultTransportCopy.Clone()
|
||||||
|
|
||||||
if insecure {
|
if insecure {
|
||||||
cfg.HTTPClient = &http.Client{
|
transport.TLSClientConfig = &tls.Config{
|
||||||
Transport: &http.Transport{
|
|
||||||
TLSClientConfig: &tls.Config{
|
|
||||||
InsecureSkipVerify: true, //nolint:gosec
|
InsecureSkipVerify: true, //nolint:gosec
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !useproxy {
|
||||||
|
transport.Proxy = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg.HTTPClient = &http.Client{
|
||||||
|
Transport: transport,
|
||||||
|
}
|
||||||
|
|
||||||
var api redfishApi.RedfishAPI = redfishClient.NewAPIClient(cfg).DefaultApi
|
var api redfishApi.RedfishAPI = redfishClient.NewAPIClient(cfg).DefaultApi
|
||||||
|
|
||||||
|
@ -249,6 +249,7 @@ func TestNewRedfishRemoteDirectClient(t *testing.T) {
|
|||||||
computerSystemID,
|
computerSystemID,
|
||||||
"/tmp/test.iso",
|
"/tmp/test.iso",
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
@ -259,6 +260,7 @@ func TestNewRedfishRemoteDirectClient(t *testing.T) {
|
|||||||
computerSystemID,
|
computerSystemID,
|
||||||
"/tmp/test.iso",
|
"/tmp/test.iso",
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
expectedError := "missing configuration: redfish remote url empty"
|
expectedError := "missing configuration: redfish remote url empty"
|
||||||
assert.EqualError(t, err, expectedError)
|
assert.EqualError(t, err, expectedError)
|
||||||
@ -270,6 +272,7 @@ func TestNewRedfishRemoteDirectClient(t *testing.T) {
|
|||||||
"",
|
"",
|
||||||
"/tmp/test.iso",
|
"/tmp/test.iso",
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
expectedError = "missing configuration: redfish ephemeral node id empty"
|
expectedError = "missing configuration: redfish ephemeral node id empty"
|
||||||
assert.EqualError(t, err, expectedError)
|
assert.EqualError(t, err, expectedError)
|
||||||
@ -281,6 +284,7 @@ func TestNewRedfishRemoteDirectClient(t *testing.T) {
|
|||||||
computerSystemID,
|
computerSystemID,
|
||||||
"",
|
"",
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
expectedError = "missing configuration: redfish ephemeral node iso Path empty"
|
expectedError = "missing configuration: redfish ephemeral node iso Path empty"
|
||||||
assert.EqualError(t, err, expectedError)
|
assert.EqualError(t, err, expectedError)
|
||||||
@ -295,6 +299,7 @@ func getDefaultRedfishRemoteDirectObj(t *testing.T, api redfishAPI.RedfishAPI) R
|
|||||||
computerSystemID,
|
computerSystemID,
|
||||||
"/tmp/test.iso",
|
"/tmp/test.iso",
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -49,6 +49,7 @@ func getRemoteDirectClient(remoteConfig *config.RemoteDirect, remoteURL string)
|
|||||||
nodeID,
|
nodeID,
|
||||||
remoteConfig.IsoURL,
|
remoteConfig.IsoURL,
|
||||||
remoteConfig.Insecure,
|
remoteConfig.Insecure,
|
||||||
|
remoteConfig.UseProxy,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
alog.Debugf("redfish remotedirect client creation failed")
|
alog.Debugf("redfish remotedirect client creation failed")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user