mirror of
https://github.com/distribution/distribution.git
synced 2025-08-20 07:45:33 +00:00
* Make copy poll max retry, a global driver max retry * Get support for etags in Azure * Fix storage driver tests * Fix auth mess and update docs * Refactor Azure client and enable Azure storage tests We use Azurite for integration testing which requires TLS, so we had to figure out how to skip TLS verification when running tests locally: this required updating testsuites Driver and constructor due to TestRedirectURL sending GET and HEAD requests to remote storage which in this case is Azurite. Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
69 lines
1.9 KiB
Go
69 lines
1.9 KiB
Go
package azure
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/mitchellh/mapstructure"
|
|
)
|
|
|
|
const (
|
|
defaultRealm = "core.windows.net"
|
|
defaultMaxRetries = 5
|
|
defaultRetryDelay = "100ms"
|
|
)
|
|
|
|
type CredentialsType string
|
|
|
|
const (
|
|
CredentialsTypeClientSecret = "client_secret"
|
|
CredentialsTypeSharedKey = "shared_key"
|
|
CredentialsTypeDefault = "default_credentials"
|
|
)
|
|
|
|
type Credentials struct {
|
|
Type CredentialsType `mapstructure:"type"`
|
|
ClientID string `mapstructure:"clientid"`
|
|
TenantID string `mapstructure:"tenantid"`
|
|
Secret string `mapstructure:"secret"`
|
|
}
|
|
|
|
type DriverParameters struct {
|
|
Credentials Credentials `mapstructure:"credentials"`
|
|
Container string `mapstructure:"container"`
|
|
AccountName string `mapstructure:"accountname"`
|
|
AccountKey string `mapstructure:"accountkey"`
|
|
ConnectionString string `mapstructure:"connectionstring"`
|
|
Realm string `mapstructure:"realm"`
|
|
RootDirectory string `mapstructure:"rootdirectory"`
|
|
ServiceURL string `mapstructure:"serviceurl"`
|
|
MaxRetries int `mapstructure:"max_retries"`
|
|
RetryDelay string `mapstructure:"retry_delay"`
|
|
SkipVerify bool `mapstructure:"skipverify"`
|
|
}
|
|
|
|
func NewParameters(parameters map[string]interface{}) (*DriverParameters, error) {
|
|
params := DriverParameters{
|
|
Realm: defaultRealm,
|
|
}
|
|
if err := mapstructure.Decode(parameters, ¶ms); err != nil {
|
|
return nil, err
|
|
}
|
|
if params.AccountName == "" {
|
|
return nil, errors.New("no accountname parameter provided")
|
|
}
|
|
if params.Container == "" {
|
|
return nil, errors.New("no container parameter provider")
|
|
}
|
|
if params.ServiceURL == "" {
|
|
params.ServiceURL = fmt.Sprintf("https://%s.blob.%s", params.AccountName, params.Realm)
|
|
}
|
|
if params.MaxRetries == 0 {
|
|
params.MaxRetries = defaultMaxRetries
|
|
}
|
|
if params.RetryDelay == "" {
|
|
params.RetryDelay = defaultRetryDelay
|
|
}
|
|
return ¶ms, nil
|
|
}
|