Skip to content

Commit

Permalink
Revert "Merge pull request #718 from cf-routing/list_route_services"
Browse files Browse the repository at this point in the history
This reverts commit f676112, reversing
changes made to c16b4c9.
  • Loading branch information
Kris Hicks committed Dec 21, 2015
1 parent 6512e65 commit a3259fb
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 173 deletions.
10 changes: 4 additions & 6 deletions cf/api/resources/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ type RouteResource struct {
}

type RouteEntity struct {
Host string `json:"host"`
Domain DomainResource `json:"domain"`
Space SpaceResource `json:"space"`
Apps []ApplicationResource `json:"apps"`
ServiceInstance ServiceInstanceResource `json:"service_instance"`
Host string
Domain DomainResource
Space SpaceResource
Apps []ApplicationResource
}

func (resource RouteResource) ToFields() (fields models.Route) {
Expand All @@ -25,7 +24,6 @@ func (resource RouteResource) ToModel() (route models.Route) {
route.Guid = resource.Metadata.Guid
route.Domain = resource.Entity.Domain.ToFields()
route.Space = resource.Entity.Space.ToFields()
route.ServiceInstance = resource.Entity.ServiceInstance.ToFields()
for _, appResource := range resource.Entity.Apps {
route.Apps = append(route.Apps, appResource.ToFields())
}
Expand Down
43 changes: 2 additions & 41 deletions cf/api/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ var _ = Describe("route repository", func() {

Expect(len(routes)).To(Equal(2))
Expect(routes[0].Guid).To(Equal("route-1-guid"))
Expect(routes[0].ServiceInstance.Guid).To(Equal("service-guid"))
Expect(routes[0].ServiceInstance.Name).To(Equal("test-service"))
Expect(routes[1].Guid).To(Equal("route-2-guid"))
Expect(handler).To(HaveAllRequestsCalled())
Expect(apiErr).NotTo(HaveOccurred())
Expand Down Expand Up @@ -98,11 +96,8 @@ var _ = Describe("route repository", func() {
Expect(len(routes)).To(Equal(2))
Expect(routes[0].Guid).To(Equal("route-1-guid"))
Expect(routes[0].Space.Guid).To(Equal("space-1-guid"))
Expect(routes[0].ServiceInstance.Guid).To(Equal("service-guid"))
Expect(routes[0].ServiceInstance.Name).To(Equal("test-service"))
Expect(routes[1].Guid).To(Equal("route-2-guid"))
Expect(routes[1].Space.Guid).To(Equal("space-2-guid"))

Expect(handler).To(HaveAllRequestsCalled())
Expect(apiErr).NotTo(HaveOccurred())
})
Expand Down Expand Up @@ -349,24 +344,7 @@ var firstPageRoutesResponse = testnet.TestResponse{Status: http.StatusOK, Body:
"name": "app-1"
}
}
],
"service_instance_url": "/v2/service_instances/service-guid",
"service_instance": {
"metadata": {
"guid": "service-guid",
"url": "/v2/service_instances/service-guid"
},
"entity": {
"name": "test-service",
"credentials": {
"username": "user",
"password": "password"
},
"type": "managed_service_instance",
"route_service_url": "https://something.awesome.com",
"space_url": "/v2/spaces/space-1-guid"
}
}
]
}
}
]
Expand Down Expand Up @@ -472,24 +450,7 @@ var firstPageRoutesOrgLvlResponse = testnet.TestResponse{Status: http.StatusOK,
"name": "app-1"
}
}
],
"service_instance_url": "/v2/service_instances/service-guid",
"service_instance": {
"metadata": {
"guid": "service-guid",
"url": "/v2/service_instances/service-guid"
},
"entity": {
"name": "test-service",
"credentials": {
"username": "user",
"password": "password"
},
"type": "managed_service_instance",
"route_service_url": "https://something.awesome.com",
"space_url": "/v2/spaces/space-1-guid"
}
}
]
}
}
]
Expand Down
25 changes: 6 additions & 19 deletions cf/commands/route/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,14 @@ func (cmd *ListRoutes) SetDependency(deps command_registry.Dependency, pluginCal
}

