Example #1
0
func init() {
	m = martini.New()

	envEnvironment := os.Getenv("ENVIRONMENT")

	if envEnvironment == "" {
		envEnvironment = "development"
	}

	brokerConfig, _ = config.ParseFromYAMLFile(envEnvironment, "config/config.yml")
	b, _ = sqlbroker.New(brokerConfig)

	if brokerConfig.CFCCTarget != "" &&
		brokerConfig.CFUAATarget != "" &&
		brokerConfig.CFUser != "" &&
		brokerConfig.CFPassword != "" {

		registerCFServices = true
		var err error
		cfs, err = cfservices.New(brokerConfig.CFCCTarget, brokerConfig.CFUAATarget, brokerConfig.CFUser, brokerConfig.CFPassword)
		if err != nil {
			fmt.Println("Cannot connect to CF Services. - " + err.Error())
		}
	}

	m.Use(martini.Recovery())
	m.Use(martini.Logger())

	r := martini.NewRouter()
	r.Get(`/v2/catalog`, GetCatalog)
	r.Put(`/v2/service_instances/:id`, Provision)
	r.Delete(`/v2/service_instances/:id`, Deprovision)
	r.Put(`/v2/service_instances/:instance_id/service_bindings/:id`, Bind)
	r.Delete(`/v2/service_instances/:instance_id/service_bindings/:id`, Unbind)
	r.Put(`/v2/services/:service_id/plans`, AddPlan)
	r.Delete(`/v2/services/:service_id/plans/:plan_id`, DeletePlan)

	m.Action(r.Handle)
}
func (t *CFServicesTestSuite) SetUpSuite(c *gocheck.C) {
	testConfig, _ = config.ParseFromYAMLFile("development", "../config/config.yml")
}
func (t *ServiceBindingTestSuite) SetUpSuite(c *gocheck.C) {
	testConfig, _ = config.ParseFromYAMLFile("development", "../config/config.yml")
	testDBConnection, _ = db.New(testConfig.Services[0].Plans[0].MgmtDbUri)
	testServiceBindingUUID = "29cddf68-4024-45fd-b876-c5c5d5a8d6d2"
	testServiceBinding, _ = New(testServiceBindingUUID, testDBConnection)
}
func (t *ServiceInstanceTestSuite) SetUpSuite(c *gocheck.C) {
	testConfig, _ := config.ParseFromYAMLFile("development", "../config/config.yml")
	testDBConnection, _ = db.New(testConfig.Services[0].Plans[0].MgmtDbUri)
	testServiceInstanceUUID = "290b73fa-56bd-433e-81e4-460f698c0d45"
	testServiceInstance, _ = New(testServiceInstanceUUID, testDBConnection)
}
func (t *BrokerTestSuite) SetUpSuite(c *gocheck.C) {
	testConfig, _ = config.ParseFromYAMLFile("development", "../config/config.yml")
	testBroker, _ = New(testConfig)
	testCatalog = testBroker.GetCatalog()
}