当前位置: 首页>>代码示例>>Golang>>正文


Golang config.Config类代码示例

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


在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: NewVerifier

func NewVerifier(config *config_package.Config) Verifier {
	switch config.ActiveBlobStore() {
	case config_package.DAVBlobStore:
		return dav_blob_store.Verifier{}
	case config_package.S3BlobStore:
		return &s3_blob_store.Verifier{}
	}

	return dav_blob_store.Verifier{}
}
开发者ID:rowhit,项目名称:lattice,代码行数:10,代码来源:blob_store.go

示例2: Verify

func (v BlobStoreVerifier) Verify(config *config_package.Config) (authorized bool, err error) {
	switch config.ActiveBlobStore() {
	case config_package.DAVBlobStore:
		return v.DAVBlobStoreVerifier.Verify(config)
	case config_package.S3BlobStore:
		return v.S3BlobStoreVerifier.Verify(config)
	}

	panic("unknown blob store type")
}
开发者ID:Klaudit,项目名称:lattice,代码行数:10,代码来源:blob_store.go

示例3: 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, password_reader.NewPasswordReader(exitHandler))
	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
		}

		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.Error()))
			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)
	return app
}
开发者ID:datachand,项目名称:lattice,代码行数:52,代码来源:cli_app_factory.go

示例4: New

func New(config *config_package.Config) BlobStore {
	switch config.ActiveBlobStore() {
	case config_package.DAVBlobStore:
		return dav_blob_store.New(config.BlobStore())
	case config_package.S3BlobStore:
		return s3_blob_store.New(config.S3BlobStore())
	}

	return dav_blob_store.New(config.BlobStore())
}
开发者ID:rowhit,项目名称:lattice,代码行数:10,代码来源:blob_store.go

示例5: Verify

func (Verifier) Verify(config *config_package.Config) (authorized bool, err error) {
	blobStoreURL := url.URL{
		Scheme: "http",
		Host:   fmt.Sprintf("%s:%s", config.BlobStore().Host, config.BlobStore().Port),
		User:   url.UserPassword(config.BlobStore().Username, config.BlobStore().Password),
	}

	baseURL := &url.URL{
		Scheme: blobStoreURL.Scheme,
		Host:   blobStoreURL.Host,
		User:   blobStoreURL.User,
		Path:   "/blobs/",
	}

	req, err := http.NewRequest("PROPFIND", baseURL.String(), nil)
	if err != nil {
		return false, err
	}

	req.Header.Add("Depth", "1")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return false, err
	}

	defer resp.Body.Close()

	return resp.StatusCode == 207, err
}
开发者ID:davidwadden,项目名称:lattice-release,代码行数:29,代码来源:blob_store_verifier.go

示例6: 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
}
开发者ID:davidwadden,项目名称:lattice-release,代码行数:11,代码来源:dialer.go

示例7:

	"github.com/cloudfoundry-incubator/lattice/ltc/test_helpers/matchers"
	"github.com/cloudfoundry-incubator/receptor"
	"github.com/cloudfoundry-incubator/runtime-schema/models"
	"github.com/goamz/goamz/s3"

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

