當前位置: 首頁>>代碼示例>>Golang>>正文


Golang config.NewWarning函數代碼示例

本文整理匯總了Golang中github.com/tsuru/config.NewWarning函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewWarning函數的具體用法?Golang NewWarning怎麽用?Golang NewWarning使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewWarning函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: checkPubSub

func checkPubSub() error {
	oldConfig, _ := config.GetString("redis-queue:host")
	if oldConfig != "" {
		return config.NewWarning(`Using "redis-queue:*" is deprecated. Please change your tsuru.conf to use "pubsub:*" options. See http://docs.tsuru.io/en/latest/reference/config.html#pubsub for more details.`)
	}
	redisHost, _ := config.GetString("pubsub:redis-host")
	if redisHost == "" {
		return config.NewWarning(`Config entry "pubsub:redis-host" is not set, default "localhost" will be used. Running "tsuru app-log -f" might not work.`)
	}
	return nil
}
開發者ID:zhenruyan,項目名稱:tsuru,代碼行數:11,代碼來源:checker.go

示例2: TestCheckPubSubOld

func (w *CheckerSuite) TestCheckPubSubOld(c *check.C) {
	config.Unset("pubsub:redis-host")
	config.Set("redis-queue:host", "localhost")
	err := checkPubSub()
	c.Assert(err, check.FitsTypeOf, config.NewWarning(""))
	c.Assert(err, check.ErrorMatches, ".*Using \"redis-queue:\\*\" is deprecated.*")
}
開發者ID:RichardKnop,項目名稱:tsuru,代碼行數:7,代碼來源:checker_test.go

示例3: TestCheckRouterHipacheCanHaveHipacheInRoutersConf

func (s *CheckerSuite) TestCheckRouterHipacheCanHaveHipacheInRoutersConf(c *check.C) {
	config.Unset("routers:hipache")
	config.Set("hipache:domain", "something")
	err := checkRouter()
	c.Assert(err, check.FitsTypeOf, config.NewWarning(""))
	c.Assert(err, check.ErrorMatches, ".*Setting \"hipache:\\*\" config entries is deprecated.*")
}
開發者ID:RichardKnop,項目名稱:tsuru,代碼行數:7,代碼來源:checker_test.go

示例4: checkQueue

func checkQueue() error {
	queueConfig, _ := config.GetString("queue:mongo-url")
	if queueConfig == "" {
		return config.NewWarning(`Config entry "queue:mongo-url" is not set, default "localhost" will be used. Running "tsuru-admin docker-node-{add,remove}" commands might not work.`)
	}
	return nil
}
開發者ID:zhenruyan,項目名稱:tsuru,代碼行數:7,代碼來源:checker.go

示例5: TestCheckSchedulerConfigSegregate

func (s *CheckerSuite) TestCheckSchedulerConfigSegregate(c *check.C) {
	config.Set("docker:segregate", true)
	err := checkScheduler()
	baseWarn := config.NewWarning("")
	c.Assert(err, check.FitsTypeOf, baseWarn)
	c.Assert(err, check.ErrorMatches, `Setting "docker:segregate" is not necessary anymore, this is the default behavior from now on.`)
	config.Set("docker:segregate", false)
	err = checkScheduler()
	c.Assert(err, check.Not(check.FitsTypeOf), baseWarn)
	c.Assert(err, check.ErrorMatches, `You must remove "docker:segregate" from your config.`)
}
開發者ID:RichardKnop,項目名稱:tsuru,代碼行數:11,代碼來源:checker_test.go

示例6: checkScheduler

// Check Schedulers
// It verifies your scheduler configuration and validates related confs.
func checkScheduler() error {
	if servers, err := config.Get("docker:servers"); err == nil && servers != nil {
		return fmt.Errorf(`Using docker:servers is deprecated, please remove it your config and use "tsuru-admin docker-node-add" do add docker nodes.`)
	}
	isSegregate, err := config.GetBool("docker:segregate")
	if err == nil {
		if isSegregate {
			return config.NewWarning(`Setting "docker:segregate" is not necessary anymore, this is the default behavior from now on.`)
		} else {
			return fmt.Errorf(`You must remove "docker:segregate" from your config.`)
		}
	}
	return nil
}
開發者ID:zhenruyan,項目名稱:tsuru,代碼行數:16,代碼來源:checker.go

示例7: checkRouter

// Check Router
// It verifies your router configuration and validates related confs.
func checkRouter() error {
	defaultRouter, _ := config.GetString("docker:router")
	if defaultRouter == "" {
		return fmt.Errorf(`You must configure a default router in "docker:router".`)
	}
	isHipacheOld := false
	if defaultRouter == "hipache" {
		hipacheOld, _ := config.Get("hipache")
		isHipacheOld = hipacheOld != nil
	}
	routerConf, _ := config.Get("routers:" + defaultRouter)
	if isHipacheOld {
		return config.NewWarning(`Setting "hipache:*" config entries is deprecated. You should configure your router with "routers:*". See http://docs.tsuru.io/en/latest/reference/config.html#routers for more details.`)
	}
	if routerConf == nil {
		return fmt.Errorf(`You must configure your default router %q in "routers:%s".`, defaultRouter, defaultRouter)
	}
	routerType, _ := config.Get("routers:" + defaultRouter + ":type")
	if routerType == nil {
		return fmt.Errorf(`You must configure your default router type in "routers:%s:type".`, defaultRouter)
	}
	return nil
}
開發者ID:zhenruyan,項目名稱:tsuru,代碼行數:25,代碼來源:checker.go

示例8: TestCheckQueueNotSet

func (w *CheckerSuite) TestCheckQueueNotSet(c *check.C) {
	config.Unset("queue:mongo-url")
	err := checkQueue()
	c.Assert(err, check.FitsTypeOf, config.NewWarning(""))
	c.Assert(err, check.ErrorMatches, ".*Config entry \"queue:mongo-url\" is not set.*")
}
開發者ID:RichardKnop,項目名稱:tsuru,代碼行數:6,代碼來源:checker_test.go

示例9: TestCheckPubSubMissing

func (w *CheckerSuite) TestCheckPubSubMissing(c *check.C) {
	config.Unset("pubsub:redis-host")
	err := checkPubSub()
	c.Assert(err, check.FitsTypeOf, config.NewWarning(""))
	c.Assert(err, check.ErrorMatches, ".*Config entry \"pubsub:redis-host\" is not set.*")
}
開發者ID:RichardKnop,項目名稱:tsuru,代碼行數:6,代碼來源:checker_test.go


注:本文中的github.com/tsuru/config.NewWarning函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。