本文整理汇总了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
}
示例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.*")
}
示例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.*")
}
示例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
}
示例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.`)
}
示例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
}
示例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
}
示例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.*")
}
示例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.*")
}