本文整理汇总了Golang中github.com/cloudfoundry-incubator/ltc/config.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewCliApp
func NewCliApp() *cli.App {
config := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(ltcConfigRoot())))
signalChan := make(chan os.Signal)
signal.Notify(signalChan, os.Interrupt, syscall.SIGHUP, syscall.SIGTERM)
exitHandler := exit_handler.New(signalChan, os.Exit)
go exitHandler.Run()
receptorClientCreator := receptor_client.ProxyAwareCreator{}
return cli_app_factory.MakeCliApp(
diegoVersion,
latticeVersion,
ltcConfigRoot(),
exitHandler,
config,
logger(),
receptorClientCreator,
target_verifier.New(receptorClientCreator),
os.Stdout,
)
}
示例2:
config *config_package.Config
appSSH *ssh.SSH
)
BeforeEach(func() {
fakeClientDialer = &mocks.FakeClientDialer{}
fakeClient = &mocks.FakeClient{}
fakeTerm = &mocks.FakeTerm{}
fakeListener = &mocks.FakeListener{}
fakeSessionFactory = &mocks.FakeSessionFactory{}
fakeSession = &mocks.FakeSession{}
fakeExitHandler = &fake_exit_handler.FakeExitHandler{}
sigWinchChan = make(chan os.Signal, 4)
config = config_package.New(nil)
appSSH = &ssh.SSH{
Listener: fakeListener,
ClientDialer: fakeClientDialer,
Term: fakeTerm,
SessionFactory: fakeSessionFactory,
ExitHandler: fakeExitHandler,
SigWinchChannel: sigWinchChan,
}
fakeClientDialer.DialReturns(fakeClient, nil)
fakeSessionFactory.NewReturns(fakeSession, nil)
})
Describe("#Connect", func() {
It("should dial an ssh client", func() {
Expect(appSSH.Connect("some-app-name", 100, config)).To(Succeed())
示例3:
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{}
fakeReceptorClientCreator = &fake_receptor_client_creator.FakeCreator{}
fakeExitHandler = &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"
fakeReceptorClientCreator.CreateReceptorClientReturns(&fake_receptor.FakeClient{})
})
JustBeforeEach(func() {
cliApp = cli_app_factory.MakeCliApp(
diegoVersion,
latticeVersion,
"~/",
fakeExitHandler,
cliConfig,
lager.NewLogger("test"),
fakeReceptorClientCreator,
fakeTargetVerifier,
示例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)
示例5:
ghttp.VerifyRequest("GET", "/v1/actual_lrps"),
ghttp.RespondWithJSONEncoded(http.StatusOK, actualResponse),
),
)
fakeServer.RouteToHandler("GET", "/v1/tasks",
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v1/tasks"),
ghttp.RespondWithJSONEncoded(http.StatusOK, tasksResponse),
),
)
var err error
configRoot, err = ioutil.TempDir("", "config")
Expect(err).NotTo(HaveOccurred())
ltcConfig := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(configRoot)))
listenerHost, listenerPort, err = net.SplitHostPort(listenerAddr)
Expect(err).NotTo(HaveOccurred())
ltcConfig.SetTarget(fmt.Sprintf("%s.xip.io:%s", listenerHost, listenerPort))
Expect(ltcConfig.Save()).To(Succeed())
os.Setenv(latticeCliHomeVar, configRoot)
})
AfterEach(func() {
fakeServer.Close()
Expect(os.RemoveAll(configRoot)).To(Succeed())
Expect(os.Unsetenv(latticeCliHomeVar)).To(Succeed())
})
ltcCommand := func(args ...string) *exec.Cmd {
示例6:
var _ = Describe("DropletRunner", func() {
var (
fakeAppRunner *fake_app_runner.FakeAppRunner
fakeTaskRunner *fake_task_runner.FakeTaskRunner
config *config_package.Config
fakeBlobStore *fake_blob_store.FakeBlobStore
fakeAppExaminer *fake_app_examiner.FakeAppExaminer
fakeProxyConfReader *fake_proxyconf_reader.FakeProxyConfReader
dropletRunner droplet_runner.DropletRunner
)
BeforeEach(func() {
fakeAppRunner = &fake_app_runner.FakeAppRunner{}
fakeTaskRunner = &fake_task_runner.FakeTaskRunner{}
config = config_package.New(persister.NewMemPersister())
fakeBlobStore = &fake_blob_store.FakeBlobStore{}
fakeAppExaminer = &fake_app_examiner.FakeAppExaminer{}
fakeProxyConfReader = &fake_proxyconf_reader.FakeProxyConfReader{}
dropletRunner = droplet_runner.New(fakeAppRunner, fakeTaskRunner, config, fakeBlobStore, fakeAppExaminer, fakeProxyConfReader)
})
Describe("ListDroplets", func() {
It("returns a list of droplets in the blob store", func() {
fakeBlobStore.ListReturns([]blob.Blob{
{Path: "X/bits.zip", Created: time.Unix(1000, 0), Size: 100},
{Path: "X/droplet.tgz", Created: time.Unix(2000, 0), Size: 200},
{Path: "X/result.json", Created: time.Unix(3000, 0), Size: 300},
{Path: "Y/bits.zip"},
{Path: "X/Y/droplet.tgz"},
{Path: "droplet.tgz"},
示例7:
fakeExitHandler *fake_exit_handler.FakeExitHandler
fakePasswordReader *mocks.FakePasswordReader
fakeVersionManager *fake_version_manager.FakeVersionManager
)
BeforeEach(func() {
stdinReader, stdinWriter = io.Pipe()
outputBuffer = gbytes.NewBuffer()
fakeExitHandler = &fake_exit_handler.FakeExitHandler{}
fakePasswordReader = &mocks.FakePasswordReader{}
terminalUI = terminal.NewUI(stdinReader, outputBuffer, fakePasswordReader)
fakeTargetVerifier = &fake_target_verifier.FakeTargetVerifier{}
fakeBlobStoreVerifier = &fake_blob_store_verifier.FakeBlobStoreVerifier{}
fakeVersionManager = &fake_version_manager.FakeVersionManager{}
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, fakeVersionManager)
targetCommand = commandFactory.MakeTargetCommand()
示例8:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/cloudfoundry-incubator/ltc/config"
)
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"))