func getScalityConnInfo(e plugin.ShieldEndpoint) (ScalityConnectionInfo, error) { host, err := e.StringValue("scality_host") if err != nil { return ScalityConnectionInfo{}, err } insecure_ssl, err := e.BooleanValueDefault("skip_ssl_validation", DefaultSkipSSLValidation) if err != nil { return ScalityConnectionInfo{}, err } key, err := e.StringValue("access_key_id") if err != nil { return ScalityConnectionInfo{}, err } secret, err := e.StringValue("secret_access_key") if err != nil { return ScalityConnectionInfo{}, err } bucket, err := e.StringValue("bucket") if err != nil { return ScalityConnectionInfo{}, err } prefix, err := e.StringValueDefault("prefix", DefaultPrefix) if err != nil { return ScalityConnectionInfo{}, err } proxy, err := e.StringValueDefault("socks5_proxy", "") if err != nil { return ScalityConnectionInfo{}, err } return ScalityConnectionInfo{ Host: host, SkipSSLValidation: insecure_ssl, AccessKey: key, SecretKey: secret, Bucket: bucket, PathPrefix: prefix, SOCKS5Proxy: proxy, }, nil }
func getS3ConnInfo(e plugin.ShieldEndpoint) (S3ConnectionInfo, error) { host, err := e.StringValueDefault("s3_host", DefaultS3Host) if err != nil { return S3ConnectionInfo{}, err } insecure_ssl, err := e.BooleanValueDefault("skip_ssl_validation", DefaultSkipSSLValidation) if err != nil { return S3ConnectionInfo{}, err } key, err := e.StringValue("access_key_id") if err != nil { return S3ConnectionInfo{}, err } secret, err := e.StringValue("secret_access_key") if err != nil { return S3ConnectionInfo{}, err } bucket, err := e.StringValue("bucket") if err != nil { return S3ConnectionInfo{}, err } prefix, err := e.StringValueDefault("prefix", DefaultPrefix) if err != nil { return S3ConnectionInfo{}, err } sigVer, err := e.StringValueDefault("signature_version", DefaultSigVersion) if !validSigVersion(sigVer) { return S3ConnectionInfo{}, fmt.Errorf("Invalid `signature_version` specified (`%s`). Expected `2` or `4`", sigVer) } proxy, err := e.StringValueDefault("socks5_proxy", "") if err != nil { return S3ConnectionInfo{}, err } return S3ConnectionInfo{ Host: host, SkipSSLValidation: insecure_ssl, AccessKey: key, SecretKey: secret, Bucket: bucket, PathPrefix: prefix, SignatureVersion: sigVer, SOCKS5Proxy: proxy, }, nil }
func getFSConfig(endpoint plugin.ShieldEndpoint) (*FSConfig, error) { include, err := endpoint.StringValueDefault("include", "") if err != nil { return nil, err } exclude, err := endpoint.StringValueDefault("exclude", "") if err != nil { return nil, err } bsdtar, err := endpoint.StringValueDefault("bsdtar", DefaultBsdTar) if err != nil { return nil, err } base_dir, err := endpoint.StringValue("base_dir") if err != nil { return nil, err } return &FSConfig{ Include: include, Exclude: exclude, BasePath: base_dir, BsdTar: bsdtar, }, nil }
func (p FSPlugin) Validate(endpoint plugin.ShieldEndpoint) error { var ( s string err error fail bool ) s, err = endpoint.StringValue("base_dir") if err != nil { ansi.Printf("@R{\u2717 base_dir %s}\n", err) fail = true } else { ansi.Printf("@G{\u2713 base_dir} files in @C{%s} will be backed up\n", s) } s, err = endpoint.StringValueDefault("include", "") if err != nil { ansi.Printf("@R{\u2717 include %s}\n", err) fail = true } else if s == "" { ansi.Printf("@G{\u2713 include} all files will be included\n") } else { ansi.Printf("@G{\u2713 include} only files matching @C{%s} will be backed up\n", s) } s, err = endpoint.StringValueDefault("exclude", "") if err != nil { ansi.Printf("@R{\u2717 base_dir %s}\n", err) fail = true } else if s == "" { ansi.Printf("@G{\u2713 exclude} no files will be excluded\n") } else { ansi.Printf("@G{\u2713 exclude} files matching @C{%s} will be skipped\n", s) } s, err = endpoint.StringValueDefault("bsdtar", "") if err != nil { ansi.Printf("@R{\u2717 bsdtar %s}\n", err) fail = true } else if s == "" { ansi.Printf("@G{\u2713 bsdtar} using default @C{%s}\n", DefaultBsdTar) } else { ansi.Printf("@G{\u2713 bsdtar} @C{%s}\n", s) } if fail { return fmt.Errorf("fs: invalid configuration") } return nil }
func (p S3Plugin) Validate(endpoint plugin.ShieldEndpoint) error { var ( s string err error fail bool ) s, err = endpoint.StringValueDefault("s3_host", DefaultS3Host) if err != nil { ansi.Printf("@R{\u2717 s3_host %s}\n", err) fail = true } else { ansi.Printf("@G{\u2713 s3_host} @C{%s}\n", s) } s, err = endpoint.StringValue("access_key_id") if err != nil { ansi.Printf("@R{\u2717 access_key_id %s}\n", err) fail = true } else { ansi.Printf("@G{\u2713 access_key_id} @C{%s}\n", s) } s, err = endpoint.StringValue("secret_access_key") if err != nil { ansi.Printf("@R{\u2717 secret_access_key %s}\n", err) fail = true } else { ansi.Printf("@G{\u2713 secret_access_key} @C{%s}\n", s) } s, err = endpoint.StringValue("bucket") if err != nil { ansi.Printf("@R{\u2717 bucket %s}\n", err) fail = true } else { ansi.Printf("@G{\u2713 bucket} @C{%s}\n", s) } s, err = endpoint.StringValueDefault("prefix", DefaultPrefix) if err != nil { ansi.Printf("@R{\u2717 prefix %s}\n", err) fail = true } else if s == "" { ansi.Printf("@G{\u2713 prefix} (none)\n") } else { ansi.Printf("@G{\u2713 prefix} @C{%s}\n", s) } s, err = endpoint.StringValueDefault("signature_version", DefaultSigVersion) if err != nil { ansi.Printf("@R{\u2717 signature_version %s}\n", err) fail = true } else if !validSigVersion(s) { ansi.Printf("@R{\u2717 signature_version Unexpected signature version '%s' found (expecting '2' or '4')}\n", s) fail = true } else { ansi.Printf("@G{\u2713 signature_version} @C{%s}\n", s) } s, err = endpoint.StringValueDefault("socks5_proxy", "") if err != nil { ansi.Printf("@R{\u2717 socks5_proxy %s}\n", err) fail = true } else if s == "" { ansi.Printf("@G{\u2713 socks5_proxy} (no proxy will be used)\n") } else { ansi.Printf("@G{\u2713 socks5_proxy} @C{%s}\n", s) } tf, err := endpoint.BooleanValueDefault("skip_ssl_validation", DefaultSkipSSLValidation) if err != nil { ansi.Printf("@R{\u2717 skip_ssl_validation %s}\n", err) fail = true } else if tf { ansi.Printf("@G{\u2713 skip_ssl_validation} @C{yes}, SSL will @Y{NOT} be validated\n") } else { ansi.Printf("@G{\u2713 skip_ssl_validation} @C{no}, SSL @Y{WILL} be validated\n") } if fail { return fmt.Errorf("s3: invalid configuration") } return nil }