Files
mc/config-utils.go
T
Harshavardhana 7355eecf56 config/csv: Add config import command for importing csv credential files.
- Much needed cleanup of 'config' handling code.
- Adds a new CSVUnmarshal, unmarshalling to a struct from a csv file.

Fixes #1422
2015-11-21 11:42:14 -08:00

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
}