MCPcopy Index your code
hub / github.com/cloudfoundry/cli / Find

Method Find

cf/api/routes.go:88–120  ·  view source on GitHub ↗
(host string, domain models.DomainFields, path string, port int)

Source from the content-addressed store, hash-verified

86}
87
88func (repo CloudControllerRouteRepository) Find(host string, domain models.DomainFields, path string, port int) (models.Route, error) {
89 var route models.Route
90 queryString := queryStringForRouteSearch(host, domain.GUID, path, port)
91
92 q := struct {
93 Query string `url:"q"`
94 InlineRelationsDepth int `url:"inline-relations-depth"`
95 }{queryString, 1}
96
97 opt, _ := query.Values(q)
98
99 found := false
100 apiErr := repo.gateway.ListPaginatedResources(
101 repo.config.APIEndpoint(),
102 fmt.Sprintf("/v2/routes?%s", opt.Encode()),
103 resources.RouteResource{},
104 func(resource interface{}) bool {
105 keepSearching := true
106 route = resource.(resources.RouteResource).ToModel()
107 if doesNotMatchVersionSpecificAttributes(route, path, port) {
108 return keepSearching
109 }
110
111 found = true
112 return !keepSearching
113 })
114
115 if apiErr == nil && !found {
116 apiErr = errors.NewModelNotFoundError("Route", host)
117 }
118
119 return route, apiErr
120}
121
122func doesNotMatchVersionSpecificAttributes(route models.Route, path string, port int) bool {
123 return normalizedPath(route.Path) != normalizedPath(path) || route.Port != port

Callers

nothing calls this directly

Calls 6

NewModelNotFoundErrorFunction · 0.92
APIEndpointMethod · 0.65
ToModelMethod · 0.45

Tested by

no test coverage detected