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

Golang dependency.NewClientSet函数代码示例

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

本文整理汇总了Golang中github.com/hashicorp/consul-template/dependency.NewClientSet函数的典型用法代码示例。如果您正苦于以下问题:Golang NewClientSet函数的具体用法?Golang NewClientSet怎么用?Golang NewClientSet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewClientSet函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: newClientSet

// newClientSet creates a new client set from the given config.
func newClientSet(config *Config) (*dep.ClientSet, error) {
	clients := dep.NewClientSet()

	if err := clients.CreateConsulClient(&dep.CreateConsulClientInput{
		Address:      config.Consul,
		Token:        config.Token,
		AuthEnabled:  config.Auth.Enabled,
		AuthUsername: config.Auth.Username,
		AuthPassword: config.Auth.Password,
		SSLEnabled:   config.SSL.Enabled,
		SSLVerify:    config.SSL.Verify,
		SSLCert:      config.SSL.Cert,
		SSLKey:       config.SSL.Key,
		SSLCACert:    config.SSL.CaCert,
	}); err != nil {
		return nil, fmt.Errorf("runner: %s", err)
	}

	if err := clients.CreateVaultClient(&dep.CreateVaultClientInput{
		Address:    config.Vault.Address,
		Token:      config.Vault.Token,
		SSLEnabled: config.Vault.SSL.Enabled,
		SSLVerify:  config.Vault.SSL.Verify,
		SSLCert:    config.Vault.SSL.Cert,
		SSLKey:     config.Vault.SSL.Key,
		SSLCACert:  config.Vault.SSL.CaCert,
	}); err != nil {
		return nil, fmt.Errorf("runner: %s", err)
	}

	return clients, nil
}
开发者ID:yuanfeng0905,项目名称:consul-template,代码行数:33,代码来源:runner.go


示例2: newWatcher

// newWatcher creates a new watcher.
func newWatcher(config *Config, client *api.Client, once bool) (*watch.Watcher, error) {
	log.Printf("[INFO] (runner) creating Watcher")

	clients := dep.NewClientSet()
	if err := clients.CreateConsulClient(&dep.CreateConsulClientInput{
		Address:      config.Consul,
		Token:        config.Token,
		AuthEnabled:  config.Auth.Enabled,
		AuthUsername: config.Auth.Username,
		AuthPassword: config.Auth.Password,
		SSLEnabled:   config.SSL.Enabled,
		SSLVerify:    config.SSL.Verify,
	}); err != nil {
		return nil, err
	}

	watcher, err := watch.NewWatcher(&watch.WatcherConfig{
		Clients:  clients,
		Once:     once,
		MaxStale: config.MaxStale,
		RetryFunc: func(current time.Duration) time.Duration {
			return config.Retry
		},
	})
	if err != nil {
		return nil, err
	}

	return watcher, err
}
开发者ID:kjniemi,项目名称:consul-replicate,代码行数:31,代码来源:runner.go


示例3: TestNewWatcher_renewVault

func TestNewWatcher_renewVault(t *testing.T) {
	clients := dep.NewClientSet()

	w, err := NewWatcher(&WatcherConfig{
		Clients:    clients,
		Once:       true,
		RenewVault: true,
	})
	if err != nil {
		t.Fatal(err)
	}
	defer w.Stop()

	if !w.Watching(&dep.VaultToken{}) {
		t.Errorf("expected watcher to be renewing vault token")
	}
}
开发者ID:xytis,项目名称:consul-template,代码行数:17,代码来源:watcher_test.go


示例4: newWatcher

// newWatcher creates a new watcher.
func newWatcher(config *JsonExport, client *api.Client, once bool) (*watch.Watcher, error) {
	log.Println("[INFO] (runner) creating Watcher")

	clientSet := dep.NewClientSet()
	if err := clientSet.Add(client); err != nil {
		return nil, err
	}

	watcher, err := watch.NewWatcher(&watch.WatcherConfig{
		Clients: clientSet,
		Once:    once,
	})
	if err != nil {
		return nil, err
	}

	return watcher, err
}
开发者ID:bhourigan,项目名称:jsonconsul,代码行数:19,代码来源:export_watch.go


示例5: TestNewWatcher_values

func TestNewWatcher_values(t *testing.T) {
	clients := dep.NewClientSet()

	w, err := NewWatcher(&WatcherConfig{
		Clients: clients,
		Once:    true,
	})
	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(w.config.Clients, clients) {
		t.Errorf("expected %#v to be %#v", w.config.Clients, clients)
	}

	if w.config.Once != true {
		t.Errorf("expected w.config.Once to be true")
	}
}
开发者ID:xytis,项目名称:consul-template,代码行数:19,代码来源:watcher_test.go


示例6: newClientSet

