Ejemplo n.º 1
0
func mapToAppSet(basePath string, data generic.Map) (appSet []models.AppParams, errs ManifestErrors) {
	if data.Has("applications") {
		appMaps, ok := data.Get("applications").([]interface{})
		if !ok {
			errs = append(errs, errors.New("Expected applications to be a list"))
			return
		}

		// we delete applications so that we may merge top level app params into each app
		data.Delete("applications")

		for _, appData := range appMaps {
			if !generic.IsMappable(appData) {
				errs = append(errs, errors.New("Expected application to be a dictionary"))
				continue
			}

			appMap := generic.DeepMerge(data, generic.NewMap(appData))

			appParams, appErrs := mapToAppParams(basePath, appMap)
			if !appErrs.Empty() {
				errs = append(errs, appErrs)
				continue
			}

			appSet = append(appSet, appParams)
		}
	}

	return
}
Ejemplo n.º 2
0
			{"Binding", "my-new-app.shared.cf-app.com"},
			{"OK"},
			{"Uploading my-new-app"},
			{"OK"},
		})
	})

	Describe("randomized hostnames", func() {
		var manifestApp generic.Map

		BeforeEach(func() {
			appRepo.ReadNotFound = true

			manifest := singleAppManifest()
			manifestApp = manifest.Data.Get("applications").([]interface{})[0].(generic.Map)
			manifestApp.Delete("host")
			manifestRepo.ReadManifestReturns.Manifest = manifest
		})

		It("provides a random hostname when the --random-route flag is passed", func() {
			callPush("--random-route", "my-new-app")
			Expect(routeRepo.FindByHostAndDomainHost).To(Equal("my-new-app-laughing-cow"))
		})

		It("provides a random hostname when the random-route option is set in the manifest", func() {
			manifestApp.Set("random-route", true)

			callPush("my-new-app")

			Expect(routeRepo.FindByHostAndDomainHost).To(Equal("my-new-app-laughing-cow"))
		})