Skip to content

Commit

Permalink
Add subnet proxy config (minio#14225)
Browse files Browse the repository at this point in the history
Will store the HTTP(S) proxy URL to use for connecting to SUBNET.
  • Loading branch information
anjalshireesh authored Feb 1, 2022
1 parent 77b780b commit 3882da6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/common-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions cmd/config-current.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const (
SecretKey = "secret_key"
License = "license" // Deprecated Dec 2021
APIKey = "api_key"
Proxy = "proxy"
)

// Top level config constants.
Expand Down
1 change: 1 addition & 0 deletions internal/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 21 additions & 0 deletions internal/config/subnet/api-key.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package subnet

import (
"net/url"

"github.com/minio/minio/internal/config"
"github.com/minio/pkg/env"
)
Expand All @@ -33,6 +35,10 @@ var (
Key: config.APIKey,
Value: "",
},
config.KV{
Key: config.Proxy,
Value: "",
},
}

// HelpSubnet - provides help for subnet api key config
Expand All @@ -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,
},
}
)

Expand All @@ -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.
Expand All @@ -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))

Expand Down

0 comments on commit 3882da6

Please sign in to comment.