Ejemplo n.º 1
0
func checkIfPlanidExist(client osclient.Interface, planId string) (bool, *backingserviceapi.BackingService, error) {

	items, err := client.BackingServices("openshift").List(kapi.ListOptions{})

	if err != nil {
		return false, nil, err
	}

	for _, bs := range items.Items {
		for _, plans := range bs.Spec.Plans {
			if planId == plans.Id {
				glog.Info("we found plan id at plan", bs.Spec.Name)

				return true, &bs, nil
			}
		}
	}
	return false, nil, fatalError(fmt.Sprintf("Can't find plan id %s", planId))

}
func backingServiceHandler(client osclient.Interface, backingService *backingserviceapi.BackingService) error {
	newBs, err := client.BackingServices(backingserviceapi.BSNS).Get(backingService.Name)
	if err != nil {
		if errors.IsNotFound(err) {
			if _, err := client.BackingServices(backingserviceapi.BSNS).Create(backingService); err != nil {
				glog.Errorln("servicebroker create backingservice err ", err)
				return err
			}
		}
	} else {
		newBs.Status.Phase = backingserviceapi.BackingServicePhaseActive
		if _, err := client.BackingServices(backingserviceapi.BSNS).Update(newBs); err != nil {
			glog.Errorln("servicebroker update backingservice err ", err)
			return err
		}
	}

	return nil
}