本文整理汇总了Golang中github.com/cloudfoundry-incubator/lattice/ltc/config/persister.NewMemPersister函数的典型用法代码示例。如果您正苦于以下问题:Golang NewMemPersister函数的具体用法?Golang NewMemPersister怎么用?Golang NewMemPersister使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewMemPersister函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: VerifyBlobTarget
func (t *targetVerifier) VerifyBlobTarget(host string, port uint16, accessKey, secretKey, bucketName string) (bool, error) {
s3Auth := aws.Auth{
AccessKey: accessKey,
SecretKey: secretKey,
}
config := config.New(persister.NewMemPersister())
config.SetBlobTarget(host, port, accessKey, secretKey, bucketName)
s3S3 := s3.New(s3Auth, awsRegion, &http.Client{
Transport: &http.Transport{
Proxy: config.BlobTarget().Proxy(),
Dial: (&net.Dialer{
Timeout: 5 * time.Second,
KeepAlive: 5 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
},
})
s3S3.AttemptStrategy = aws.AttemptStrategy{}
blobStore := blob_store.NewBlobStore(config, s3S3)
blobBucket := blobStore.Bucket(config.BlobTarget().BucketName)
if _, err := blobBucket.List("", "/", "", 1); err != nil {
if httpError, ok := err.(*s3.Error); ok {
switch httpError.StatusCode {
case 403:
return false, fmt.Errorf("unauthorized")
default:
return false, fmt.Errorf("%s", httpError)
}
}
return false, fmt.Errorf("blob target is down: %s", err)
}
return true, nil
}
开发者ID:se77en,项目名称:lattice,代码行数:39,代码来源:blob_target_verifier.go
示例2:
stdinReader *io.PipeReader
stdinWriter *io.PipeWriter
outputBuffer *gbytes.Buffer
terminalUI terminal.UI
config *config_package.Config
fakeTargetVerifier *fake_target_verifier.FakeTargetVerifier
fakeExitHandler *fake_exit_handler.FakeExitHandler
)
BeforeEach(func() {
stdinReader, stdinWriter = io.Pipe()
outputBuffer = gbytes.NewBuffer()
fakeTargetVerifier = &fake_target_verifier.FakeTargetVerifier{}
fakeExitHandler = new(fake_exit_handler.FakeExitHandler)
terminalUI = terminal.NewUI(stdinReader, outputBuffer, nil)
config = config_package.New(persister.NewMemPersister())
})
Describe("TargetBlobCommand", func() {
var targetBlobCommand cli.Command
BeforeEach(func() {
commandFactory := command_factory.NewConfigCommandFactory(config, terminalUI, fakeTargetVerifier, fakeExitHandler)
targetBlobCommand = commandFactory.MakeTargetBlobCommand()
})
Context("displaying the blob target", func() {
It("outputs the current target", func() {
config.SetBlobTarget("192.168.11.11", 8980, "datkeyyo", "supersecretJKJK", "bucket")
config.Save()
开发者ID:se77en,项目名称:lattice,代码行数:30,代码来源:blob_config_command_factory_test.go
示例3:
var _ = Describe("CliAppFactory", func() {
var (
fakeTargetVerifier *fake_target_verifier.FakeTargetVerifier
fakeExitHandler *fake_exit_handler.FakeExitHandler
outputBuffer *gbytes.Buffer
terminalUI terminal.UI
cliApp *cli.App
cliConfig *config.Config
latticeVersion, diegoVersion string
)
BeforeEach(func() {
fakeTargetVerifier = &fake_target_verifier.FakeTargetVerifier{}
fakeExitHandler = new(fake_exit_handler.FakeExitHandler)
memPersister := persister.NewMemPersister()
outputBuffer = gbytes.NewBuffer()
terminalUI = terminal.NewUI(nil, outputBuffer, nil)
cliConfig = config.New(memPersister)
latticeVersion, diegoVersion = "v0.2.Test", "0.12345.0"
})
JustBeforeEach(func() {
cliApp = cli_app_factory.MakeCliApp(
diegoVersion,
latticeVersion,
"~/",
fakeExitHandler,
cliConfig,
lager.NewLogger("test"),
fakeTargetVerifier,
开发者ID:edwardt,项目名称:lattice,代码行数:31,代码来源:cli_app_factory_test.go
示例4:
subCommandTemplate := `NAME:
{{.Name}} - {{.Usage}}
USAGE:
{{.Name}} command{{if .Flags}} [command options]{{end}} [arguments...]
`
BeforeEach(func() {
outputBuffer = gbytes.NewBuffer()
fakeReceptorClientCreator = &fake_receptor_client_creator.FakeCreator{}
cliApp = cli_app_factory.MakeCliApp(
"",
"",
"~/",
nil,
config.New(persister.NewMemPersister()),
nil,
fakeReceptorClientCreator,
nil,
terminal.NewUI(nil, outputBuffer, nil),
)
})
Describe("ShowHelp", func() {
It("shows help for all commands", func() {
Expect(cliApp.Commands).NotTo(BeEmpty())
cli_app_factory.ShowHelp(outputBuffer, dummyTemplate, cliApp)
outputBytes, err := ioutil.ReadAll(outputBuffer)
开发者ID:davidwadden,项目名称:lattice-release,代码行数:31,代码来源:app_help_test.go
示例5:
configPersister persister.Persister
fakeTargetVerifier *fake_target_verifier.FakeTargetVerifier
fakeBlobStoreVerifier *fake_blob_store_verifier.FakeBlobStoreVerifier
fakeExitHandler *fake_exit_handler.FakeExitHandler
fakePasswordReader *fake_password_reader.FakePasswordReader
)
BeforeEach(func() {
stdinReader, stdinWriter = io.Pipe()
outputBuffer = gbytes.NewBuffer()
fakeExitHandler = &fake_exit_handler.FakeExitHandler{}
fakePasswordReader = &fake_password_reader.FakePasswordReader{}
terminalUI = terminal.NewUI(stdinReader, outputBuffer, fakePasswordReader)
fakeTargetVerifier = &fake_target_verifier.FakeTargetVerifier{}
fakeBlobStoreVerifier = &fake_blob_store_verifier.FakeBlobStoreVerifier{}
configPersister = persister.NewMemPersister()
config = config_package.New(configPersister)
})
Describe("TargetCommand", func() {
var targetCommand cli.Command
verifyOldTargetStillSet := func() {
newConfig := config_package.New(configPersister)
Expect(newConfig.Load()).To(Succeed())
Expect(newConfig.Receptor()).To(Equal("http://olduser:[email protected]"))
}
BeforeEach(func() {
commandFactory := command_factory.NewConfigCommandFactory(config, terminalUI, fakeTargetVerifier, fakeBlobStoreVerifier, fakeExitHandler)
开发者ID:SrinivasChilveri,项目名称:lattice,代码行数:31,代码来源:config_command_factory_test.go
示例6:
)
var _ = Describe("HelpHelpers", func() {
var (
fakeTargetVerifier *fake_target_verifier.FakeTargetVerifier
outputBuffer *gbytes.Buffer
terminalUI terminal.UI
cliConfig *config.Config
cliApp *cli.App
)
BeforeEach(func() {
fakeTargetVerifier = &fake_target_verifier.FakeTargetVerifier{}
outputBuffer = gbytes.NewBuffer()
terminalUI = terminal.NewUI(nil, outputBuffer, nil)
cliConfig = config.New(persister.NewMemPersister())
cliApp = cli_app_factory.MakeCliApp(
"",
"~/",
nil,
cliConfig,
nil,
fakeTargetVerifier,
terminalUI,
)
})
Describe("MatchArgAndFlags", func() {
It("Checks for badflag", func() {
cliAppArgs := []string{"ltc", "create", "--badflag"}
flags := main.GetCommandFlags(cliApp, cliAppArgs[1])
开发者ID:rajkumargithub,项目名称:lattice,代码行数:31,代码来源:help_helpers_test.go
注:本文中的github.com/cloudfoundry-incubator/lattice/ltc/config/persister.NewMemPersister函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论