Example #1
0
func (repo *FakeBuildpackRepository) ListBuildpacks(stop chan bool) (buildpacksChan chan []cf.Buildpack, statusChan chan net.ApiResponse) {
	buildpacksChan = make(chan []cf.Buildpack, 4)
	statusChan = make(chan net.ApiResponse, 1)

	go func() {
		buildpackCount := len(repo.Buildpacks)
		for i := 0; i < buildpackCount; i += 2 {
			select {
			case <-stop:
				break
			default:
				if buildpackCount-i > 1 {
					buildpacksChan <- repo.Buildpacks[i : i+2]
				} else {
					buildpacksChan <- repo.Buildpacks[i:]
				}
			}
		}

		close(buildpacksChan)
		close(statusChan)

		cf.WaitForClose(stop)
	}()

	return
}
Example #2
0
func (repo FakeOrgRepository) ListOrgs(stop chan bool) (orgsChan chan []cf.Organization, statusChan chan net.ApiResponse) {
	orgsChan = make(chan []cf.Organization, 4)
	statusChan = make(chan net.ApiResponse, 1)

	go func() {
		orgsCount := len(repo.Organizations)
		for i := 0; i < orgsCount; i += 2 {
			select {
			case <-stop:
				break
			default:
				if orgsCount-i > 1 {
					orgsChan <- repo.Organizations[i : i+2]
				} else {
					orgsChan <- repo.Organizations[i:]
				}
			}
		}

		close(orgsChan)
		close(statusChan)

		cf.WaitForClose(stop)
	}()

	return
}
Example #3
0
func (repo *FakeUserRepository) listUsersForRole(roleName string, stop chan bool) (usersChan chan []cf.UserFields, statusChan chan net.ApiResponse) {
	usersChan = make(chan []cf.UserFields, 4)
	statusChan = make(chan net.ApiResponse, 1)

	go func() {
		usersCount := len(repo.ListUsersByRole[roleName])
		for i := 0; i < usersCount; i += 2 {
			select {
			case <-stop:
				break
			default:
				if usersCount-i > 1 {
					usersChan <- repo.ListUsersByRole[roleName][i : i+2]
				} else {
					usersChan <- repo.ListUsersByRole[roleName][i:]
				}
			}
		}

		close(usersChan)
		close(statusChan)

		cf.WaitForClose(stop)
	}()

	return
}
Example #4
0
func (repo *FakeDomainRepository) ListDomainsForOrg(orgGuid string, stop chan bool) (domainsChan chan []cf.Domain, statusChan chan net.ApiResponse) {
	repo.ListDomainsForOrgDomainsGuid = orgGuid

	domainsChan = make(chan []cf.Domain, 4)
	statusChan = make(chan net.ApiResponse, 1)

	go func() {
		domainsCount := len(repo.ListDomainsForOrgDomains)
		for i := 0; i < domainsCount; i += 2 {
			select {
			case <-stop:
				break
			default:
				if domainsCount-i > 1 {
					domainsChan <- repo.ListDomainsForOrgDomains[i : i+2]
				} else {
					domainsChan <- repo.ListDomainsForOrgDomains[i:]
				}
			}
		}

		close(domainsChan)
		close(statusChan)

		cf.WaitForClose(stop)
	}()

	return
}
Example #5
0
func (repo FakeSpaceRepository) ListSpaces(stop chan bool) (spacesChan chan []cf.Space, statusChan chan net.ApiResponse) {
	spacesChan = make(chan []cf.Space, 4)
	statusChan = make(chan net.ApiResponse, 1)

	go func() {
		spacesCount := len(repo.Spaces)
		for i := 0; i < spacesCount; i += 2 {
			select {
			case <-stop:
				break
			default:
				if spacesCount-i > 1 {
					spacesChan <- repo.Spaces[i : i+2]
				} else {
					spacesChan <- repo.Spaces[i:]
				}
			}
		}

		close(spacesChan)
		close(statusChan)

		cf.WaitForClose(stop)
	}()

	return
}
Example #6
0
func (repo *FakeRouteRepository) ListRoutes(stop chan bool) (routesChan chan []cf.Route, statusChan chan net.ApiResponse) {
	routesChan = make(chan []cf.Route, 4)
	statusChan = make(chan net.ApiResponse, 1)

	if repo.ListErr {
		statusChan <- net.NewApiResponseWithMessage("Error finding all routes")
		close(routesChan)
		close(statusChan)
		return
	}

	go func() {
		routesCount := len(repo.Routes)
		for i := 0; i < routesCount; i += 2 {
			select {
			case <-stop:
				break
			default:
				if routesCount-i > 1 {
					routesChan <- repo.Routes[i : i+2]
				} else {
					routesChan <- repo.Routes[i:]
				}
			}
		}

		close(routesChan)
		close(statusChan)

		cf.WaitForClose(stop)
	}()

	return
}
Example #7
0
func (repo *FakeServiceBrokerRepo) ListServiceBrokers(stop chan bool) (serviceBrokersChan chan []cf.ServiceBroker, statusChan chan net.ApiResponse) {
	serviceBrokersChan = make(chan []cf.ServiceBroker, 4)
	statusChan = make(chan net.ApiResponse, 1)

	if repo.ListErr {
		statusChan <- net.NewApiResponseWithMessage("Error finding all routes")
		close(serviceBrokersChan)
		close(statusChan)
		return
	}

	go func() {
		serviceBrokersCount := len(repo.ServiceBrokers)
		for i := 0; i < serviceBrokersCount; i += 2 {
			select {
			case <-stop:
				break
			default:
				if serviceBrokersCount-i > 1 {
					serviceBrokersChan <- repo.ServiceBrokers[i : i+2]
				} else {
					serviceBrokersChan <- repo.ServiceBrokers[i:]
				}
			}
		}

		close(serviceBrokersChan)
		close(statusChan)

		cf.WaitForClose(stop)
	}()

	return
}
Example #8
0
func (repo CloudControllerDomainRepository) ListDomainsForOrg(orgGuid string, stop chan bool) (domainsChan chan []cf.Domain, statusChan chan net.ApiResponse) {
	domainsChan = make(chan []cf.Domain, 4)
	statusChan = make(chan net.ApiResponse, 1)

	go func() {
		path := "/v2/domains?inline-relations-depth=1"
	loop:
		for path != "" {
			select {
			case <-stop:
				break loop
			default:
				var (
					allDomains      []cf.Domain
					domainsToReturn []cf.Domain
					apiResponse     net.ApiResponse
				)

				allDomains, path, apiResponse = repo.findNextWithPath(path)
				if apiResponse.IsNotSuccessful() {
					statusChan <- apiResponse
					close(domainsChan)
					close(statusChan)
					return
				}

				for _, d := range allDomains {
					if repo.isOrgDomain(orgGuid, d.DomainFields) {
						domainsToReturn = append(domainsToReturn, d)
					}
				}

				if len(domainsToReturn) > 0 {
					domainsChan <- domainsToReturn
				}
			}
		}
		close(domainsChan)
		close(statusChan)
		cf.WaitForClose(stop)
	}()

	return
}
Example #9
0
func (repo CloudControllerServiceBrokerRepository) ListServiceBrokers(stop chan bool) (serviceBrokersChan chan []cf.ServiceBroker, statusChan chan net.ApiResponse) {
	serviceBrokersChan = make(chan []cf.ServiceBroker, 4)
	statusChan = make(chan net.ApiResponse, 1)

	go func() {
		path := "/v2/service_brokers"

	loop:
		for path != "" {
			select {
			case <-stop:
				break loop
			default:
				var (
					serviceBrokers []cf.ServiceBroker
					apiResponse    net.ApiResponse
				)
				serviceBrokers, path, apiResponse = repo.findNextWithPath(path)
				if apiResponse.IsNotSuccessful() {
					statusChan <- apiResponse
					close(serviceBrokersChan)
					close(statusChan)
					return
				}

				if len(serviceBrokers) > 0 {
					serviceBrokersChan <- serviceBrokers
				}
			}
		}
		close(serviceBrokersChan)
		close(statusChan)
		cf.WaitForClose(stop)
	}()

	return
}
Example #10
0
File: routes.go Project: nsnt/cli
func (repo CloudControllerRouteRepository) ListRoutes(stop chan bool) (routesChan chan []cf.Route, statusChan chan net.ApiResponse) {
	routesChan = make(chan []cf.Route, 4)
	statusChan = make(chan net.ApiResponse, 1)

	go func() {
		path := fmt.Sprintf("/v2/routes?inline-relations-depth=1")

	loop:
		for path != "" {
			select {
			case <-stop:
				break loop
			default:
				var (
					routes      []cf.Route
					apiResponse net.ApiResponse
				)
				routes, path, apiResponse = repo.findNextWithPath(path)
				if apiResponse.IsNotSuccessful() {
					statusChan <- apiResponse
					close(routesChan)
					close(statusChan)
					return
				}

				if len(routes) > 0 {
					routesChan <- routes
				}
			}
		}
		close(routesChan)
		close(statusChan)
		cf.WaitForClose(stop)
	}()

	return
}
Example #11
0
func (repo CloudControllerBuildpackRepository) ListBuildpacks(stop chan bool) (buildpacksChan chan []cf.Buildpack, statusChan chan net.ApiResponse) {
	buildpacksChan = make(chan []cf.Buildpack, 4)
	statusChan = make(chan net.ApiResponse, 1)

	go func() {
		path := buildpacks_path

	loop:
		for path != "" {
			select {
			case <-stop:
				break loop
			default:
				var (
					buildpacks  []cf.Buildpack
					apiResponse net.ApiResponse
				)
				buildpacks, path, apiResponse = repo.findNextWithPath(path)
				if apiResponse.IsNotSuccessful() {
					statusChan <- apiResponse
					close(buildpacksChan)
					close(statusChan)
					return
				}

				if len(buildpacks) > 0 {
					buildpacksChan <- buildpacks
				}
			}
		}
		close(buildpacksChan)
		close(statusChan)
		cf.WaitForClose(stop)
	}()

	return
}
Example #12
0
File: spaces.go Project: nsnt/cli
func (repo CloudControllerSpaceRepository) ListSpaces(stop chan bool) (spacesChan chan []cf.Space, statusChan chan net.ApiResponse) {
	spacesChan = make(chan []cf.Space, 4)
	statusChan = make(chan net.ApiResponse, 1)

	go func() {
		path := fmt.Sprintf("/v2/organizations/%s/spaces", repo.config.OrganizationFields.Guid)

	loop:
		for path != "" {
			select {
			case <-stop:
				break loop
			default:
				var (
					spaces      []cf.Space
					apiResponse net.ApiResponse
				)
				spaces, path, apiResponse = repo.findNextWithPath(path)
				if apiResponse.IsNotSuccessful() {
					statusChan <- apiResponse
					close(spacesChan)
					close(statusChan)
					return
				}

				if len(spaces) > 0 {
					spacesChan <- spaces
				}
			}
		}
		close(spacesChan)
		close(statusChan)
		cf.WaitForClose(stop)
	}()

	return
}
Example #13
0
func (repo CloudControllerOrganizationRepository) ListOrgs(stop chan bool) (orgsChan chan []cf.Organization, statusChan chan net.ApiResponse) {
	orgsChan = make(chan []cf.Organization, 4)
	statusChan = make(chan net.ApiResponse, 1)

	go func() {
		path := "/v2/organizations"

	loop:
		for path != "" {
			select {
			case <-stop:
				break loop
			default:
				var (
					organizations []cf.Organization
					apiResponse   net.ApiResponse
				)
				organizations, path, apiResponse = repo.findNextWithPath(path)
				if apiResponse.IsNotSuccessful() {
					statusChan <- apiResponse
					close(orgsChan)
					close(statusChan)
					return
				}

				if len(organizations) > 0 {
					orgsChan <- organizations
				}
			}
		}
		close(orgsChan)
		close(statusChan)
		cf.WaitForClose(stop)
	}()

	return
}
Example #14
0
File: users.go Project: pmuellr/cli
func (repo CloudControllerUserRepository) listUsersForRole(path string, roleName string, stop chan bool) (usersChan chan []cf.UserFields, statusChan chan net.ApiResponse) {
	usersChan = make(chan []cf.UserFields, 4)
	statusChan = make(chan net.ApiResponse, 1)

	go func() {
	loop:
		for path != "" {
			select {
			case <-stop:
				break loop
			default:
				var (
					users       []cf.UserFields
					apiResponse net.ApiResponse
				)

				users, path, apiResponse = repo.findNextWithPath(path)
				if apiResponse.IsNotSuccessful() {
					statusChan <- apiResponse
					close(usersChan)
					close(statusChan)
					return
				}

				if len(users) > 0 {
					usersChan <- users
				}
			}
		}
		close(usersChan)
		close(statusChan)
		cf.WaitForClose(stop)
	}()

	return
}