// newClientSet creates a new client set from the given config.
func newClientSet(config *Config) (*dep.ClientSet, error) {
	clients := dep.NewClientSet()

	consul, err := newConsulClient(config)
	if err != nil {
		return nil, err
	}
	if err := clients.Add(consul); err != nil {
		return nil, err
	}

	vault, err := newVaultClient(config)
	if err != nil {
		return nil, err
	}
	if err := clients.Add(vault); err != nil {
		return nil, err
	}

	return clients, nil
}
开发者ID:timopek,项目名称:consul-template,代码行数:22,代码来源:runner.go


示例7: newWatcher

// newWatcher creates a new watcher.
func newWatcher(config *Config, client *api.Client, once bool) (*watch.Watcher, error) {
	log.Printf("[INFO] (runner) creating Watcher")

	clientSet := dep.NewClientSet()
	if err := clientSet.Add(client); err != nil {
		return nil, err
	}

	watcher, err := watch.NewWatcher(&watch.WatcherConfig{
		Clients:  clientSet,
		Once:     once,
		MaxStale: config.MaxStale,
		RetryFunc: func(current time.Duration) time.Duration {
			return config.Retry
		},
	})
	if err != nil {
		return nil, err
	}

	return watcher, err
}
开发者ID:mdelagrange,项目名称:envconsul,代码行数:23,代码来源:runner.go


示例8: newClientSet

// newClientSet creates a new client set from the given config.
func newClientSet(c *config.Config) (*dep.ClientSet, error) {
	clients := dep.NewClientSet()

	if err := clients.CreateConsulClient(&dep.CreateConsulClientInput{
		Address:      config.StringVal(c.Consul.Address),
		Token:        config.StringVal(c.Consul.Token),
		AuthEnabled:  config.BoolVal(c.Consul.Auth.Enabled),
		AuthUsername: config.StringVal(c.Consul.Auth.Username),
		AuthPassword: config.StringVal(c.Consul.Auth.Password),
		SSLEnabled:   config.BoolVal(c.Consul.SSL.Enabled),
		SSLVerify:    config.BoolVal(c.Consul.SSL.Verify),
		SSLCert:      config.StringVal(c.Consul.SSL.Cert),
		SSLKey:       config.StringVal(c.Consul.SSL.Key),
		SSLCACert:    config.StringVal(c.Consul.SSL.CaCert),
		SSLCAPath:    config.StringVal(c.Consul.SSL.CaPath),
		ServerName:   config.StringVal(c.Consul.SSL.ServerName),
	}); err != nil {
		return nil, fmt.Errorf("runner: %s", err)
	}

	if err := clients.CreateVaultClient(&dep.CreateVaultClientInput{
		Address:     config.StringVal(c.Vault.Address),
		Token:       config.StringVal(c.Vault.Token),
		UnwrapToken: config.BoolVal(c.Vault.UnwrapToken),
		SSLEnabled:  config.BoolVal(c.Vault.SSL.Enabled),
		SSLVerify:   config.BoolVal(c.Vault.SSL.Verify),
		SSLCert:     config.StringVal(c.Vault.SSL.Cert),
		SSLKey:      config.StringVal(c.Vault.SSL.Key),
		SSLCACert:   config.StringVal(c.Vault.SSL.CaCert),
		SSLCAPath:   config.StringVal(c.Vault.SSL.CaPath),
		ServerName:  config.StringVal(c.Vault.SSL.ServerName),
	}); err != nil {
		return nil, fmt.Errorf("runner: %s", err)
	}

	return clients, nil
}
开发者ID:hashicorp,项目名称:envconsul,代码行数:38,代码来源:runner.go


示例9: TestNewWatcher_noConfig

package watch

import (
	"fmt"
	"reflect"
	"strings"
	"testing"
	"time"

	dep "github.com/hashicorp/consul-template/dependency"
)

var defaultWatcherConfig = &WatcherConfig{
	Clients:   dep.NewClientSet(),
	Once:      true,
	RetryFunc: func(time.Duration) time.Duration { return 0 },
}

func TestNewWatcher_noConfig(t *testing.T) {
	_, err := NewWatcher(nil)
	if err == nil {
		t.Fatal("expected error, but nothing was returned")
	}

	expected := "watcher: missing config"
	if !strings.Contains(err.Error(), expected) {
		t.Errorf("expected %q to contain %q", err.Error(), expected)
	}
}

func TestNewWatcher_defaultValues(t *testing.T) {
开发者ID:xytis,项目名称:consul-template,代码行数:31,代码来源:watcher_test.go



注:本文中的github.com/hashicorp/consul-template/dependency.NewClientSet函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang dependency.ParseCatalogNode函数代码示例发布时间:2022-05-23
下一篇:
Golang ec2.EC2类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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