-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Repository udpate operation checks
Signed-off-by: jay-dee7 <[email protected]>
- Loading branch information
Showing
17 changed files
with
257 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,54 @@ | ||
package extensions | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
"time" | ||
|
||
store_v1 "github.com/containerish/OpenRegistry/store/v1" | ||
"github.com/containerish/OpenRegistry/store/v1/types" | ||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
func (ext *extension) ChangeContainerImageVisibility(ctx echo.Context) error { | ||
ctx.Set(types.HandlerStartTime, time.Now()) | ||
|
||
var body types.ContainerImageVisibilityChangeRequest | ||
user, ok := ctx.Get(string(types.UserContextKey)).(*types.User) | ||
if !ok { | ||
echoErr := ctx.JSON(http.StatusBadRequest, echo.Map{ | ||
"error": store_v1.ErrMissingUserInContext.Error(), | ||
}) | ||
|
||
if err := json.NewDecoder(ctx.Request().Body).Decode(&body); err != nil { | ||
return ctx.JSON(http.StatusBadRequest, echo.Map{ | ||
ext.logger.Log(ctx, store_v1.ErrMissingUserInContext).Send() | ||
return echoErr | ||
} | ||
|
||
var body types.ContainerImageVisibilityChangeRequest | ||
if err := ctx.Bind(&body); err != nil { | ||
echoErr := ctx.JSON(http.StatusBadRequest, echo.Map{ | ||
"error": "invalid request body", | ||
}) | ||
ext.logger.Log(ctx, err).Send() | ||
return echoErr | ||
} | ||
defer ctx.Request().Body.Close() | ||
|
||
err := ext.store.SetContainerImageVisibility(ctx.Request().Context(), body.ImageManifestUUID, body.Visibility) | ||
err := ext.store.SetContainerImageVisibility( | ||
ctx.Request().Context(), | ||
body.RepositoryID, | ||
user.ID, | ||
body.Visibility, | ||
) | ||
if err != nil { | ||
return ctx.JSON(http.StatusBadRequest, echo.Map{ | ||
echoErr := ctx.JSON(http.StatusBadRequest, echo.Map{ | ||
"error": err.Error(), | ||
}) | ||
ext.logger.Log(ctx, err).Send() | ||
return echoErr | ||
} | ||
|
||
return ctx.JSON(http.StatusOK, echo.Map{ | ||
echoErr := ctx.JSON(http.StatusOK, echo.Map{ | ||
"message": "container image visibility mode changed successfully", | ||
}) | ||
ext.logger.Log(ctx, nil).Send() | ||
return echoErr | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.