本文整理汇总了Golang中github.com/pivotal-cf-experimental/bosh-test/bosh.NewClient函数的典型用法代码示例。如果您正苦于以下问题:Golang NewClient函数的具体用法?Golang NewClient怎么用?Golang NewClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewClient函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
configuration, err := flags.ParseFlags(os.Args[1:])
if err != nil {
fmt.Fprintf(os.Stderr, "\n\n%s\n", err)
os.Exit(1)
}
boshConfig := bosh.Config{
URL: configuration.BoshDirector,
Password: configuration.BoshPassword,
Username: configuration.BoshUser,
AllowInsecureSSL: true,
}
aws := clients.NewAWS(configuration.AWSAccessKeyID, configuration.AWSSecretAccessKey,
configuration.AWSRegion, configuration.AWSEndpointOverride)
bosh := clients.NewBOSH(bosh.NewClient(boshConfig), os.Stdout)
subnetChecker := subnetchecker.NewSubnetChecker(aws)
awsDeployer := awsdeployer.NewAWSDeployer(bosh, subnetChecker, os.Stdout)
err = awsDeployer.Deploy(configuration.ManifestPath)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\n%s\n", err)
os.Exit(1)
}
os.Exit(0)
}
开发者ID:cloudfoundry,项目名称:mega-ci,代码行数:29,代码来源:main.go
示例2:
username, password, ok := r.BasicAuth()
Expect(ok).To(BeTrue())
Expect(username).To(Equal("some-username"))
Expect(password).To(Equal("some-password"))
rawBody, err := ioutil.ReadAll(r.Body)
Expect(err).NotTo(HaveOccurred())
Expect(string(rawBody)).To(Equal(cloudConfig))
w.WriteHeader(http.StatusCreated)
}))
client := bosh.NewClient(bosh.Config{
URL: testServer.URL,
Username: "some-username",
Password: "some-password",
})
err := client.UpdateCloudConfig([]byte(cloudConfig))
Expect(err).NotTo(HaveOccurred())
Expect(testServerCallCount).To(Equal(1))
})
Context("failure cases", func() {
It("returns an error when request creation fails", func() {
client := bosh.NewClient(bosh.Config{
URL: "%%%%%",
})
开发者ID:pivotal-cf-experimental,项目名称:bosh-test,代码行数:30,代码来源:update_cloud_config_test.go
示例3: TestDeploy
func TestDeploy(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "turbulence")
}
var _ = BeforeSuite(func() {
configPath, err := helpers.ConfigPath()
Expect(err).NotTo(HaveOccurred())
config, err = helpers.LoadConfig(configPath)
Expect(err).NotTo(HaveOccurred())
consulReleaseVersion = helpers.ConsulReleaseVersion()
boshClient = bosh.NewClient(bosh.Config{
URL: fmt.Sprintf("https://%s:25555", config.BOSH.Target),
Username: config.BOSH.Username,
Password: config.BOSH.Password,
AllowInsecureSSL: true,
})
})
func lockedDeployments() ([]string, error) {
var lockNames []string
locks, err := boshClient.Locks()
if err != nil {
return []string{}, err
}
for _, lock := range locks {
lockNames = append(lockNames, lock.Resource[0])
}
return lockNames, nil
}
开发者ID:cloudfoundry-incubator,项目名称:consul-release,代码行数:32,代码来源:init_test.go
示例4:
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
serverCallCount++
Expect(r.URL.Path).To(Equal("/locks"))
Expect(r.Method).To(Equal("GET"))
username, password, ok := r.BasicAuth()
Expect(ok).To(BeTrue())
Expect(username).To(Equal("some-username"))
Expect(password).To(Equal("some-password"))
w.Write([]byte(`[{"type":"deployment","resource":["some-deployment"],"timeout":"1475796348.793560"}]`))
}))
client = bosh.NewClient(bosh.Config{
URL: server.URL,
Username: "some-username",
Password: "some-password",
})
locks, err := client.Locks()
Expect(err).NotTo(HaveOccurred())
Expect(serverCallCount).To(Equal(1))
Expect(locks).To(Equal([]bosh.Lock{
{Type: "deployment", Resource: []string{"some-deployment"}, Timeout: "1475796348.793560"},
}))
})
Context("failure cases", func() {
It("returns an error when url is invalid", func() {
client := bosh.NewClient(bosh.Config{
开发者ID:pivotal-cf-experimental,项目名称:bosh-test,代码行数:31,代码来源:locks_test.go
示例5:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Info", func() {
It("fetches the director info", func() {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expect(r.URL.Path).To(Equal("/info"))
Expect(r.Method).To(Equal("GET"))
w.Write([]byte(`{"uuid":"some-director-uuid", "cpi":"some-cpi"}`))
}))
client := bosh.NewClient(bosh.Config{
URL: server.URL,
TaskPollingInterval: time.Nanosecond,
})
info, err := client.Info()
Expect(err).NotTo(HaveOccurred())
Expect(info).To(Equal(bosh.DirectorInfo{
UUID: "some-director-uuid",
CPI: "some-cpi",
}))
})
Context("failure cases", func() {
It("should error on malformed json", func() {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`&&%%%%%&%&%&%&%&%&%&%&`))
开发者ID:pivotal-cf-experimental,项目名称:bosh-test,代码行数:31,代码来源:info_test.go
示例6:
})
It("is able to deploy concourse", func() {
bbl.Up()
certPath, err := testhelpers.WriteContentsToTempFile(testhelpers.BBL_CERT)
Expect(err).NotTo(HaveOccurred())
keyPath, err := testhelpers.WriteContentsToTempFile(testhelpers.BBL_KEY)
Expect(err).NotTo(HaveOccurred())
bbl.CreateLB("concourse", certPath, keyPath, "")
boshClient := bosh.NewClient(bosh.Config{
URL: bbl.DirectorAddress(),
Username: bbl.DirectorUsername(),
Password: bbl.DirectorPassword(),
AllowInsecureSSL: true,
})
err = downloadAndUploadRelease(boshClient, ConcourseReleaseURL)
Expect(err).NotTo(HaveOccurred())
err = downloadAndUploadRelease(boshClient, GardenReleaseURL)
Expect(err).NotTo(HaveOccurred())
err = downloadAndUploadStemcell(boshClient, StemcellURL)
Expect(err).NotTo(HaveOccurred())
concourseExampleManifest, err := downloadConcourseExampleManifest()
Expect(err).NotTo(HaveOccurred())
开发者ID:pivotal-cf-experimental,项目名称:bosh-bootloader,代码行数:31,代码来源:deploy_test.go
示例7:
Expect(taskCallCount).NotTo(Equal(0))
w.Write([]byte(`
{"index": 0, "job_name": "consul_z1", "job_state":"some-state", "ips": ["1.2.3.4"]}
{"index": 0, "job_name": "etcd_z1", "job_state":"some-state", "ips": ["1.2.3.5"]}
{"index": 1, "job_name": "etcd_z1", "job_state":"some-other-state", "ips": ["1.2.3.6"]}
{"index": 2, "job_name": "etcd_z1", "job_state":"some-more-state", "ips": ["1.2.3.7"]}
`))
default:
Fail("unknown route")
}
}))
client := bosh.NewClient(bosh.Config{
URL: server.URL,
Username: "some-username",
Password: "some-password",
})
vms, err := client.DeploymentVMs("some-deployment-name")
Expect(err).NotTo(HaveOccurred())
Expect(vms).To(ConsistOf([]bosh.VM{
{
Index: 0,
JobName: "consul_z1",
State: "some-state",
IPs: []string{"1.2.3.4"},
},
{
Index: 0,
JobName: "etcd_z1",
开发者ID:pivotal-cf-experimental,项目名称:bosh-test,代码行数:31,代码来源:deployment_vms_test.go
示例8:
Expect(r.Method).To(Equal("GET"))
w.Write([]byte(`{"versions":["2.0.0","3.0.0","4.0.0"]}`))
case "/stemcells":
Expect(r.Method).To(Equal("GET"))
w.Write([]byte(`[
{"name": "some-stemcell-name","version": "1"},
{"name": "some-stemcell-name","version": "2"},
{"name": "some-other-stemcell-name","version": "100"}
]`))
default:
Fail("unexpected route")
}
}))
client = bosh.NewClient(bosh.Config{
URL: server.URL,
Username: "some-username",
Password: "some-password",
TaskPollingInterval: time.Nanosecond,
})
})
It("resolves manifest-v2 latest version of releases", func() {
manifest := `---
director_uuid: some-director-uuid
name: some-name
stemcells:
- alias: default
name: some-stemcell-name
version: latest
instance_groups:
- azs:
- z1
开发者ID:pivotal-cf-experimental,项目名称:bosh-test,代码行数:32,代码来源:resolve_manifest_versions_test.go
示例9:
Expect(password).To(Equal("some-password"))
if callCount == 3 {
w.Write([]byte(`{"id": 1, "state": "done"}`))
} else {
w.Write([]byte(`{"id": 1, "state": "processing"}`))
}
callCount++
default:
Fail("could not match any URL endpoints")
}
}))
client := bosh.NewClient(bosh.Config{
URL: server.URL,
Username: "some-username",
Password: "some-password",
TaskPollingInterval: time.Nanosecond,
})
taskId, err := client.Deploy([]byte("some-yaml"))
Expect(err).NotTo(HaveOccurred())
Expect(callCount).To(Equal(4))
Expect(taskId).To(Equal(1))
})
Context("failure cases", func() {
It("should error on a non 302 redirect response with a body", func() {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/deployments":
开发者ID:pivotal-cf-experimental,项目名称:bosh-test,代码行数:32,代码来源:deploy_test.go
注:本文中的github.com/pivotal-cf-experimental/bosh-test/bosh.NewClient函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论