Add subnet proxy config (#14225)

Will store the HTTP(S) proxy URL to use for connecting to SUBNET.
This commit is contained in:
Shireesh Anjal 2022-02-01 23:22:38 +05:30 committed by GitHub
parent 77b780b8ca
commit 3882da6ac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 0 deletions

View File

@ -213,6 +213,9 @@ func minioConfigToConsoleFeatures() {
if globalSubnetConfig.APIKey != "" {
os.Setenv("CONSOLE_SUBNET_API_KEY", globalSubnetConfig.APIKey)
}
if globalSubnetConfig.Proxy != "" {
os.Setenv("CONSOLE_SUBNET_PROXY", globalSubnetConfig.Proxy)
}
}
func initConsoleServer() (*restapi.Server, error) {

View File

@ -361,6 +361,10 @@ func validateConfig(s config.Config) error {
return err
}
if _, err = subnet.LookupConfig(s[config.SubnetSubSys][config.Default]); err != nil {
return err
}
return notify.TestNotificationTargets(GlobalContext, s, NewGatewayHTTPTransport(), globalNotificationSys.ConfiguredTargetIDs())
}

View File

@ -62,6 +62,7 @@ const (
SecretKey = "secret_key"
License = "license" // Deprecated Dec 2021
APIKey = "api_key"
Proxy = "proxy"
)
// Top level config constants.

View File

@ -55,6 +55,7 @@ const (
EnvMinIOSubnetLicense = "MINIO_SUBNET_LICENSE" // Deprecated Dec 2021
EnvMinIOSubnetAPIKey = "MINIO_SUBNET_API_KEY"
EnvMinIOSubnetProxy = "MINIO_SUBNET_PROXY"
EnvMinIOServerURL = "MINIO_SERVER_URL"
EnvMinIOBrowserRedirectURL = "MINIO_BROWSER_REDIRECT_URL"
EnvRootDiskThresholdSize = "MINIO_ROOTDISK_THRESHOLD_SIZE"

View File

@ -18,6 +18,8 @@
package subnet
import (
"net/url"
"github.com/minio/minio/internal/config"
"github.com/minio/pkg/env"
)
@ -33,6 +35,10 @@ var (
Key: config.APIKey,
Value: "",
},
config.KV{
Key: config.Proxy,
Value: "",
},
}
// HelpSubnet - provides help for subnet api key config
@ -49,6 +55,12 @@ var (
Description: "Subnet api key for the cluster",
Optional: true,
},
config.HelpKV{
Key: config.Proxy,
Type: "string",
Description: "HTTP(S) proxy URL to use for connecting to SUBNET",
Optional: true,
},
}
)
@ -59,6 +71,9 @@ type Config struct {
// The subnet api key
APIKey string `json:"api_key"`
// The HTTP(S) proxy URL to use for connecting to SUBNET
Proxy string `json:"proxy"`
}
// LookupConfig - lookup config and override with valid environment settings if any.
@ -67,6 +82,12 @@ func LookupConfig(kvs config.KVS) (cfg Config, err error) {
return cfg, err
}
cfg.Proxy = env.Get(config.EnvMinIOSubnetProxy, kvs.Get(config.Proxy))
_, err = url.Parse(cfg.Proxy)
if err != nil {
return cfg, err
}
cfg.License = env.Get(config.EnvMinIOSubnetLicense, kvs.Get(config.License))
cfg.APIKey = env.Get(config.EnvMinIOSubnetAPIKey, kvs.Get(config.APIKey))