- Much needed cleanup of 'config' handling code. - Adds a new CSVUnmarshal, unmarshalling to a struct from a csv file. Fixes #1422
42 lines
860 B
Go
42 lines
860 B
Go
package main
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
|
|
"github.com/minio/mc/pkg/client"
|
|
)
|
|
|
|
// isValidSecretKey - validate secret key
|
|
func isValidSecretKey(secretAccessKey string) bool {
|
|
if secretAccessKey == "" {
|
|
return true
|
|
}
|
|
regex := regexp.MustCompile("^.{40}$")
|
|
return regex.MatchString(secretAccessKey)
|
|
}
|
|
|
|
// isValidAccessKey - validate access key
|
|
func isValidAccessKey(accessKeyID string) bool {
|
|
if accessKeyID == "" {
|
|
return true
|
|
}
|
|
regex := regexp.MustCompile("^[A-Z0-9\\-\\.\\_\\~]{20}$")
|
|
return regex.MatchString(accessKeyID)
|
|
}
|
|
|
|
// isValidHostURL - validate input host url.
|
|
func isValidHostURL(hostURL string) bool {
|
|
if strings.TrimSpace(hostURL) == "" {
|
|
return false
|
|
}
|
|
url := client.NewURL(hostURL)
|
|
if url.Scheme != "https" && url.Scheme != "http" {
|
|
return false
|
|
}
|
|
if url.Path != "" && url.Path != "/" {
|
|
return false
|
|
}
|
|
return true
|
|
}
|