diff --git a/app/http/controllers/plugins/podman_controller.go b/app/http/controllers/plugins/podman_controller.go new file mode 100644 index 000000000..520d0d5fa --- /dev/null +++ b/app/http/controllers/plugins/podman_controller.go @@ -0,0 +1,239 @@ +package plugins + +import ( + "github.com/goravel/framework/contracts/http" + + "github.com/TheTNB/panel/app/http/controllers" + requests "github.com/TheTNB/panel/app/http/requests/plugins/podman" + "github.com/TheTNB/panel/pkg/tools" +) + +type PodmanController struct { +} + +func NewPodmanController() *PodmanController { + return &PodmanController{} +} + +// Status +// +// @Summary 服务状态 +// @Description 获取 Podman 服务状态 +// @Tags 插件-Podman +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/podman/status [get] +func (r *PodmanController) Status(ctx http.Context) http.Response { + status, err := tools.ServiceStatus("podman") + if err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, "获取 Podman 服务运行状态失败") + } + + return controllers.Success(ctx, status) +} + +// IsEnabled +// +// @Summary 是否启用服务 +// @Description 获取是否启用 Podman 服务 +// @Tags 插件-Podman +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/podman/isEnabled [get] +func (r *PodmanController) IsEnabled(ctx http.Context) http.Response { + enabled, err := tools.ServiceIsEnabled("podman") + if err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, "获取 Podman 服务启用状态失败") + } + + return controllers.Success(ctx, enabled) +} + +// Enable +// +// @Summary 启用服务 +// @Description 启用 Podman 服务 +// @Tags 插件-Podman +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/podman/enable [post] +func (r *PodmanController) Enable(ctx http.Context) http.Response { + if err := tools.ServiceEnable("podman"); err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, "启用 Podman 服务失败") + } + + return controllers.Success(ctx, nil) +} + +// Disable +// +// @Summary 禁用服务 +// @Description 禁用 Podman 服务 +// @Tags 插件-Podman +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/podman/disable [post] +func (r *PodmanController) Disable(ctx http.Context) http.Response { + if err := tools.ServiceDisable("podman"); err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, "禁用 Podman 服务失败") + } + + return controllers.Success(ctx, nil) +} + +// Restart +// +// @Summary 重启服务 +// @Description 重启 Podman 服务 +// @Tags 插件-Podman +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/podman/restart [post] +func (r *PodmanController) Restart(ctx http.Context) http.Response { + if err := tools.ServiceRestart("podman"); err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, "重启 Podman 服务失败") + } + + return controllers.Success(ctx, nil) +} + +// Start +// +// @Summary 启动服务 +// @Description 启动 Podman 服务 +// @Tags 插件-Podman +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/podman/start [post] +func (r *PodmanController) Start(ctx http.Context) http.Response { + if err := tools.ServiceStart("podman"); err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, "启动 Podman 服务失败") + } + + status, err := tools.ServiceStatus("podman") + if err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, "获取 Podman 服务运行状态失败") + } + + return controllers.Success(ctx, status) +} + +// Stop +// +// @Summary 停止服务 +// @Description 停止 Podman 服务 +// @Tags 插件-Podman +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/podman/stop [post] +func (r *PodmanController) Stop(ctx http.Context) http.Response { + if err := tools.ServiceStop("podman"); err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, "停止 Podman 服务失败") + } + + status, err := tools.ServiceStatus("podman") + if err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, "获取 Podman 服务运行状态失败") + } + + return controllers.Success(ctx, !status) +} + +// GetRegistryConfig +// +// @Summary 获取注册表配置 +// @Description 获取 Podman 注册表配置 +// @Tags 插件-Podman +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/podman/registryConfig [get] +func (r *PodmanController) GetRegistryConfig(ctx http.Context) http.Response { + config, err := tools.Read("/etc/containers/registries.conf") + if err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, err.Error()) + } + + return controllers.Success(ctx, config) +} + +// UpdateRegistryConfig +// +// @Summary 更新注册表配置 +// @Description 更新 Podman 注册表配置 +// @Tags 插件-Podman +// @Produce json +// @Security BearerToken +// @Param data body requests.UpdateRegistryConfig true "request" +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/podman/registryConfig [post] +func (r *PodmanController) UpdateRegistryConfig(ctx http.Context) http.Response { + var updateRequest requests.UpdateRegistryConfig + sanitize := controllers.Sanitize(ctx, &updateRequest) + if sanitize != nil { + return sanitize + } + + if err := tools.Write("/etc/containers/registries.conf", updateRequest.Config, 0644); err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, err.Error()) + } + + if err := tools.ServiceRestart("podman"); err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, err.Error()) + } + + return controllers.Success(ctx, nil) +} + +// GetStorageConfig +// +// @Summary 获取存储配置 +// @Description 获取 Podman 存储配置 +// @Tags 插件-Podman +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/podman/storageConfig [get] +func (r *PodmanController) GetStorageConfig(ctx http.Context) http.Response { + config, err := tools.Read("/etc/containers/storage.conf") + if err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, err.Error()) + } + + return controllers.Success(ctx, config) +} + +// UpdateStorageConfig +// +// @Summary 更新存储配置 +// @Description 更新 Podman 存储配置 +// @Tags 插件-Podman +// @Produce json +// @Security BearerToken +// @Param data body requests.UpdateStorageConfig true "request" +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/podman/storageConfig [post] +func (r *PodmanController) UpdateStorageConfig(ctx http.Context) http.Response { + var updateRequest requests.UpdateStorageConfig + sanitize := controllers.Sanitize(ctx, &updateRequest) + if sanitize != nil { + return sanitize + } + + if err := tools.Write("/etc/containers/storage.conf", updateRequest.Config, 0644); err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, err.Error()) + } + + if err := tools.ServiceRestart("podman"); err != nil { + return controllers.Error(ctx, http.StatusInternalServerError, err.Error()) + } + + return controllers.Success(ctx, nil) +} diff --git a/app/http/middleware/must_install.go b/app/http/middleware/must_install.go index 68a548ba2..cc6b94cd4 100644 --- a/app/http/middleware/must_install.go +++ b/app/http/middleware/must_install.go @@ -18,6 +18,8 @@ func MustInstall() http.Middleware { var slug string if strings.HasPrefix(path, "/api/panel/website") { slug = "openresty" + } else if strings.HasPrefix(path, "/api/panel/container") { + slug = "podman" } else { pathArr := strings.Split(path, "/") if len(pathArr) < 4 { diff --git a/app/http/requests/plugins/podman/update_registry_config.go b/app/http/requests/plugins/podman/update_registry_config.go new file mode 100644 index 000000000..4941300f8 --- /dev/null +++ b/app/http/requests/plugins/podman/update_registry_config.go @@ -0,0 +1,32 @@ +package requests + +import ( + "github.com/goravel/framework/contracts/http" + "github.com/goravel/framework/contracts/validation" +) + +type UpdateRegistryConfig struct { + Config string `form:"config" json:"config"` +} + +func (r *UpdateRegistryConfig) Authorize(ctx http.Context) error { + return nil +} + +func (r *UpdateRegistryConfig) Rules(ctx http.Context) map[string]string { + return map[string]string{ + "config": "required|string", + } +} + +func (r *UpdateRegistryConfig) Messages(ctx http.Context) map[string]string { + return map[string]string{} +} + +func (r *UpdateRegistryConfig) Attributes(ctx http.Context) map[string]string { + return map[string]string{} +} + +func (r *UpdateRegistryConfig) PrepareForValidation(ctx http.Context, data validation.Data) error { + return nil +} diff --git a/app/http/requests/plugins/podman/update_storage_config.go b/app/http/requests/plugins/podman/update_storage_config.go new file mode 100644 index 000000000..d4aa191aa --- /dev/null +++ b/app/http/requests/plugins/podman/update_storage_config.go @@ -0,0 +1,32 @@ +package requests + +import ( + "github.com/goravel/framework/contracts/http" + "github.com/goravel/framework/contracts/validation" +) + +type UpdateStorageConfig struct { + Config string `form:"config" json:"config"` +} + +func (r *UpdateStorageConfig) Authorize(ctx http.Context) error { + return nil +} + +func (r *UpdateStorageConfig) Rules(ctx http.Context) map[string]string { + return map[string]string{ + "config": "required|string", + } +} + +func (r *UpdateStorageConfig) Messages(ctx http.Context) map[string]string { + return map[string]string{} +} + +func (r *UpdateStorageConfig) Attributes(ctx http.Context) map[string]string { + return map[string]string{} +} + +func (r *UpdateStorageConfig) PrepareForValidation(ctx http.Context, data validation.Data) error { + return nil +} diff --git a/docs/docs.go b/docs/docs.go index 497117fdd..abdf69c2f 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -3943,6 +3943,299 @@ const docTemplate = `{ } } }, + "/plugins/podman/disable": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "禁用 Podman 服务", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "禁用服务", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/enable": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "启用 Podman 服务", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "启用服务", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/isEnabled": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "获取是否启用 Podman 服务", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "是否启用服务", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/registryConfig": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "获取 Podman 注册表配置", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "获取注册表配置", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + }, + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "更新 Podman 注册表配置", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "更新注册表配置", + "parameters": [ + { + "description": "request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/requests.UpdateRegistryConfig" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/restart": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "重启 Podman 服务", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "重启服务", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/start": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "启动 Podman 服务", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "启动服务", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/status": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "获取 Podman 服务状态", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "服务状态", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/stop": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "停止 Podman 服务", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "停止服务", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/storageConfig": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "获取 Podman 存储配置", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "获取存储配置", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + }, + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "更新 Podman 存储配置", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "更新存储配置", + "parameters": [ + { + "description": "request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/requests.UpdateStorageConfig" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, "/plugins/rsync/config": { "get": { "security": [ @@ -5081,6 +5374,22 @@ const docTemplate = `{ } } }, + "requests.UpdateRegistryConfig": { + "type": "object", + "properties": { + "config": { + "type": "string" + } + } + }, + "requests.UpdateStorageConfig": { + "type": "object", + "properties": { + "config": { + "type": "string" + } + } + }, "requests.UserStore": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 312471229..c5d309aa1 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -3936,6 +3936,299 @@ } } }, + "/plugins/podman/disable": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "禁用 Podman 服务", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "禁用服务", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/enable": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "启用 Podman 服务", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "启用服务", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/isEnabled": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "获取是否启用 Podman 服务", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "是否启用服务", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/registryConfig": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "获取 Podman 注册表配置", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "获取注册表配置", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + }, + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "更新 Podman 注册表配置", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "更新注册表配置", + "parameters": [ + { + "description": "request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/requests.UpdateRegistryConfig" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/restart": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "重启 Podman 服务", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "重启服务", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/start": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "启动 Podman 服务", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "启动服务", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/status": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "获取 Podman 服务状态", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "服务状态", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/stop": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "停止 Podman 服务", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "停止服务", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/podman/storageConfig": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "获取 Podman 存储配置", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "获取存储配置", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + }, + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "更新 Podman 存储配置", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Podman" + ], + "summary": "更新存储配置", + "parameters": [ + { + "description": "request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/requests.UpdateStorageConfig" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, "/plugins/rsync/config": { "get": { "security": [ @@ -5074,6 +5367,22 @@ } } }, + "requests.UpdateRegistryConfig": { + "type": "object", + "properties": { + "config": { + "type": "string" + } + } + }, + "requests.UpdateStorageConfig": { + "type": "object", + "properties": { + "config": { + "type": "string" + } + } + }, "requests.UserStore": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 90a533ccd..ce7d42902 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -533,6 +533,16 @@ definitions: path: type: string type: object + requests.UpdateRegistryConfig: + properties: + config: + type: string + type: object + requests.UpdateStorageConfig: + properties: + config: + type: string + type: object requests.UserStore: properties: ca: @@ -3053,6 +3063,183 @@ paths: summary: 停止服务 tags: - 插件-Gitea + /plugins/podman/disable: + post: + description: 禁用 Podman 服务 + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 禁用服务 + tags: + - 插件-Podman + /plugins/podman/enable: + post: + description: 启用 Podman 服务 + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 启用服务 + tags: + - 插件-Podman + /plugins/podman/isEnabled: + get: + description: 获取是否启用 Podman 服务 + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 是否启用服务 + tags: + - 插件-Podman + /plugins/podman/registryConfig: + get: + description: 获取 Podman 注册表配置 + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 获取注册表配置 + tags: + - 插件-Podman + post: + description: 更新 Podman 注册表配置 + parameters: + - description: request + in: body + name: data + required: true + schema: + $ref: '#/definitions/requests.UpdateRegistryConfig' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 更新注册表配置 + tags: + - 插件-Podman + /plugins/podman/restart: + post: + description: 重启 Podman 服务 + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 重启服务 + tags: + - 插件-Podman + /plugins/podman/start: + post: + description: 启动 Podman 服务 + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 启动服务 + tags: + - 插件-Podman + /plugins/podman/status: + get: + description: 获取 Podman 服务状态 + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 服务状态 + tags: + - 插件-Podman + /plugins/podman/stop: + post: + description: 停止 Podman 服务 + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 停止服务 + tags: + - 插件-Podman + /plugins/podman/storageConfig: + get: + description: 获取 Podman 存储配置 + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 获取存储配置 + tags: + - 插件-Podman + post: + description: 更新 Podman 存储配置 + parameters: + - description: request + in: body + name: data + required: true + schema: + $ref: '#/definitions/requests.UpdateStorageConfig' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 更新存储配置 + tags: + - 插件-Podman /plugins/rsync/config: get: description: 获取 Rsync 配置 diff --git a/routes/api.go b/routes/api.go index 080a0966b..c2014f288 100644 --- a/routes/api.go +++ b/routes/api.go @@ -114,7 +114,7 @@ func Api() { r.Get("pingStatus", safeController.GetPingStatus) r.Post("pingStatus", safeController.SetPingStatus) }) - r.Prefix("container").Middleware(middleware.Jwt()).Group(func(r route.Router) { + r.Prefix("container").Middleware(middleware.Jwt(), middleware.MustInstall()).Group(func(r route.Router) { containerController := controllers.NewContainerController() r.Get("list", containerController.ContainerList) r.Get("search", containerController.ContainerSearch) diff --git a/routes/plugin.go b/routes/plugin.go index 40889c4c8..9011ecd07 100644 --- a/routes/plugin.go +++ b/routes/plugin.go @@ -340,6 +340,20 @@ func Plugin() { route.Post("whiteList", fail2banController.SetWhiteList) route.Get("whiteList", fail2banController.GetWhiteList) }) + r.Prefix("podman").Group(func(route route.Router) { + controller := plugins.NewPodmanController() + route.Get("status", controller.Status) + route.Get("isEnabled", controller.IsEnabled) + route.Post("enable", controller.Enable) + route.Post("disable", controller.Disable) + route.Post("start", controller.Start) + route.Post("stop", controller.Stop) + route.Post("restart", controller.Restart) + route.Get("registryConfig", controller.GetRegistryConfig) + route.Post("registryConfig", controller.UpdateRegistryConfig) + route.Get("storageConfig", controller.GetStorageConfig) + route.Post("storageConfig", controller.UpdateStorageConfig) + }) r.Prefix("rsync").Group(func(route route.Router) { rsyncController := plugins.NewRsyncController() route.Get("status", rsyncController.Status)