func (cmd *ListRoutes) Execute(c flags.FlagContext) {
flag := c.Bool("orglevel")

if flag {
cmd.ui.Say(T("Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
map[string]interface{}{
"Username": terminal.EntityNameColor(cmd.config.Username()),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
}))
} else {
cmd.ui.Say(T("Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
map[string]interface{}{
"Username": terminal.EntityNameColor(cmd.config.Username()),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
}))
}
cmd.ui.Say(T("Getting routes as {{.Username}} ...\n",
map[string]interface{}{"Username": terminal.EntityNameColor(cmd.config.Username())}))

table := cmd.ui.Table([]string{T("space"), T("host"), T("domain"), T("apps"), T("service")})
table := cmd.ui.Table([]string{T("space"), T("host"), T("domain"), T("apps")})

noRoutes := true
var apiErr error
flag := c.Bool("orglevel")

if flag {
apiErr = cmd.routeRepo.ListAllRoutes(func(route models.Route) bool {
Expand All @@ -87,7 +74,7 @@ func (cmd *ListRoutes) Execute(c flags.FlagContext) {
appNames = append(appNames, app.Name)
}

table.Add(route.Space.Name, route.Host, route.Domain.Name, strings.Join(appNames, ","), route.ServiceInstance.Name)
table.Add(route.Space.Name, route.Host, route.Domain.Name, strings.Join(appNames, ","))
return true
})

Expand All @@ -100,7 +87,7 @@ func (cmd *ListRoutes) Execute(c flags.FlagContext) {
appNames = append(appNames, app.Name)
}

table.Add(route.Space.Name, route.Host, route.Domain.Name, strings.Join(appNames, ","), route.ServiceInstance.Name)
table.Add(route.Space.Name, route.Host, route.Domain.Name, strings.Join(appNames, ","))
return true
})
}
Expand Down
20 changes: 6 additions & 14 deletions cf/commands/route/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ var _ = Describe("routes command", func() {
route.Host = "hostname-1"
route.Domain = domain
route.Apps = []models.ApplicationFields{app1}
route.ServiceInstance = models.ServiceInstanceFields{
Name: "test-service",
Guid: "service-guid",
}

route2 := models.Route{}
route2.Host = "hostname-2"
Expand All @@ -94,9 +90,9 @@ var _ = Describe("routes command", func() {
runCommand()

Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Getting routes for org", "/ space", "my-org", "my-space", "my-user"},
[]string{"host", "domain", "apps", "service"},
[]string{"hostname-1", "example.com", "dora", "test-service"},
[]string{"Getting routes", "my-user"},
[]string{"host", "domain", "apps"},
[]string{"hostname-1", "example.com", "dora"},
[]string{"hostname-2", "cookieclicker.co", "dora", "bora"},
))
})
Expand All @@ -118,10 +114,6 @@ var _ = Describe("routes command", func() {
route.Domain = domain
route.Apps = []models.ApplicationFields{app1}
route.Space = space1
route.ServiceInstance = models.ServiceInstanceFields{
Name: "test-service",
Guid: "service-guid",
}

route2 := models.Route{}
route2.Host = "hostname-2"
Expand All @@ -135,9 +127,9 @@ var _ = Describe("routes command", func() {
runCommand("--orglevel")

Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Getting routes for org", "my-org", "my-user"},
[]string{"space", "host", "domain", "apps", "service"},
[]string{"space-1", "hostname-1", "example.com", "dora", "test-service"},
[]string{"Getting routes", "my-user"},
[]string{"space", "host", "domain", "apps"},
[]string{"space-1", "hostname-1", "example.com", "dora"},
[]string{"space-2", "hostname-2", "cookieclicker.co", "dora", "bora"},
))
})
Expand Down
10 changes: 0 additions & 10 deletions cf/i18n/resources/de_DE.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -2664,16 +2664,6 @@
"translation": "Getting routes as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting rules for the security group : {{.SecurityGroupName}}...",
"translation": "Getting rules for the security group : {{.SecurityGroupName}}...",
Expand Down
10 changes: 0 additions & 10 deletions cf/i18n/resources/en_US.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -2664,16 +2664,6 @@
"translation": "Getting routes as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting rules for the security group : {{.SecurityGroupName}}...",
"translation": "Getting rules for the security group : {{.SecurityGroupName}}...",
Expand Down
10 changes: 0 additions & 10 deletions cf/i18n/resources/es_ES.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -2664,16 +2664,6 @@
"translation": "Obteniendo rutas como {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting rules for the security group : {{.SecurityGroupName}}...",
"translation": "Getting rules for the security group : {{.SecurityGroupName}}...",
Expand Down
10 changes: 0 additions & 10 deletions cf/i18n/resources/fr_FR.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -2664,16 +2664,6 @@
"translation": "Récupération des routes en tant que {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting rules for the security group : {{.SecurityGroupName}}...",
"translation": "Getting rules for the security group : {{.SecurityGroupName}}...",
Expand Down
10 changes: 0 additions & 10 deletions cf/i18n/resources/it_IT.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -2664,16 +2664,6 @@
"translation": "Getting routes as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting rules for the security group : {{.SecurityGroupName}}...",
"translation": "Getting rules for the security group : {{.SecurityGroupName}}...",
Expand Down
10 changes: 0 additions & 10 deletions cf/i18n/resources/ja_JA.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -2664,16 +2664,6 @@
"translation": "Getting routes as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting rules for the security group : {{.SecurityGroupName}}...",
"translation": "Getting rules for the security group : {{.SecurityGroupName}}...",
Expand Down
10 changes: 0 additions & 10 deletions cf/i18n/resources/pt_BR.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -2664,16 +2664,6 @@
"translation": "Obtendo rotas como {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting rules for the security group : {{.SecurityGroupName}}...",
"translation": "Getting rules for the security group : {{.SecurityGroupName}}...",
Expand Down
10 changes: 0 additions & 10 deletions cf/i18n/resources/zh_Hans.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -2664,16 +2664,6 @@
"translation": "Getting routes as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting rules for the security group : {{.SecurityGroupName}}...",
"translation": "Getting rules for the security group : {{.SecurityGroupName}}...",
Expand Down
10 changes: 0 additions & 10 deletions cf/i18n/resources/zh_Hant.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -2664,16 +2664,6 @@
"translation": "Getting routes as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"translation": "Getting routes for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}} ...\n",
"modified": false
},
{
"id": "Getting rules for the security group : {{.SecurityGroupName}}...",
"translation": "Getting rules for the security group : {{.SecurityGroupName}}...",
Expand Down
5 changes: 2 additions & 3 deletions cf/models/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ type Route struct {
Host string
Domain DomainFields

Space SpaceFields
Apps []ApplicationFields
ServiceInstance ServiceInstanceFields
Space SpaceFields
Apps []ApplicationFields
}

func (route Route) URL() string {
Expand Down

0 comments on commit a3259fb

Please sign in to comment.