本文整理匯總了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{}
}
示例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")
}
示例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
}
示例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())
}
示例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
}
示例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
}
示例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)
})
示例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())
})
示例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
示例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"
})
示例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")
示例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"))
})
})
示例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())
示例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()
示例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() {