本文整理匯總了Golang中github.com/cloudfoundry-incubator/ltc/config.Config.Load方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.Load方法的具體用法?Golang Config.Load怎麽用?Golang Config.Load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/ltc/config.Config
的用法示例。
在下文中一共展示了Config.Load方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: MakeCliApp
func MakeCliApp(
diegoVersion string,
latticeVersion string,
ltcConfigRoot string,
exitHandler exit_handler.ExitHandler,
config *config.Config,
logger lager.Logger,
receptorClientCreator receptor_client.Creator,
targetVerifier target_verifier.TargetVerifier,
cliStdout io.Writer,
) *cli.App {
config.Load()
app := cli.NewApp()
app.Name = AppName
app.Author = latticeCliAuthor
app.Version = defaultVersion(diegoVersion, latticeVersion)
app.Usage = LtcUsage
app.Email = "[email protected]"
ui := terminal.NewUI(os.Stdin, cliStdout, terminal.NewPasswordReader())
app.Writer = ui
app.Before = func(context *cli.Context) error {
args := context.Args()
command := app.Command(args.First())
if command == nil {
return nil
}
if _, ok := nonTargetVerifiedCommandNames[command.Name]; ok || len(args) == 0 {
return nil
}
for _, arg := range args {
if arg == "-h" || arg == "--help" {
return nil
}
}
if receptorUp, authorized, err := targetVerifier.VerifyTarget(config.Receptor()); !receptorUp {
ui.SayLine(fmt.Sprintf("Error connecting to the receptor. Make sure your lattice target is set, and that lattice is up and running.\n\tUnderlying error: %s", err))
return err
} else if !authorized {
ui.SayLine("Could not authenticate with the receptor. Please run ltc target with the correct credentials.")
return errors.New("Could not authenticate with the receptor.")
}
return nil
}
app.Action = defaultAction
app.CommandNotFound = func(c *cli.Context, command string) {
ui.SayLine(fmt.Sprintf(unknownCommand, command))
exitHandler.Exit(1)
}
app.Commands = cliCommands(ltcConfigRoot, exitHandler, config, logger, receptorClientCreator, targetVerifier, ui, latticeVersion)
return app
}
示例2:
It("returns errors from the persistor", func() {
testPersister.err = errors.New("Error")
err := testConfig.Save()
Expect(err).To(MatchError("Error"))
})
})
Describe("Load", func() {
It("loads the target, username, and password from the persister", func() {
testPersister.target = "mysavedapi.com"
testPersister.username = "saveduser"
testPersister.password = "password"
Expect(testConfig.Load()).To(Succeed())
Expect(testPersister.target).To(Equal("mysavedapi.com"))
Expect(testConfig.Receptor()).To(Equal("http://saveduser:[email protected]"))
})
It("returns errors from loading the config", func() {
testPersister.err = errors.New("Error")
err := testConfig.Load()
Expect(err).To(MatchError("Error"))
})
})
Describe("ActiveBlobStore", func() {
It("defaults to 'dav'", func() {