// PrepareRenderData constructs new renderdata based on pipeline config + latest BOSH deployments data func PrepareRenderData(config *config.PipelinesConfig, db data.DeploymentsPerBOSH, filterByTag string) *RenderData { tiers := make([]*Tier, len(config.Tiers)) filterTags := filterTagsForReleaseNames(db.ReleaseNames()) renderdata := &RenderData{ Config: config, FilterTags: filterTags, Tiers: tiers, } for tierIndex, configTier := range config.Tiers { slots := make([]*Slot, len(configTier.Slots)) tiers[tierIndex] = &Tier{ Name: configTier.Name, Slots: slots, } for slotIndex, configSlot := range configTier.Slots { deployments := renderdata.DiscoverDeploymentsForSlot(db, configTier, configSlot, filterByTag) slots[slotIndex] = &Slot{ Deployments: deployments, } } } return renderdata }
package rendertemplates_test import ( "github.com/cloudfoundry-community/stannis/config" "github.com/cloudfoundry-community/stannis/data" . "github.com/cloudfoundry-community/stannis/rendertemplates" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Prepare data for templates", func() { var ( pipelineConfig *config.PipelinesConfig expectedRenderData RenderData db data.DeploymentsPerBOSH renderdata *RenderData ) BeforeEach(func() { expectedRenderData = *TestScenarioData() db = data.NewDeploymentsPerBOSH() db.FixtureBosh("../upload/fixtures/bosh-lite.json") db.FixtureDeployment("../upload/fixtures/deployment-bosh-lite-cf1.json") db.FixtureDeployment("../upload/fixtures/deployment-bosh-lite-cf2.json") db.FixtureBosh("../upload/fixtures/bosh-vsphere-sandbox.json") db.FixtureDeployment("../upload/fixtures/deployment-vsphere-sandbox-cf.json") db.FixtureBosh("../upload/fixtures/bosh-aws-production.json") db.FixtureDeployment("../upload/fixtures/deployment-aws-production-cf.json")