func loadServiceBindings() map[string]*model.ServiceBinding { var bindingMap map[string]*model.ServiceBinding err := utils.ReadAndUnmarshal(&bindingMap, conf.DataPath, conf.ServiceBindingsFileName) if err != nil { fmt.Printf("WARNING: key map data file '%s' does not exist: \n", conf.ServiceBindingsFileName) bindingMap = make(map[string]*model.ServiceBinding) } return bindingMap }
// private methods func loadServiceInstances() map[string]*model.ServiceInstance { var serviceInstancesMap map[string]*model.ServiceInstance err := utils.ReadAndUnmarshal(&serviceInstancesMap, conf.DataPath, conf.ServiceInstancesFileName) if err != nil && os.IsNotExist(err) { fmt.Printf("WARNING: service instance data file '%s' does not exist: \n", conf.ServiceInstancesFileName) serviceInstancesMap = make(map[string]*model.ServiceInstance) } return serviceInstancesMap }
func (c *Controller) Catalog(w http.ResponseWriter, r *http.Request) { fmt.Println("Get Service Broker Catalog...") var catalog model.Catalog err := utils.ReadAndUnmarshal(&catalog, conf.CatalogPath, "catalog.json") if err != nil { w.WriteHeader(http.StatusInternalServerError) return } utils.WriteResponse(w, http.StatusOK, catalog) }
func loadServiceBindings() (map[string]*model.ServiceBinding, error) { var bindingMap map[string]*model.ServiceBinding err := utils.ReadAndUnmarshal(&bindingMap, conf.DataPath, conf.ServiceBindingsFileName) if err != nil { if os.IsNotExist(err) { fmt.Printf("WARNING: key map data file '%s' does not exist: \n", conf.ServiceBindingsFileName) bindingMap = make(map[string]*model.ServiceBinding) } else { return nil, errors.New(fmt.Sprintf("Could not load the service instances, message: %s", err.Error())) } } return bindingMap, nil }
func (c *Controller) Catalog(w http.ResponseWriter, r *http.Request) { fmt.Println("Get Service Broker Catalog...") var catalog model.Catalog catalogFileName := "catalog.json" if c.cloudName == utils.AWS { catalogFileName = "catalog.AWS.json" } else if c.cloudName == utils.SOFTLAYER || c.cloudName == utils.SL { catalogFileName = "catalog.SoftLayer.json" } err := utils.ReadAndUnmarshal(&catalog, conf.CatalogPath, catalogFileName) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } utils.WriteResponse(w, http.StatusOK, catalog) }