Try to use Application Default Credentials when GCS is enabled but GCS key is not provided

This commit is contained in:
DarthSim
2019-09-30 19:10:55 +06:00
parent 219d0f8d78
commit ed41919be2
4 changed files with 27 additions and 4 deletions

View File

@@ -176,6 +176,7 @@ type config struct {
S3Enabled bool
S3Region string
S3Endpoint string
GCSEnabled bool
GCSKey string
ETagEnabled bool
@@ -307,6 +308,7 @@ func configure() {
strEnvConfig(&conf.S3Region, "IMGPROXY_S3_REGION")
strEnvConfig(&conf.S3Endpoint, "IMGPROXY_S3_ENDPOINT")
boolEnvConfig(&conf.GCSEnabled, "IMGPROXY_USE_GCS")
strEnvConfig(&conf.GCSKey, "IMGPROXY_GCS_KEY")
boolEnvConfig(&conf.ETagEnabled, "IMGPROXY_USE_ETAG")
@@ -447,6 +449,11 @@ func configure() {
}
}
if _, ok := os.LookupEnv("IMGPROXY_USE_GCS"); !ok && len(conf.GCSKey) > 0 {
logWarning("Set IMGPROXY_USE_GCS to true since it may be required by future versions to enable GCS support")
conf.GCSEnabled = true
}
if err := checkPresets(conf.Presets); err != nil {
logFatal(err.Error())
}