本文整理汇总了Golang中github.com/cloudfoundry-incubator/ltc/config.Config.Target方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.Target方法的具体用法?Golang Config.Target怎么用?Golang Config.Target使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry-incubator/ltc/config.Config
的用法示例。
在下文中一共展示了Config.Target方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Dial
func (*AppDialer) Dial(appName string, instanceIndex int, config *config_package.Config) (Client, error) {
diegoSSHUser := fmt.Sprintf("diego:%s/%d", appName, instanceIndex)
address := fmt.Sprintf("%s:2222", config.Target())
client, err := sshapi.New(diegoSSHUser, config.Username(), config.Password(), address)
if err != nil {
return nil, err
}
return client, nil
}
示例2:
Expect(outputBuffer).To(test_helpers.SayLine("Error connecting to good-name/0: connection failed"))
Expect(fakeSSH.ConnectCallCount()).To(Equal(1))
Expect(fakeSSH.ForwardCallCount()).To(Equal(0))
Expect(fakeSSH.ShellCallCount()).To(Equal(0))
Expect(fakeExitHandler.ExitCalledWith).To(Equal([]int{exit_codes.CommandFailed}))
})
})
Describe("port forwarding", func() {
It("should forward a local port to a remote host and port", func() {
fakeAppExaminer.AppStatusReturns(app_examiner.AppInfo{ActualRunningInstances: 1}, nil)
test_helpers.ExecuteCommandWithArgs(sshCommand, []string{"app-name", "-N", "-L", "mrlocalhost:1234:remotehost:5678"})
Expect(outputBuffer).To(test_helpers.SayLine("Forwarding mrlocalhost:1234 to remotehost:5678 via app-name/0 at %s", config.Target()))
Expect(fakeSSH.ConnectCallCount()).To(Equal(1))
appName, instanceIndex, actualConfig := fakeSSH.ConnectArgsForCall(0)
Expect(appName).To(Equal("app-name"))
Expect(instanceIndex).To(Equal(0))
Expect(actualConfig).To(Equal(config))
Expect(fakeSSH.ForwardCallCount()).To(Equal(1))
localAddr, remoteAddr := fakeSSH.ForwardArgsForCall(0)
Expect(localAddr).To(Equal("mrlocalhost:1234"))
Expect(remoteAddr).To(Equal("remotehost:5678"))
Expect(fakeAppExaminer.AppStatusCallCount()).To(Equal(1))
Expect(fakeAppExaminer.AppStatusArgsForCall(0)).To(Equal("app-name"))
})
示例3: cliCommands
func cliCommands(ltcConfigRoot string, exitHandler exit_handler.ExitHandler, config *config.Config, logger lager.Logger, receptorClientCreator receptor_client.Creator, targetVerifier target_verifier.TargetVerifier, ui terminal.UI, latticeVersion string) []cli.Command {
receptorClient := receptorClientCreator.CreateReceptorClient(config.Receptor())
noaaConsumer := noaa.NewConsumer(LoggregatorUrl(config.Loggregator()), nil, nil)
appRunner := app_runner.New(receptorClient, config.Target(), &keygen_package.KeyGenerator{RandReader: rand.Reader})
clock := clock.NewClock()
logReader := logs.NewLogReader(noaaConsumer)
tailedLogsOutputter := console_tailed_logs_outputter.NewConsoleTailedLogsOutputter(ui, logReader)
taskExaminer := task_examiner.New(receptorClient)
taskExaminerCommandFactory := task_examiner_command_factory.NewTaskExaminerCommandFactory(taskExaminer, ui, exitHandler)
taskRunner := task_runner.New(receptorClient, taskExaminer, clock)
taskRunnerCommandFactory := task_runner_command_factory.NewTaskRunnerCommandFactory(taskRunner, ui, exitHandler)
appExaminer := app_examiner.New(receptorClient, app_examiner.NewNoaaConsumer(noaaConsumer))
graphicalVisualizer := graphical.NewGraphicalVisualizer(appExaminer)
dockerTerminal := &app_examiner_command_factory.DockerTerminal{}
appExaminerCommandFactory := app_examiner_command_factory.NewAppExaminerCommandFactory(appExaminer, ui, dockerTerminal, clock, exitHandler, graphicalVisualizer, taskExaminer, config.Target())
appRunnerCommandFactoryConfig := app_runner_command_factory.AppRunnerCommandFactoryConfig{
AppRunner: appRunner,
AppExaminer: appExaminer,
UI: ui,
Domain: config.Target(),
Env: os.Environ(),
Clock: clock,
Logger: logger,
TailedLogsOutputter: tailedLogsOutputter,
ExitHandler: exitHandler,
}
appRunnerCommandFactory := app_runner_command_factory.NewAppRunnerCommandFactory(appRunnerCommandFactoryConfig)
dockerRunnerCommandFactoryConfig := docker_runner_command_factory.DockerRunnerCommandFactoryConfig{
AppRunner: appRunner,
AppExaminer: appExaminer,
UI: ui,
Domain: config.Target(),
Env: os.Environ(),
Clock: clock,
Logger: logger,
ExitHandler: exitHandler,
TailedLogsOutputter: tailedLogsOutputter,
DockerMetadataFetcher: docker_metadata_fetcher.New(docker_metadata_fetcher.NewDockerSessionFactory()),
}
dockerRunnerCommandFactory := docker_runner_command_factory.NewDockerRunnerCommandFactory(dockerRunnerCommandFactoryConfig)
logsCommandFactory := logs_command_factory.NewLogsCommandFactory(appExaminer, taskExaminer, ui, tailedLogsOutputter, exitHandler)
clusterTestRunner := cluster_test.NewClusterTestRunner(config, ltcConfigRoot)
clusterTestCommandFactory := cluster_test_command_factory.NewClusterTestCommandFactory(clusterTestRunner)
blobStore := blob_store.New(config)
blobStoreVerifier := blob_store.BlobStoreVerifier{
DAVBlobStoreVerifier: dav_blob_store.Verifier{},
S3BlobStoreVerifier: s3_blob_store.Verifier{},
}
httpProxyConfReader := &droplet_runner.HTTPProxyConfReader{
URL: fmt.Sprintf("http://%s:8444/proxyconf.json", config.Target()),
}
dropletRunner := droplet_runner.New(appRunner, taskRunner, config, blobStore, appExaminer, httpProxyConfReader)
cfIgnore := cf_ignore.New()
zipper := &zipper_package.DropletArtifactZipper{}
dropletRunnerCommandFactory := droplet_runner_command_factory.NewDropletRunnerCommandFactory(*appRunnerCommandFactory, blobStoreVerifier, taskExaminer, dropletRunner, cfIgnore, zipper, config)
versionManager := version.NewVersionManager(receptorClientCreator, &version.AppFileSwapper{}, defaultLatticeVersion(latticeVersion))
configCommandFactory := config_command_factory.NewConfigCommandFactory(config, ui, targetVerifier, blobStoreVerifier, exitHandler, versionManager)
sshCommandFactory := ssh_command_factory.NewSSHCommandFactory(config, ui, exitHandler, appExaminer, ssh.New(exitHandler))
ltcPath, _ := osext.Executable()
versionCommandFactory := version_command_factory.NewVersionCommandFactory(config, ui, exitHandler, runtime.GOOS, ltcPath, versionManager)
helpCommand := cli.Command{
Name: "help",
Aliases: []string{"h"},
Usage: "Shows a list of commands or help for one command",
Description: "ltc help",
Action: defaultAction,
}
return []cli.Command{
appExaminerCommandFactory.MakeCellsCommand(),
dockerRunnerCommandFactory.MakeCreateAppCommand(),
appRunnerCommandFactory.MakeSubmitLrpCommand(),
logsCommandFactory.MakeDebugLogsCommand(),
appExaminerCommandFactory.MakeListAppCommand(),
logsCommandFactory.MakeLogsCommand(),
appRunnerCommandFactory.MakeRemoveAppCommand(),
appRunnerCommandFactory.MakeScaleAppCommand(),
appExaminerCommandFactory.MakeStatusCommand(),
taskRunnerCommandFactory.MakeSubmitTaskCommand(),
configCommandFactory.MakeTargetCommand(),
taskExaminerCommandFactory.MakeTaskCommand(),
taskRunnerCommandFactory.MakeDeleteTaskCommand(),
taskRunnerCommandFactory.MakeCancelTaskCommand(),
clusterTestCommandFactory.MakeClusterTestCommand(),
//.........这里部分代码省略.........
示例4:
BeforeEach(func() {
fakeTargetVerifier.VerifyTargetReturns(true, false, nil)
fakeBlobStoreVerifier.VerifyReturns(true, nil)
fakePasswordReader.PromptForPasswordReturns("testpassword")
})
It("prompts for credentials and stores them in the config", func() {
doneChan := test_helpers.AsyncExecuteCommandWithArgs(targetCommand, []string{"myapi.com"})
Eventually(outputBuffer).Should(test_helpers.Say("Username: "))
fakeTargetVerifier.VerifyTargetReturns(true, true, nil)
stdinWriter.Write([]byte("testusername\n"))
Eventually(doneChan, 3).Should(BeClosed())
Expect(config.Target()).To(Equal("myapi.com"))
Expect(config.Receptor()).To(Equal("http://testusername:[email protected]"))
Expect(outputBuffer).To(test_helpers.SayLine("API location set."))
Expect(fakePasswordReader.PromptForPasswordCallCount()).To(Equal(1))
Expect(fakePasswordReader.PromptForPasswordArgsForCall(0)).To(Equal("Password"))
Expect(fakeTargetVerifier.VerifyTargetCallCount()).To(Equal(2))
Expect(fakeTargetVerifier.VerifyTargetArgsForCall(0)).To(Equal("http://receptor.myapi.com"))
Expect(fakeTargetVerifier.VerifyTargetArgsForCall(1)).To(Equal("http://testusername:[email protected]"))
})
Context("when provided receptor credentials are invalid", func() {
It("does not save the config", func() {
fakePasswordReader.PromptForPasswordReturns("some-invalid-password")
doneChan := test_helpers.AsyncExecuteCommandWithArgs(targetCommand, []string{"newtarget.com"})
示例5:
var _ = Describe("Config", func() {
var (
testPersister *fakePersister
testConfig *config.Config
)
BeforeEach(func() {
testPersister = &fakePersister{}
testConfig = config.New(testPersister)
})
Describe("Target", func() {
It("sets the target", func() {
testConfig.SetTarget("mynewapi.com")
Expect(testConfig.Target()).To(Equal("mynewapi.com"))
})
})
Describe("Username", func() {
It("sets the target", func() {
testConfig.SetLogin("ausername", "apassword")
Expect(testConfig.Username()).To(Equal("ausername"))
})
})
Describe("Receptor", func() {
It("returns the Receptor with a username and password", func() {
testConfig.SetTarget("mynewapi.com")
testConfig.SetLogin("testusername", "testpassword")