Documentation
¶
Index ¶
- type Controller
- func (ctrl *Controller) Build(c *gin.Context)
- func (ctrl *Controller) Get(c *gin.Context)
- func (ctrl *Controller) History(c *gin.Context)
- func (ctrl *Controller) List(c *gin.Context)
- func (ctrl *Controller) Pull(c *gin.Context)
- func (ctrl *Controller) RegisterRoutes(router *gin.RouterGroup, authMW *middleware.AuthMiddleware)
- func (ctrl *Controller) Remove(c *gin.Context)
- func (ctrl *Controller) Tag(c *gin.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller handles image-related API requests
func NewController ¶
func NewController( imageService image.Service, imageRepo repositories.ImageRepository, dockerClient docker.Manager, logger *logrus.Logger, ) *Controller
NewController creates a new image controller
func (*Controller) Build ¶
func (ctrl *Controller) Build(c *gin.Context)
Build godoc @Summary Build an image @Description Builds a Docker image from a Dockerfile and context. Context can be uploaded as a TAR archive. @Tags Images @Accept multipart/form-data @Produce json @Security BearerAuth @Param tag formData string true "Image tag (e.g., myapp:latest)" example(my-custom-app:v1.1) @Param dockerfile formData file false "Dockerfile content (alternative to context archive)" @Param context formData file false "Build context as TAR archive (can contain Dockerfile)" @Param dockerfile_path formData string false "Path to Dockerfile within the context archive" default("Dockerfile") example(build/Dockerfile.prod) @Param nocache formData bool false "Do not use cache when building the image" default(false) example(true) @Param pull formData bool false "Always attempt to pull a newer version of the image" default(false) example(true) @Param buildarg.* formData string false "Build-time variables (e.g., buildarg.VERSION=1.0)" example(buildarg.APP_VERSION=1.1) @Param label.* formData string false "Set metadata for an image (e.g., label.maintainer=me)" example(label.project=webapp) @Success 200 {object} models.SuccessResponse{data=models.ImageBuildResponse} "Image built successfully" @Failure 400 {object} models.ErrorResponse "Invalid input (e.g., missing tag, invalid tag format, missing Dockerfile/context)" @Failure 401 {object} models.ErrorResponse "Authentication required" @Failure 500 {object} models.ErrorResponse "Internal server error (e.g., Docker daemon error, failed to process context)" @Router /images/build [post]
func (*Controller) Get ¶
func (ctrl *Controller) Get(c *gin.Context)
Get godoc @Summary Get image details @Description Retrieves detailed information about a specific image by its ID or name/tag. Handles names with slashes. @Tags Images @Produce json @Security BearerAuth @Param id path string true "Image ID, Name, or Name:Tag (URL encoded if contains slashes)" example(nginx:latest) @Success 200 {object} models.SuccessResponse{data=models.ImageResponse} "Successfully retrieved image details" @Failure 400 {object} models.ErrorResponse "Invalid image ID/name format" @Failure 401 {object} models.ErrorResponse "Authentication required" @Failure 403 {object} models.ErrorResponse "Permission denied" @Failure 404 {object} models.ErrorResponse "Image not found" @Failure 500 {object} models.ErrorResponse "Internal server error" @Router /images/{id} [get] // Corrected path parameter syntax
func (*Controller) History ¶
func (ctrl *Controller) History(c *gin.Context)
History godoc @Summary Get image history @Description Retrieves the history (layers) of an image. Handles names with slashes. @Tags Images @Produce json @Security BearerAuth @Param id path string true "Image ID or Name:Tag (URL encoded if contains slashes)" @Success 200 {object} models.SuccessResponse{data=[]models.ImageHistoryItem} "Successfully retrieved image history" @Failure 400 {object} models.ErrorResponse "Invalid image ID/name format" @Failure 401 {object} models.ErrorResponse "Authentication required" @Failure 403 {object} models.ErrorResponse "Permission denied" @Failure 404 {object} models.ErrorResponse "Image not found" @Failure 500 {object} models.ErrorResponse "Internal server error" @Router /image-history/{id} [get]
func (*Controller) List ¶
func (ctrl *Controller) List(c *gin.Context)
List godoc @Summary List images @Description Retrieves a list of Docker images. @Tags Images @Produce json @Security BearerAuth @Param page query int false "Page number" default(1) example(1) @Param page_size query int false "Number of items per page" default(10) minimum(1) maximum(100) example(20) @Param sort_by query string false "Field to sort by (e.g., repository, tag, size, created)" default(created) example(size) @Param sort_order query string false "Sort order (asc, desc)" default(desc) Enums(asc, desc) example(asc) @Param all query bool false "Show all images (including intermediate layers)" default(false) example(true) @Param dangling query bool false "Filter by dangling images" example(true) @Param label query string false "Filter by label (e.g., key=value)" example(maintainer=me) @Param search query string false "Search term for repository, tag, or image ID" example(nginx) @Success 200 {object} models.PaginatedResponse{data=models.ImageListResponse} "Successfully retrieved images" @Failure 401 {object} models.ErrorResponse "Authentication required" @Failure 500 {object} models.ErrorResponse "Internal server error" @Router /images [get]
func (*Controller) Pull ¶
func (ctrl *Controller) Pull(c *gin.Context)
Pull godoc @Summary Pull an image @Description Pulls an image from a Docker registry. Authentication can be provided. @Tags Images @Accept json @Produce json @Security BearerAuth @Param image body models.ImagePullRequest true "Image Pull Request" @Success 200 {object} models.SuccessResponse{data=models.ImagePullResponse} "Image pulled successfully" @Failure 400 {object} models.ErrorResponse "Invalid input (e.g., missing image name)" @Failure 401 {object} models.ErrorResponse "Authentication required or invalid credentials" @Failure 403 {object} models.ErrorResponse "Permission denied for registry" @Failure 404 {object} models.ErrorResponse "Image not found in registry" @Failure 500 {object} models.ErrorResponse "Internal server error (e.g., Docker daemon error)" @Router /images/pull [post]
func (*Controller) RegisterRoutes ¶
func (ctrl *Controller) RegisterRoutes(router *gin.RouterGroup, authMW *middleware.AuthMiddleware)
RegisterRoutes registers the image API routes
func (*Controller) Remove ¶
func (ctrl *Controller) Remove(c *gin.Context)
Remove godoc @Summary Remove an image @Description Removes an image by its ID or name/tag. Handles names with slashes. @Tags Images @Produce json @Security BearerAuth @Param id path string true "Image ID, Name, or Name:Tag (URL encoded if contains slashes)" @Param force query bool false "Force removal of the image" default(false) @Param noprune query bool false "Do not delete untagged parents" default(false) @Success 200 {object} models.SuccessResponse{data=[]models.ImageRemoveResponse} "Image removal report" @Failure 400 {object} models.ErrorResponse "Invalid image ID/name format" @Failure 401 {object} models.ErrorResponse "Authentication required" @Failure 403 {object} models.ErrorResponse "Permission denied" @Failure 404 {object} models.ErrorResponse "Image not found" @Failure 409 {object} models.ErrorResponse "Conflict (e.g., image is in use by a container)" @Failure 500 {object} models.ErrorResponse "Internal server error" @Router /images/{id} [delete] // Corrected path parameter syntax
func (*Controller) Tag ¶
func (ctrl *Controller) Tag(c *gin.Context)
Tag godoc @Summary Tag an image @Description Creates a new tag for an existing image. Handles names with slashes. @Tags Images @Accept json @Produce json @Security BearerAuth @Param tag body models.ImageTagRequest true "New Tag Info" @Success 201 "Image tagged successfully" @Failure 400 {object} models.ErrorResponse "Invalid input (e.g., missing repo/tag, invalid format)" @Failure 401 {object} models.ErrorResponse "Authentication required" @Failure 403 {object} models.ErrorResponse "Permission denied" @Failure 404 {object} models.ErrorResponse "Source image not found" @Failure 409 {object} models.ErrorResponse "Tag already exists" @Failure 500 {object} models.ErrorResponse "Internal server error" @Router /images/tag [post] // Updated route