mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
Pass SUBNET URL to console (#18503)
When minio runs with MINIO_CI_CD=on, it is expected to communicate with the locally running SUBNET. This is happening in the case of MinIO via call home functionality. However, the subnet-related functionality inside the console continues to talk to the SUBNET production URL. Because of this, the console cannot be tested with a locally running SUBNET. Set the env variable CONSOLE_SUBNET_URL correctly in such cases. (The console already has code to use the value of this variable as the subnet URL)
This commit is contained in:
@@ -29,6 +29,11 @@ import (
|
||||
xnet "github.com/minio/pkg/v2/net"
|
||||
)
|
||||
|
||||
const (
|
||||
baseURL = "https://subnet.min.io"
|
||||
baseURLDev = "http://localhost:9000"
|
||||
)
|
||||
|
||||
// DefaultKVS - default KV config for subnet settings
|
||||
var DefaultKVS = config.KVS{
|
||||
config.KV{
|
||||
@@ -58,6 +63,9 @@ type Config struct {
|
||||
|
||||
// Transport configured with proxy_url if set optionally.
|
||||
transport http.RoundTripper
|
||||
|
||||
// The subnet base URL
|
||||
BaseURL string
|
||||
}
|
||||
|
||||
var configLock sync.RWMutex
|
||||
@@ -84,10 +92,11 @@ func (c *Config) ApplyEnv() {
|
||||
if c.Proxy != "" {
|
||||
os.Setenv("CONSOLE_SUBNET_PROXY", c.Proxy)
|
||||
}
|
||||
os.Setenv("CONSOLE_SUBNET_URL", c.BaseURL)
|
||||
}
|
||||
|
||||
// Update - in-place update with new license and registration information.
|
||||
func (c *Config) Update(ncfg Config) {
|
||||
func (c *Config) Update(ncfg Config, isDevEnv bool) {
|
||||
configLock.Lock()
|
||||
defer configLock.Unlock()
|
||||
|
||||
@@ -95,6 +104,14 @@ func (c *Config) Update(ncfg Config) {
|
||||
c.APIKey = ncfg.APIKey
|
||||
c.Proxy = ncfg.Proxy
|
||||
c.transport = ncfg.transport
|
||||
c.BaseURL = baseURL
|
||||
|
||||
if isDevEnv {
|
||||
c.BaseURL = os.Getenv("_MINIO_SUBNET_URL")
|
||||
if c.BaseURL == "" {
|
||||
c.BaseURL = baseURLDev
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LookupConfig - lookup config and override with valid environment settings if any.
|
||||
|
||||
Reference in New Issue
Block a user