Fix `validate` formatting for S3 plugin
@@ -33,7 +33,7 @@ func validSigVersion(v string) bool {
}
func parsePartSize(v string) int {
- re := regexp.MustCompile(`(?i)^(\d+)([mg])b?`)
+ re := regexp.MustCompile(`(?i)^(\d+)([mg])b?$`)
m := re.FindStringSubmatch(v)
if m == nil {
return -1
@@ -226,7 +226,6 @@ func (p S3Plugin) Validate(endpoint plugin.ShieldEndpoint) error {
fmt.Printf("@G{\u2713 s3_host} @C{%s}\n", s)
}
- //BEGIN AUTH VALIDATION
useInstanceProfiles, err := endpoint.BooleanValueDefault("use_instance_profile", DefaultUseInstanceProfiles)
if err != nil {
@@ -237,7 +236,7 @@ func (p S3Plugin) Validate(endpoint plugin.ShieldEndpoint) error {
} else {
fmt.Printf("@G{\u2713 use_instance_profile} @C{no}, AWS Instance Profiles will @Y{NOT} be used\n")
}
- //When using instance profiles, the key and secret are grabbed automatically.
+
if !useInstanceProfiles {
s, err = endpoint.StringValue("access_key_id")
if err != nil {
@@ -264,11 +263,12 @@ func (p S3Plugin) Validate(endpoint plugin.ShieldEndpoint) error {
if s3Host, err := endpoint.StringValueDefault("s3_host", ""); s != "" && err == nil && s3Host == "" {
fmt.Printf("@R{\u2717 s3_port %s but s3_host cannot be empty}\n", s)
fail = true
+ } else if s == "" {
+ fmt.Printf("@G{\u2713 s3_port} (autodetect)\n")
} else {
fmt.Printf("@G{\u2713 s3_port} @C{%s}\n", s)
}
}
- //END AUTH VALIDATION
s, err = endpoint.StringValue("bucket")
if err != nil {
