示例#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("SubnetChecker", func() {
	var (
		manifestsDirectory string
		fakeAWS            *fakes.AWS
		subnetChecker      subnetchecker.SubnetChecker
	)

	BeforeEach(func() {
		fakeAWS = new(fakes.AWS)

		var err error
		manifestsDirectory, err = ioutil.TempDir("", "")
		Expect(err).NotTo(HaveOccurred())
		subnetChecker = subnetchecker.NewSubnetChecker(fakeAWS)
	})

	It("returns true if all subnets in manifest exist on AWS", func() {
		const manifestWithSubnets1And2 = `---
director_uuid: BOSH-DIRECTOR-UUID

name: multi-az-ssl

networks:
- subnets:
  - cloud_properties:
      subnet: "subnet-1"
    range: 10.0.20.0/24
- subnets:
  - cloud_properties: