• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang plugin.ShieldEndpoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang ui.UserInterface类代码示例发布时间:2022-05-28
下一篇:
Golang pg.NewPG函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap