forked from minio/minio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move etcd, logger, crypto into their own packages (minio#8366)
- Deprecates _MINIO_PROFILER, `mc admin profile` does the job - Move ENVs to common location in cmd/config/
- Loading branch information
1 parent
bffc378
commit 290ad09
Showing
36 changed files
with
735 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import ( | |
"errors" | ||
"fmt" | ||
"reflect" | ||
"strings" | ||
"sync" | ||
|
||
"github.com/minio/minio/cmd/config" | ||
|
@@ -31,6 +32,7 @@ import ( | |
"github.com/minio/minio/cmd/crypto" | ||
xhttp "github.com/minio/minio/cmd/http" | ||
"github.com/minio/minio/cmd/logger" | ||
"github.com/minio/minio/cmd/logger/target/http" | ||
"github.com/minio/minio/pkg/auth" | ||
"github.com/minio/minio/pkg/env" | ||
"github.com/minio/minio/pkg/event" | ||
|
@@ -111,7 +113,7 @@ func (s *serverConfig) GetCredential() auth.Credentials { | |
// SetWorm set if worm is enabled. | ||
func (s *serverConfig) SetWorm(b bool) { | ||
// Set the new value. | ||
s.Worm = BoolFlag(b) | ||
s.Worm = config.BoolFlag(b) | ||
} | ||
|
||
// GetStorageClass reads storage class fields from current config. | ||
|
@@ -271,16 +273,27 @@ func (s *serverConfig) lookupConfigs() { | |
globalCacheMaxUse = s.Cache.MaxUse | ||
|
||
if cacheEncKey := env.Get(cache.EnvCacheEncryptionMasterKey, ""); cacheEncKey != "" { | ||
globalCacheKMSKeyID, globalCacheKMS, err = parseKMSMasterKey(cacheEncKey) | ||
globalCacheKMS, err = crypto.ParseMasterKey(cacheEncKey) | ||
if err != nil { | ||
logger.FatalIf(config.ErrInvalidCacheEncryptionKey(err), | ||
"Unable to setup encryption cache") | ||
} | ||
} | ||
} | ||
|
||
if err = LookupKMSConfig(s.KMS); err != nil { | ||
logger.FatalIf(err, "Unable to setup KMS") | ||
s.KMS, err = crypto.LookupConfig(s.KMS) | ||
if err != nil { | ||
logger.FatalIf(err, "Unable to setup KMS config") | ||
} | ||
|
||
GlobalKMS, err = crypto.NewKMS(s.KMS) | ||
if err != nil { | ||
logger.FatalIf(err, "Unable to setup KMS with current KMS config") | ||
} | ||
|
||
globalAutoEncryption = strings.EqualFold(env.Get(crypto.EnvAutoEncryption, "off"), "on") | ||
if globalAutoEncryption && GlobalKMS == nil { | ||
logger.FatalIf(errors.New("Invalid KMS configuration: auto-encryption is enabled but no valid KMS configuration is present"), "") | ||
} | ||
|
||
s.Compression, err = compress.LookupConfig(s.Compression) | ||
|
@@ -311,6 +324,34 @@ func (s *serverConfig) lookupConfigs() { | |
if err != nil { | ||
logger.FatalIf(err, "Unable to parse LDAP configuration from env") | ||
} | ||
|
||
// Load logger targets based on user's configuration | ||
loggerUserAgent := getUserAgent(getMinioMode()) | ||
|
||
s.Logger, err = logger.LookupConfig(s.Logger) | ||
if err != nil { | ||
logger.FatalIf(err, "Unable to initialize logger") | ||
} | ||
|
||
for _, l := range s.Logger.HTTP { | ||
if l.Enabled { | ||
// Enable http logging | ||
logger.AddTarget(http.New(l.Endpoint, loggerUserAgent, NewCustomHTTPTransport())) | ||
} | ||
} | ||
|
||
for _, l := range s.Logger.Audit { | ||
if l.Enabled { | ||
// Enable http audit logging | ||
logger.AddAuditTarget(http.New(l.Endpoint, loggerUserAgent, NewCustomHTTPTransport())) | ||
} | ||
} | ||
|
||
if s.Logger.Console.Enabled { | ||
// Enable console logging | ||
logger.AddTarget(globalConsoleSys.Console()) | ||
} | ||
|
||
} | ||
|
||
// TestNotificationTargets tries to establish connections to all notification | ||
|
@@ -531,8 +572,8 @@ func newServerConfig() *serverConfig { | |
// Console logging is on by default | ||
srvCfg.Logger.Console.Enabled = true | ||
// Create an example of HTTP logger | ||
srvCfg.Logger.HTTP = make(map[string]loggerHTTP) | ||
srvCfg.Logger.HTTP["target1"] = loggerHTTP{Endpoint: "https://username:[email protected]/api"} | ||
srvCfg.Logger.HTTP = make(map[string]logger.HTTP) | ||
srvCfg.Logger.HTTP["target1"] = logger.HTTP{Endpoint: "https://username:[email protected]/api"} | ||
|
||
return srvCfg | ||
} | ||
|
Oops, something went wrong.