Use subnet proxy from minio config if available (#3969)
minio now supports storing the proxy to be used for connecting to subnet in the `subnet proxy` config. So mc can use it if available when communicating with subnet during cluster registration or diagnostics upload.
This commit is contained in:
@@ -27,6 +27,7 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -240,6 +241,24 @@ func getSubnetAPIKeyFromConfig(alias string) string {
|
||||
return mcConfig().Aliases[alias].APIKey
|
||||
}
|
||||
|
||||
func setSubnetProxyFromConfig(alias string) error {
|
||||
if globalSubnetProxyURL != nil {
|
||||
// proxy already set via command line arg.
|
||||
return nil
|
||||
}
|
||||
|
||||
// get the subnet proxy config from MinIO if available
|
||||
supported, proxy := getSubnetKeyFromMinIOConfig(alias, "proxy")
|
||||
if supported {
|
||||
proxyURL, e := url.Parse(proxy)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
globalSubnetProxyURL = proxyURL
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getSubnetLicenseFromConfig(alias string) string {
|
||||
// get the subnet license config from MinIO if available
|
||||
supported, lic := getSubnetKeyFromMinIOConfig(alias, "license")
|
||||
@@ -414,6 +433,11 @@ func getSubnetAccID(headers map[string]string) (string, error) {
|
||||
|
||||
// registerClusterOnSubnet - Registers the given cluster on SUBNET
|
||||
func registerClusterOnSubnet(alias string, clusterRegInfo ClusterRegistrationInfo) (string, error) {
|
||||
e := setSubnetProxyFromConfig(alias)
|
||||
if e != nil {
|
||||
return "", e
|
||||
}
|
||||
|
||||
apiKey := getSubnetAPIKeyFromConfig(alias)
|
||||
|
||||
lic := ""
|
||||
|
||||
@@ -316,6 +316,11 @@ func prepareDiagUploadURL(alias string, clusterName string, filename string, lic
|
||||
}
|
||||
|
||||
func uploadDiagReport(alias string, filename string, reqURL string, headers map[string]string) error {
|
||||
e := setSubnetProxyFromConfig(alias)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
req, e := subnetUploadReq(reqURL, filename)
|
||||
if e != nil {
|
||||
return e
|
||||
|
||||
Reference in New Issue
Block a user