本文整理汇总了Golang中github.com/starkandwayne/shield/plugin.ShieldEndpoint类的典型用法代码示例。如果您正苦于以下问题:Golang ShieldEndpoint类的具体用法?Golang ShieldEndpoint怎么用?Golang ShieldEndpoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ShieldEndpoint类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getRedisEndpoint
func getRedisEndpoint(endpoint plugin.ShieldEndpoint) (RedisEndpoint, error) {
mode, err := endpoint.StringValue("redis_type")
if err != nil {
return RedisEndpoint{}, err
}
return RedisEndpoint{Mode: mode}, nil
}
开发者ID:yacloud-io,项目名称:shield,代码行数:7,代码来源:plugin.go
示例2: Restore
// Called when you want to restore data Examine the ShieldEndpoint passed in, and perform actions accordingly
func (p DummyPlugin) Restore(endpoint plugin.ShieldEndpoint) error {
file, err := endpoint.StringValue("file")
if err != nil {
return err
}
return plugin.Exec(fmt.Sprintf("/bin/sh -c \"/bin/cat > %s\"", file), plugin.STDIN)
}
开发者ID:starkandwayne,项目名称:shield,代码行数:9,代码来源:dummy.go
示例3: Backup
// Called when you want to back data up. Examine the ShieldEndpoint passed in, and perform actions accordingly
func (p DummyPlugin) Backup(endpoint plugin.ShieldEndpoint) error {
data, err := endpoint.StringValue("data")
if err != nil {
return err
}
return plugin.Exec(fmt.Sprintf("/bin/echo %s", data), plugin.STDOUT)
}
开发者ID:starkandwayne,项目名称:shield,代码行数:9,代码来源:dummy.go
示例4: Retrieve
// Called when you want to retreive backup data. Examine the ShieldEndpoint passed in, and perform actions accordingly
func (p DummyPlugin) Retrieve(endpoint plugin.ShieldEndpoint, file string) error {
directory, err := endpoint.StringValue("directory")
if err != nil {
return err
}
return plugin.Exec(fmt.Sprintf("/bin/cat %s/%s", directory, file), plugin.STDOUT)
}
开发者ID:starkandwayne,项目名称:shield,代码行数:9,代码来源:dummy.go
示例5: Store
// Called when you want to store backup data. Examine the ShieldEndpoint passed in, and perform actions accordingly
func (p DummyPlugin) Store(endpoint plugin.ShieldEndpoint) (string, error) {
directory, err := endpoint.StringValue("directory")
if err != nil {
return "", err
}
file := plugin.GenUUID()
err = plugin.Exec(fmt.Sprintf("/bin/sh -c \"/bin/cat > %s/%s\"", directory, file), plugin.STDIN)
return file, err
}
开发者ID:starkandwayne,项目名称:shield,代码行数:12,代码来源:dummy.go
示例6: getFSConfig
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
}
开发者ID:yacloud-io,项目名称:shield,代码行数:28,代码来源:plugin.go
示例7: getRabbitMQEndpoint
func getRabbitMQEndpoint(endpoint plugin.ShieldEndpoint) (RabbitMQEndpoint, error) {
url, err := endpoint.StringValue("rmq_url")
if err != nil {
return RabbitMQEndpoint{}, err
}
user, err := endpoint.StringValue("rmq_username")
if err != nil {
return RabbitMQEndpoint{}, err
}
passwd, err := endpoint.StringValue("rmq_password")
if err != nil {
return RabbitMQEndpoint{}, err
}
sslValidate, err := endpoint.BooleanValue("skip_ssl_validation")
if err != nil {
return RabbitMQEndpoint{}, err
}
return RabbitMQEndpoint{
Username: user,
Password: passwd,
URL: url,
SkipSSLValidation: sslValidate,
}, nil
}
开发者ID:yacloud-io,项目名称:shield,代码行数:28,代码来源:plugin.go
示例8: Validate
func (p RedisBrokerPlugin) Validate(endpoint plugin.ShieldEndpoint) error {
var (
s string
err error
fail bool
)
s, err = endpoint.StringValue("redis_type")
if err != nil {
ansi.Printf("@R{\u2717 redis_type %s}\n", err)
fail = true
} else {
ansi.Printf("@G{\u2713 redis_type} @C{%s}\n", s)
}
if fail {
return fmt.Errorf("postgres: invalid configuration")
}
return nil
}
开发者ID:yacloud-io,项目名称:shield,代码行数:20,代码来源:plugin.go
示例9: Validate
// Called to validate endpoints from the command line
func (p DummyPlugin) Validate(endpoint plugin.ShieldEndpoint) error {
var (
s string
err error
fail bool
)
s, err = endpoint.StringValue("data")
if err != nil {
ansi.Printf("@R{\u2717 data %s}\n", err)
fail = true
} else {
ansi.Printf("@G{\u2713 data} @C{%s}\n", s)
}
if fail {
return fmt.Errorf("dummy: invalid configuration")
}
return nil
}
开发者ID:starkandwayne,项目名称:shield,代码行数:21,代码来源:dummy.go
示例10: getS3ConnInfo
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
}
开发者ID:yacloud-io,项目名称:shield,代码行数:52,代码来源:plugin.go
示例11: getScalityConnInfo
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
}
开发者ID:starkandwayne,项目名称:shield,代码行数:46,代码来源:plugin.go
示例12:
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/starkandwayne/shield/plugin"
)
var _ = Describe("ShieldEndpoint", func() {
endpoint := plugin.ShieldEndpoint{
"stringVal": "asdf",
"intVal": 1234,
"floatVal": 1234.1234,
"boolVal": true,
"arrayVal": []interface{}{
"asdf",
"fdsa",
},
"mapVal": map[string]interface{}{
"key": "value",
},
}
Describe("ArrayVal", func() {
It("returns an array from the endpoint, when provided the right key", func() {
expected := []interface{}{"asdf", "fdsa"}
got, err := endpoint.ArrayValue("arrayVal")
Expect(got).Should(BeEquivalentTo(expected))
Expect(err).ShouldNot(HaveOccurred())
})
It("errors out when not pointed at an array", func() {
开发者ID:starkandwayne,项目名称:shield,代码行数:30,代码来源:endpoint_test.go
注:本文中的github.com/starkandwayne/shield/plugin.ShieldEndpoint类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论