Beispiel #1
0
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)
}
var _ = Describe("AWSDeployer", func() {
	Describe("Deploy", func() {
		var (
			fakeBOSH          *fakes.BOSH
			fakeSubnetChecker *fakes.SubnetChecker
			awsDeployer       awsdeployer.AWSDeployer
			stdout            io.Writer
		)

		BeforeEach(func() {
			fakeBOSH = &fakes.BOSH{}
			fakeSubnetChecker = &fakes.SubnetChecker{}
			stdout = ioutil.Discard

			awsDeployer = awsdeployer.NewAWSDeployer(clients.NewBOSH(fakeBOSH, stdout), fakeSubnetChecker, stdout)
			fakeSubnetChecker.CheckSubnetsCall.Returns.Bool = true
		})

		It("deploys specified bosh manifest", func() {
			manifestFilename := createManifestFile("director_uuid: BOSH-DIRECTOR-UUID\nname: deployment-1")

			deploymentError := awsDeployer.Deploy(manifestFilename)
			Expect(deploymentError).NotTo(HaveOccurred())

			Expect(fakeBOSH.DeployCall.CallCount).To(Equal(1))
			Expect(fakeBOSH.DeployCall.Receives.Manifest).To(ContainSubstring("deployment-1"))
		})

		It("replaces the bosh director uuid before deploying each manifest", func() {
			manifestFilename := createBasicManifestFile()
Beispiel #3
0
	"io/ioutil"

	"github.com/cloudfoundry/mega-ci/scripts/ci/deploy-aws-manifests/clients"
	"github.com/cloudfoundry/mega-ci/scripts/ci/deploy-aws-manifests/fakes"
	"github.com/pivotal-cf-experimental/bosh-test/bosh"

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

var _ = Describe("BOSH", func() {
	Describe("Deploy", func() {
		It("deploys a given manifest", func() {
			boshClient := &fakes.BOSH{}
			logger := bytes.NewBuffer([]byte{})
			client := clients.NewBOSH(boshClient, logger)
			boshClient.DeployCall.Returns.TaskId = 1
			boshClient.GetTaskOutputCall.Returns.TaskOutputs = []bosh.TaskOutput{
				{
					Time:     1457571106,
					Stage:    "some-stage",
					Task:     "some-task",
					State:    "some-state",
					Progress: 0,
				},
			}

			manifest := []byte("some-manifest")
			err := client.Deploy(manifest)
			Expect(err).NotTo(HaveOccurred())
			Expect(boshClient.DeployCall.Receives.Manifest).To(Equal([]byte("some-manifest")))