mirror of
https://github.com/distribution/distribution.git
synced 2025-09-01 23:17:33 +00:00
registry: add loglevel support for aws s3 storage driver
based on the work from https://github.com/distribution/distribution/pull/3057. Co-authored-by: Simon Compston <compston@gmail.com> Signed-off-by: Flavian Missi <fmissi@redhat.com>
This commit is contained in:
@@ -117,6 +117,7 @@ type DriverParameters struct {
|
||||
SessionToken string
|
||||
UseDualStack bool
|
||||
Accelerate bool
|
||||
LogLevel aws.LogLevelType
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -461,11 +462,39 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
|
||||
fmt.Sprint(sessionToken),
|
||||
useDualStackBool,
|
||||
accelerateBool,
|
||||
getS3LogLevelFromParam(parameters["loglevel"]),
|
||||
}
|
||||
|
||||
return New(params)
|
||||
}
|
||||
|
||||
func getS3LogLevelFromParam(param interface{}) aws.LogLevelType {
|
||||
if param == nil {
|
||||
return aws.LogOff
|
||||
}
|
||||
logLevelParam := param.(string)
|
||||
var logLevel aws.LogLevelType
|
||||
switch strings.ToLower(logLevelParam) {
|
||||
case "off":
|
||||
logLevel = aws.LogOff
|
||||
case "debug":
|
||||
logLevel = aws.LogDebug
|
||||
case "debugwithsigning":
|
||||
logLevel = aws.LogDebugWithSigning
|
||||
case "debugwithhttpbody":
|
||||
logLevel = aws.LogDebugWithHTTPBody
|
||||
case "debugwithrequestretries":
|
||||
logLevel = aws.LogDebugWithRequestRetries
|
||||
case "debugwithrequesterrors":
|
||||
logLevel = aws.LogDebugWithRequestErrors
|
||||
case "debugwitheventstreambody":
|
||||
logLevel = aws.LogDebugWithEventStreamBody
|
||||
default:
|
||||
logLevel = aws.LogOff
|
||||
}
|
||||
return logLevel
|
||||
}
|
||||
|
||||
// getParameterAsInt64 converts parameters[name] to an int64 value (using
|
||||
// defaultt if nil), verifies it is no smaller than min, and returns it.
|
||||
func getParameterAsInt64(parameters map[string]interface{}, name string, defaultt int64, min int64, max int64) (int64, error) {
|
||||
@@ -504,7 +533,7 @@ func New(params DriverParameters) (*Driver, error) {
|
||||
return nil, fmt.Errorf("on Amazon S3 this storage driver can only be used with v4 authentication")
|
||||
}
|
||||
|
||||
awsConfig := aws.NewConfig()
|
||||
awsConfig := aws.NewConfig().WithLogLevel(params.LogLevel)
|
||||
|
||||
if params.AccessKey != "" && params.SecretKey != "" {
|
||||
creds := credentials.NewStaticCredentials(
|
||||
|
Reference in New Issue
Block a user