Skip to content

Commit

Permalink
Add no-op operation to allow tsuru api to update resource
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Oct 16, 2023
1 parent 6133efd commit f941f3b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func configHandlers(e *echo.Echo) {
e.POST("/resources", serviceCreate)
e.GET("/resources/plans", servicePlans)
e.GET("/resources/:instance", serviceInfo)
e.PUT("/resources/:instance", serviceUpdate)
e.DELETE("/resources/:instance", serviceDelete)
e.GET("/resources/:instance/status", serviceStatus)
e.POST("/resources/:instance/bind-app", serviceBindApp)
Expand Down
20 changes: 20 additions & 0 deletions api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/tsuru/acl-api/engine"
"github.com/tsuru/acl-api/rule"
"github.com/tsuru/acl-api/service"
"github.com/tsuru/acl-api/storage"
)

func serviceCreate(c echo.Context) error {
Expand All @@ -32,6 +33,25 @@ func serviceCreate(c echo.Context) error {
return c.String(http.StatusOK, "")
}

func serviceUpdate(c echo.Context) error {
// serviceUpdate is a no-op operation
// just check if service exists
instanceName := c.Param("instance")

svc := service.GetService()
_, err := svc.Find(instanceName)

if err == storage.ErrInstanceNotFound {
return c.String(http.StatusNotFound, "")
}

if err != nil {
return err
}

return c.String(http.StatusOK, "")
}

func serviceDelete(c echo.Context) error {
instanceName := c.Param("instance")
svc := service.GetService()
Expand Down

0 comments on commit f941f3b

Please sign in to comment.