• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang config.New函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cloudfoundry-incubator/lattice/ltc/config.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了New函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
	exitHandler := exit_handler.New(signalChan, os.Exit)
	go exitHandler.Run()

	targetVerifier := target_verifier.New(receptor_client_factory.MakeReceptorClient)
	app := cli_app_factory.MakeCliApp(latticeVersion, ltcConfigRoot(), exitHandler, config, logger(), targetVerifier, os.Stdout)
	return app
}
开发者ID:rajkumargithub,项目名称:lattice,代码行数:12,代码来源:setup_cli.go


示例2: 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


示例3: NewCliApp

func NewCliApp() *cli.App {
	config := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(ltcConfigRoot())))

	signalChan := make(chan os.Signal)
	signal.Notify(signalChan, os.Interrupt)
	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,
	)
}
开发者ID:datachand,项目名称:lattice,代码行数:22,代码来源:setup_cli.go


示例4: NewCliApp

func NewCliApp() *cli.App {
	config := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(ltcConfigRoot())))

	signalChan := make(chan os.Signal)
	signal.Notify(signalChan, os.Interrupt)
	exitHandler := exit_handler.New(signalChan, os.Exit)
	go exitHandler.Run()

	targetVerifier := target_verifier.New(func(target string) receptor.Client {
		return receptor.NewClient(target)
	})

	return cli_app_factory.MakeCliApp(
		diegoVersion,
		latticeVersion,
		ltcConfigRoot(),
		exitHandler,
		config,
		logger(),
		targetVerifier,
		os.Stdout,
	)
}
开发者ID:rowhit,项目名称:lattice,代码行数:23,代码来源:setup_cli.go


示例5:

		config                  *config_package.Config

		appRunnerCommandFactory app_runner_command_factory.AppRunnerCommandFactory
	)

	BeforeEach(func() {
		fakeDropletRunner = &fake_droplet_runner.FakeDropletRunner{}
		fakeExitHandler = &fake_exit_handler.FakeExitHandler{}
		fakeTailedLogsOutputter = fake_tailed_logs_outputter.NewFakeTailedLogsOutputter()
		fakeClock = fakeclock.NewFakeClock(time.Now())
		fakeAppExaminer = &fake_app_examiner.FakeAppExaminer{}
		fakeTaskExaminer = &fake_task_examiner.FakeTaskExaminer{}
		fakeCFIgnore = &fake_cf_ignore.FakeCFIgnore{}
		fakeZipper = &fake_zipper.FakeZipper{}
		fakeBlobStoreVerifier = &fake_blob_store_verifier.FakeBlobStoreVerifier{}
		config = config_package.New(nil)

		outputBuffer = gbytes.NewBuffer()
		appRunnerCommandFactory = app_runner_command_factory.AppRunnerCommandFactory{
			AppRunner:           &fake_app_runner.FakeAppRunner{},
			AppExaminer:         fakeAppExaminer,
			UI:                  terminal.NewUI(nil, outputBuffer, nil),
			ExitHandler:         fakeExitHandler,
			TailedLogsOutputter: fakeTailedLogsOutputter,
			Clock:               fakeClock,
			Domain:              "192.168.11.11.xip.io",
			Env:                 []string{"SHELL=/bin/bash", "COLOR=Black", "AAAA=xyz"},
		}
	})

	Describe("BuildDropletCommand", func() {
开发者ID:SrinivasChilveri,项目名称:lattice,代码行数:31,代码来源:droplet_runner_command_factory_test.go


示例6:

		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


示例7:

		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,
			terminalUI,
		)
	})
开发者ID:edwardt,项目名称:lattice,代码行数:31,代码来源:cli_app_factory_test.go


示例8:

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"},
开发者ID:datachand,项目名称:lattice,代码行数:30,代码来源:droplet_runner_test.go


示例9:

	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


示例10:

		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)
			targetCommand = commandFactory.MakeTargetCommand()
开发者ID:SrinivasChilveri,项目名称:lattice,代码行数:31,代码来源:config_command_factory_test.go


示例11:

		outputBuffer       *gbytes.Buffer
		terminalUI         terminal.UI
		config             *config_package.Config
		fakeTargetVerifier *fake_target_verifier.FakeTargetVerifier
		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{}
		config = config_package.New(persister.NewMemPersister())
	})

	Describe("TargetCommand", func() {
		var targetCommand cli.Command

		verifyOldTargetStillSet := func() {
			config.Load()
			Expect(config.Receptor()).To(Equal("http://olduser:[email protected]"))
		}

		BeforeEach(func() {
			commandFactory := command_factory.NewConfigCommandFactory(config, terminalUI, fakeTargetVerifier, fakeExitHandler)
			targetCommand = commandFactory.MakeTargetCommand()
		})
开发者ID:se77en,项目名称:lattice,代码行数:30,代码来源:config_command_factory_test.go


示例12:

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry-incubator/lattice/ltc/config"
	"github.com/cloudfoundry-incubator/lattice/ltc/config/dav_blob_store"
)

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"))
开发者ID:shanetreacy,项目名称:lattice,代码行数:31,代码来源:config_test.go


示例13:

)

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


示例14:

import (
	"errors"
	"net/http"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry-incubator/lattice/ltc/config"
)

var _ = Describe("Config", func() {
	var testConfig *config.Config

	BeforeEach(func() {
		testConfig = config.New(&fakePersister{})
	})

	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"))
开发者ID:rajkumargithub,项目名称:lattice,代码行数:30,代码来源:config_test.go


示例15:

				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 {
开发者ID:davidwadden,项目名称:lattice-release,代码行数:31,代码来源:main_test.go


示例16:

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry-incubator/lattice/ltc/blob_store"
	"github.com/cloudfoundry-incubator/lattice/ltc/blob_store/dav_blob_store"
	"github.com/cloudfoundry-incubator/lattice/ltc/blob_store/s3_blob_store"
	"github.com/cloudfoundry-incubator/lattice/ltc/config"
)

var _ = Describe("BlobStoreManager", func() {
	Describe(".New", func() {
		var blobStore blob_store.BlobStore

		Context("when a dav blob store is targeted", func() {
			BeforeEach(func() {
				config := config.New(nil)
				config.SetBlobStore("some-host", "some-port", "some-user", "some-password")
				blobStore = blob_store.New(config)
			})

			It("returns a new DavBlobStore object", func() {
				davBlobStore, ok := blobStore.(*dav_blob_store.BlobStore)
				Expect(ok).To(BeTrue())
				Expect(davBlobStore.URL.String()).To(Equal("http://some-user:[email protected]:some-port"))
			})
		})

		Context("when an s3 blob store is targeted", func() {
			BeforeEach(func() {
				config := config.New(nil)
				config.SetS3BlobStore("", "", "some-bucket-name", "")
开发者ID:rowhit,项目名称:lattice,代码行数:31,代码来源:blob_store_test.go



注:本文中的github.com/cloudfoundry-incubator/lattice/ltc/config.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang config.Config类代码示例发布时间:2022-05-23
下一篇:
Golang fake_app_runner.FakeAppRunner类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap