// newFakeServiceCatalogClientForTest creates a fake clientset that returns a
// ClusterServiceClassList with the given ClusterServiceClass as the single list item
// and list of ClusterServicePlan objects.
// If classFilter is provided (as in not ""), then only sps with the
// Spec.ClusterServiceClassRef.Name equaling that string will be added to the list.
newFakeServiceCatalogClientForTest creates a fake clientset that returns a
ClusterServiceClassList with the given ClusterServiceClass as the single list item
and list of ClusterServicePlan objects.
If classFilter is provided (as in not ""), then only sps with the
Spec.ClusterServiceClassRef.Name equaling that string will be added to the list.
// newFakeServiceCatalogClientForTest creates a fake clientset that returns a // ClusterServiceClassList with the given ClusterServiceClass as the single list item // and list of ClusterServicePlan objects . // If classFilter is provided ( as in not " " ) then only sps with the // Spec . ClusterServiceClassRef . Name equaling that string will be added to the list .
func newFakeServiceCatalogClientForTest(sc *servicecatalog.ClusterServiceClass, sps []*servicecatalog.ClusterServicePlan, classFilter string) *fake.Clientset {
	fakeClient := &fake.Clientset{}
	fakeClient.AddReactor("get", "clusterserviceclasses", func(action core.Action) (bool, runtime.Object, error) {
		if sc != nil {
			return true, sc, nil
		}
		return true, nil, apierrors.NewNotFound(schema.GroupResource{}, "")
	})
	scList := &servicecatalog.ClusterServiceClassList{
		ListMeta: metav1.ListMeta{
			ResourceVersion: "1",
		}}
	if sc != nil {
		scList.Items = append(scList.Items, *sc)
	}
	fakeClient.AddReactor("list", "clusterserviceclasses", func(action core.Action) (bool, runtime.Object, error) {
		return true, scList, nil
	})
	spList := &servicecatalog.ClusterServicePlanList{
		ListMeta: metav1.ListMeta{
			ResourceVersion: "1",
		}}
	for _, sp := range sps {
		if classFilter == "" || classFilter == sp.Spec.ClusterServiceClassRef.Name {
			spList.Items = append(spList.Items, *sp)
		}
	}
	fakeClient.AddReactor("list", "clusterserviceplans", func(action core.Action) (bool, runtime.Object, error) {
		return true, spList, nil
	})
	return fakeClient
}
func newFakeServiceCatalogClientForTest ( sc * servicecatalog . ClusterServiceClass , sps [ ] * servicecatalog . ClusterServicePlan , classFilter string ) * fake . Clientset { fakeClient := & fake . Clientset { } fakeClient . AddReactor ( " " , " " , func ( action core . Action ) ( bool , runtime . Object , error ) { if sc != nil { return true , sc , nil } return true , nil , apierrors . NewNotFound ( schema . GroupResource { } , " " ) } ) scList := & servicecatalog . ClusterServiceClassList { ListMeta : metav1 . ListMeta { ResourceVersion : " " , } } if sc != nil { scList . Items = append ( scList . Items , * sc ) } fakeClient . AddReactor ( " " , " " , func ( action core . Action ) ( bool , runtime . Object , error ) { return true , scList , nil } ) spList := & servicecatalog . ClusterServicePlanList { ListMeta : metav1 . ListMeta { ResourceVersion : " " , } } for _ , sp := range sps { if classFilter == " " || classFilter == sp . Spec . ClusterServiceClassRef . Name { spList . Items = append ( spList . Items , * sp ) } } fakeClient . AddReactor ( " " , " " , func ( action core . Action ) ( bool , runtime . Object , error ) { return true , spList , nil } ) return fakeClient }
newFakeServiceCatalogClientForTest creates a fake clientset that returns a
ClusterServiceClassList with the given ClusterServiceClass as the single list item
and list of ClusterServicePlan objects.
newFakeServiceCatalogClientForTest creates a fake clientset that returns a ClusterServiceClassList with the given ClusterServiceClass as the single list item and list of ClusterServicePlan objects .
// react to the given service class list and to gets // react to the given plans