Skip to content

Commit

Permalink
Fixups: 'blob' corrected to 'blobs' in routes and the 'detail' field …
Browse files Browse the repository at this point in the history
…under ResponseError type changed from string to ResponseErrorDetails.

Signed-off-by: Michael Valdron <mvaldron@redhat.com>
  • Loading branch information
michael-valdron committed Jul 29, 2022
1 parent 6e0a403 commit 323393c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions index/server/pkg/ocitest/ocitest.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ import (
"github.com/gin-gonic/gin"
)

type ResponseErrorDetails struct {
Tag string `json:"Tag"`
}

type ResponseError struct {
Code string `json:"code"`
Message string `json:"message"`
Detail string `json:"detail"`
Code string `json:"code"`
Message string `json:"message"`
Detail ResponseErrorDetails `json:"detail"`
}

type MockOCIServer struct {
Expand All @@ -35,10 +39,10 @@ func servePing(c *gin.Context) {
c.JSON(http.StatusOK, data)
}

func WriteErrors(errors []ResponseError) ([]byte, error) {
return json.Marshal(gin.H{
func WriteErrors(errors []ResponseError) gin.H {
return gin.H{
"errors": errors,
})
}
}

func NewMockOCIServer() *MockOCIServer {
Expand Down Expand Up @@ -68,8 +72,8 @@ func (server *MockOCIServer) Start(listenAddr string) error {

// Fetch blob routes
if server.ServeBlob != nil {
server.router.GET("/v2/devfile-catalog/:name/blob/:digest", server.ServeBlob)
server.router.HEAD("/v2/devfile-catalog/:name/blob/:digest", server.ServeBlob)
server.router.GET("/v2/devfile-catalog/:name/blobs/:digest", server.ServeBlob)
server.router.HEAD("/v2/devfile-catalog/:name/blobs/:digest", server.ServeBlob)
}

l, err := net.Listen("tcp", listenAddr)
Expand Down

0 comments on commit 323393c

Please sign in to comment.