Skip to content

Commit

Permalink
Redirects /resources api to /v1/resources
Browse files Browse the repository at this point in the history
This adds a design for resource api where it defines
the redirect path

This patch also updates goa version to 3.4.0

Signed-off-by: Puneet Punamiya [email protected]
  • Loading branch information
PuneetPunamiya authored and tekton-robot committed Mar 17, 2022
1 parent d0355fd commit b22a728
Show file tree
Hide file tree
Showing 119 changed files with 4,654 additions and 226 deletions.
12 changes: 11 additions & 1 deletion api/cmd/api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ import (
catalogsvr "github.com/tektoncd/hub/api/gen/http/catalog/server"
categorysvr "github.com/tektoncd/hub/api/gen/http/category/server"
ratingsvr "github.com/tektoncd/hub/api/gen/http/rating/server"
resourcesvr "github.com/tektoncd/hub/api/gen/http/resource/server"
statussvr "github.com/tektoncd/hub/api/gen/http/status/server"
swaggersvr "github.com/tektoncd/hub/api/gen/http/swagger/server"
"github.com/tektoncd/hub/api/gen/log"
rating "github.com/tektoncd/hub/api/gen/rating"
resource "github.com/tektoncd/hub/api/gen/resource"
status "github.com/tektoncd/hub/api/gen/status"
v1catalog "github.com/tektoncd/hub/api/v1/gen/catalog"
v1catalogsvr "github.com/tektoncd/hub/api/v1/gen/http/catalog/server"
Expand All @@ -54,6 +56,7 @@ func handleHTTPServer(
v1catalogEndpoints *v1catalog.Endpoints,
categoryEndpoints *category.Endpoints,
ratingEndpoints *rating.Endpoints,
resourceEndpoints *resource.Endpoints,
v1resourceEndpoints *v1resource.Endpoints,
statusEndpoints *status.Endpoints,
wg *sync.WaitGroup, errc chan error, logger *log.Logger, debug bool) {
Expand Down Expand Up @@ -92,6 +95,7 @@ func handleHTTPServer(
v1catalogServer *v1catalogsvr.Server
categoryServer *categorysvr.Server
ratingServer *ratingsvr.Server
resourceServer *resourcesvr.Server
v1resourceServer *v1resourcesvr.Server
statusServer *statussvr.Server
swaggerServer *swaggersvr.Server
Expand All @@ -104,9 +108,10 @@ func handleHTTPServer(
v1catalogServer = v1catalogsvr.New(v1catalogEndpoints, mux, dec, enc, eh, nil)
categoryServer = categorysvr.New(categoryEndpoints, mux, dec, enc, eh, nil)
ratingServer = ratingsvr.New(ratingEndpoints, mux, dec, enc, eh, nil)
resourceServer = resourcesvr.New(resourceEndpoints, mux, dec, enc, eh, nil)
v1resourceServer = v1resourcesvr.New(v1resourceEndpoints, mux, dec, enc, eh, nil)
statusServer = statussvr.New(statusEndpoints, mux, dec, enc, eh, nil)
swaggerServer = swaggersvr.New(nil, mux, dec, enc, eh, nil)
swaggerServer = swaggersvr.New(nil, mux, dec, enc, eh, nil, nil)
v1swaggerServer = v1swaggersvr.New(nil, mux, dec, enc, eh, nil)

if debug {
Expand All @@ -116,6 +121,7 @@ func handleHTTPServer(
v1catalogServer,
categoryServer,
ratingServer,
resourceServer,
v1resourceServer,
statusServer,
swaggerServer,
Expand All @@ -130,6 +136,7 @@ func handleHTTPServer(
v1catalogsvr.Mount(mux, v1catalogServer)
categorysvr.Mount(mux, categoryServer)
ratingsvr.Mount(mux, ratingServer)
resourcesvr.Mount(mux, resourceServer)
v1resourcesvr.Mount(mux, v1resourceServer)
statussvr.Mount(mux, statusServer)
swaggersvr.Mount(mux, swaggerServer)
Expand Down Expand Up @@ -161,6 +168,9 @@ func handleHTTPServer(
for _, m := range ratingServer.Mounts {
logger.Infof("HTTP %q mounted on %s %s", m.Method, m.Verb, m.Pattern)
}
for _, m := range resourceServer.Mounts {
logger.Infof("HTTP %q mounted on %s %s", m.Method, m.Verb, m.Pattern)
}
for _, m := range v1resourceServer.Mounts {
logger.Infof("HTTP %q mounted on %s %s", m.Method, m.Verb, m.Pattern)
}
Expand Down
5 changes: 5 additions & 0 deletions api/cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
category "github.com/tektoncd/hub/api/gen/category"
"github.com/tektoncd/hub/api/gen/log"
rating "github.com/tektoncd/hub/api/gen/rating"
resource "github.com/tektoncd/hub/api/gen/resource"
status "github.com/tektoncd/hub/api/gen/status"
"github.com/tektoncd/hub/api/pkg/app"
auth "github.com/tektoncd/hub/api/pkg/auth"
Expand Down Expand Up @@ -89,6 +90,7 @@ func main() {
v1catalogSvc v1catalog.Service
categorySvc category.Service
ratingSvc rating.Service
resourceSvc resource.Service
v1resourceSvc v1resource.Service
statusSvc status.Service
)
Expand All @@ -110,6 +112,7 @@ func main() {
v1catalogEndpoints *v1catalog.Endpoints
categoryEndpoints *category.Endpoints
ratingEndpoints *rating.Endpoints
resourceEndpoints *resource.Endpoints
v1resourceEndpoints *v1resource.Endpoints
statusEndpoints *status.Endpoints
)
Expand All @@ -119,6 +122,7 @@ func main() {
v1catalogEndpoints = v1catalog.NewEndpoints(v1catalogSvc)
categoryEndpoints = category.NewEndpoints(categorySvc)
ratingEndpoints = rating.NewEndpoints(ratingSvc)
resourceEndpoints = resource.NewEndpoints(resourceSvc)
v1resourceEndpoints = v1resource.NewEndpoints(v1resourceSvc)
statusEndpoints = status.NewEndpoints(statusSvc)
}
Expand Down Expand Up @@ -167,6 +171,7 @@ func main() {
v1catalogEndpoints,
categoryEndpoints,
ratingEndpoints,
resourceEndpoints,
v1resourceEndpoints,
statusEndpoints,
&wg, errc, api.Logger("http"), *dbgF,
Expand Down
1 change: 1 addition & 0 deletions api/design/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var _ = API("hub", func() {
"catalog",
"category",
"rating",
"resource",
"status",
"swagger",
)
Expand Down
37 changes: 37 additions & 0 deletions api/design/resource.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright © 2022 The Tekton Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package design

import (
"github.com/tektoncd/hub/api/design/types"
. "goa.design/goa/v3/dsl"
)

// NOTE: APIs in the service are moved to v1. This APIs will be deprecated in the next release.

var _ = Service("resource", func() {
Description("The resource service provides details about all kind of resources")

Method("List", func() {
Description("List all resources sorted by rating and name")
Result(types.Resources)

HTTP(func() {
GET("/resources")
Redirect("/v1/resources", StatusMovedPermanently)
})
})

})
2 changes: 1 addition & 1 deletion api/gen/admin/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/admin/endpoints.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/admin/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/catalog/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/catalog/endpoints.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/catalog/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/catalog/views/view.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/category/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/category/endpoints.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/category/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/admin/client/cli.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/admin/client/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/admin/client/encode_decode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/admin/client/paths.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/admin/client/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions api/gen/http/admin/server/encode_decode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/admin/server/paths.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/admin/server/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/admin/server/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/catalog/client/cli.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/catalog/client/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/catalog/client/encode_decode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/catalog/client/paths.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/catalog/client/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions api/gen/http/catalog/server/encode_decode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/catalog/server/paths.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/catalog/server/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/catalog/server/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/category/client/cli.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/category/client/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/category/client/encode_decode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/category/client/paths.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/gen/http/category/client/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b22a728

Please sign in to comment.