var _ = Describe("DropletRunner", func() {
	var (
		fakeAppRunner      *fake_app_runner.FakeAppRunner
		fakeTaskRunner     *fake_task_runner.FakeTaskRunner
		config             *config_package.Config
		fakeBlobStore      *fake_blob_store.FakeBlobStore
		fakeBlobBucket     *fake_blob_bucket.FakeBlobBucket
		fakeTargetVerifier *fake_target_verifier.FakeTargetVerifier
		fakeAppExaminer    *fake_app_examiner.FakeAppExaminer
		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{}
		fakeBlobBucket = &fake_blob_bucket.FakeBlobBucket{}
		fakeTargetVerifier = &fake_target_verifier.FakeTargetVerifier{}
		fakeAppExaminer = &fake_app_examiner.FakeAppExaminer{}
		dropletRunner = droplet_runner.New(fakeAppRunner, fakeTaskRunner, config, fakeBlobStore, fakeBlobBucket, fakeTargetVerifier, fakeAppExaminer)
	})
开发者ID:thomasdarimont,项目名称:lattice,代码行数:32,代码来源:droplet_runner_test.go

示例8:

	"github.com/cloudfoundry-incubator/lattice/ltc/exit_handler/exit_codes"
	"github.com/cloudfoundry-incubator/lattice/ltc/exit_handler/fake_exit_handler"
	"github.com/cloudfoundry-incubator/lattice/ltc/terminal"
	"github.com/cloudfoundry-incubator/lattice/ltc/terminal/password_reader/fake_password_reader"
	"github.com/cloudfoundry-incubator/lattice/ltc/test_helpers"
	"github.com/codegangsta/cli"

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

var _ = Describe("CommandFactory", func() {
	var (
		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
		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())
	})
开发者ID:se77en,项目名称:lattice,代码行数:31,代码来源:config_command_factory_test.go

示例9:

	"errors"
	"reflect"

	config_package "github.com/cloudfoundry-incubator/lattice/ltc/config"
	sshp "github.com/cloudfoundry-incubator/lattice/ltc/ssh"
	"github.com/cloudfoundry-incubator/lattice/ltc/ssh/sshapi"
	"golang.org/x/crypto/ssh"

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

var _ = Describe("AppDialer", func() {
	Describe("#Dial", func() {
		var (
			origDial func(network, addr string, config *ssh.ClientConfig) (*ssh.Client, error)
			config   *config_package.Config
		)

		BeforeEach(func() {
			config = config_package.New(nil)
			config.SetTarget("some-host")
			config.SetLogin("some-user", "some-password")
			origDial = sshapi.DialFunc
		})

		AfterEach(func() {
			sshapi.DialFunc = origDial
		})

		It("should create a client", func() {
			dialCalled := false
开发者ID:davidwadden,项目名称:lattice-release,代码行数:32,代码来源:dialer_test.go

示例10:

	"github.com/cloudfoundry-incubator/lattice/ltc/exit_handler/fake_exit_handler"
	"github.com/cloudfoundry-incubator/lattice/ltc/terminal"
	"github.com/cloudfoundry-incubator/lattice/ltc/test_helpers"
	"github.com/codegangsta/cli"
	"github.com/pivotal-golang/lager"

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

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

示例11:

	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/onsi/gomega/ghttp"

	config_package "github.com/cloudfoundry-incubator/lattice/ltc/config"
	"github.com/cloudfoundry-incubator/lattice/ltc/config/blob_store"
	"github.com/cloudfoundry-incubator/lattice/ltc/config/persister"
	"github.com/goamz/goamz/aws"
	"github.com/goamz/goamz/s3"
)

var _ = Describe("BlobStore", func() {
	var (
		config     *config_package.Config
		httpClient *http.Client
		blobStore  blob_store.BlobStore
		fakeServer *ghttp.Server
		awsRegion  = aws.Region{Name: "riak-region-1", S3Endpoint: "http://s3.amazonaws.com"}
	)

	BeforeEach(func() {
		fakeServer = ghttp.NewServer()
		config = config_package.New(persister.NewMemPersister())

		fakeServerURL, err := url.Parse(fakeServer.URL())
		Expect(err).NotTo(HaveOccurred())
		proxyHostArr := strings.Split(fakeServerURL.Host, ":")
		Expect(proxyHostArr).To(HaveLen(2))
		proxyHostPort, err := strconv.Atoi(proxyHostArr[1])
		Expect(err).NotTo(HaveOccurred())
		config.SetBlobTarget(proxyHostArr[0], uint16(proxyHostPort), "V8GDQFR_VDOGM55IV8OH", "Wv_kltnl98hNWNdNwyQPYnFhK4gVPTxVS3NNMg==", "buck")
开发者ID:rajkumargithub,项目名称:lattice,代码行数:31,代码来源:blob_store_test.go

示例12:

package config_test

import (
	"errors"

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

示例13:

	config_package "github.com/cloudfoundry-incubator/lattice/ltc/config"
	"github.com/cloudfoundry-incubator/lattice/ltc/secure_shell"
	"github.com/cloudfoundry-incubator/lattice/ltc/secure_shell/fake_dialer"
	"github.com/cloudfoundry-incubator/lattice/ltc/secure_shell/fake_secure_session"
	"github.com/cloudfoundry-incubator/lattice/ltc/secure_shell/fake_term"
	"github.com/pivotal-golang/clock/fakeclock"
)

var _ = Describe("SecureShell", func() {
	var (
		fakeDialer  *fake_dialer.FakeDialer
		fakeSession *fake_secure_session.FakeSecureSession
		fakeTerm    *fake_term.FakeTerm
		fakeStdin   *gbytes.Buffer
		fakeStdout  *gbytes.Buffer
		fakeStderr  *gbytes.Buffer
		fakeClock   *fakeclock.FakeClock

		config      *config_package.Config
		secureShell *secure_shell.SecureShell

		oldTerm string
	)

	BeforeEach(func() {
		fakeDialer = &fake_dialer.FakeDialer{}
		fakeSession = &fake_secure_session.FakeSecureSession{}
		fakeTerm = &fake_term.FakeTerm{}
		fakeStdin = gbytes.NewBuffer()
		fakeStdout = gbytes.NewBuffer()
		fakeStderr = gbytes.NewBuffer()
		fakeClock = fakeclock.NewFakeClock(time.Now())
开发者ID:Klaudit,项目名称:lattice,代码行数:32,代码来源:secure_shell_test.go

示例14:

	"github.com/cloudfoundry-incubator/lattice/ltc/exit_handler/fake_exit_handler"
	"github.com/cloudfoundry-incubator/lattice/ltc/terminal"
	"github.com/cloudfoundry-incubator/lattice/ltc/terminal/password_reader/fake_password_reader"
	"github.com/cloudfoundry-incubator/lattice/ltc/test_helpers"
	"github.com/codegangsta/cli"

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

var _ = Describe("CommandFactory", func() {
	var (
		stdinReader           *io.PipeReader
		stdinWriter           *io.PipeWriter
		outputBuffer          *gbytes.Buffer
		terminalUI            terminal.UI
		config                *config_package.Config
		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()
开发者ID:edwardt,项目名称:lattice,代码行数:32,代码来源:config_command_factory_test.go

示例15:

package config_test

import (
	"errors"

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

	"github.com/cloudfoundry-incubator/lattice/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() {
开发者ID:davidwadden,项目名称:lattice-release,代码行数:31,代码来源:config_test.go


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