Esempio n. 1
0
func (a AWSDeployer) replaceUUID(manifestFilename string) (map[string]interface{}, error) {
	directorUUID, err := a.bosh.UUID()
	if err != nil {
		return nil, err
	}

	manifest, err := manifests.ReadManifest(manifestFilename)
	if err != nil {
		return nil, err
	}

	manifest["director_uuid"] = directorUUID

	return manifest, nil
}
Esempio n. 2
0
var _ = Describe("manifests", func() {
	var (
		manifestsDirectory string
		err                error
	)

	BeforeEach(func() {
		manifestsDirectory, err = ioutil.TempDir("", "")
		Expect(err).NotTo(HaveOccurred())
	})

	Describe("ReadManifest", func() {
		It("returns the manifest as a map", func() {
			writeManifest(manifestsDirectory, "manifest.yml")

			manifestMap, err := manifests.ReadManifest(filepath.Join(manifestsDirectory, "manifest.yml"))
			Expect(err).NotTo(HaveOccurred())
			Expect(manifestMap["director_uuid"]).To(Equal("BOSH-DIRECTOR-UUID"))
		})

		Context("failure cases", func() {
			It("returns an error when given invalid yaml", func() {
				manifestFile := filepath.Join(manifestsDirectory, "invalid_manifest.yml")
				err := ioutil.WriteFile(manifestFile, []byte("not: valid: yaml:"), os.ModePerm)
				Expect(err).NotTo(HaveOccurred())

				_, err = manifests.ReadManifest(manifestFile)
				Expect(err.Error()).To(ContainSubstring("mapping values are not allowed in this context"))
			})

			It("returns an error when the file doesn't exist", func() {