Browse Source

fix: Docker 配置自动过滤空行 (#4707)

Refs #4701
pull/4721/head
ssongliu 7 months ago committed by GitHub
parent
commit
ad6a1ac465
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      backend/app/api/v1/docker.go
  2. 16
      cmd/server/docs/docs.go
  3. 16
      cmd/server/docs/swagger.json
  4. 16
      cmd/server/docs/swagger.yaml
  5. 11
      frontend/src/utils/util.ts
  6. 3
      frontend/src/views/container/setting/mirror/index.vue
  7. 3
      frontend/src/views/container/setting/registry/index.vue

8
backend/app/api/v1/docker.go

@ -61,7 +61,7 @@ func (b *BaseApi) LoadDaemonJson(c *gin.Context) {
// @Success 200
// @Security ApiKeyAuth
// @Router /containers/daemonjson/update [post]
// @x-panel-log {"bodyKeys":["key", "value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json 配置 [key]=>[value]","formatEN":"Updated the docker daemon.json configuration [key]=>[value]"}
// @x-panel-log {"bodyKeys":["key", "value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新配置 [key]","formatEN":"Updated configuration [key]"}
func (b *BaseApi) UpdateDaemonJson(c *gin.Context) {
var req dto.SettingUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
@ -84,7 +84,7 @@ func (b *BaseApi) UpdateDaemonJson(c *gin.Context) {
// @Success 200
// @Security ApiKeyAuth
// @Router /containers/logoption/update [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json 日志配置","formatEN":"Updated the docker daemon.json log option"}
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新日志配置","formatEN":"Updated the log option"}
func (b *BaseApi) UpdateLogOption(c *gin.Context) {
var req dto.LogOption
if err := helper.CheckBind(&req, c); err != nil {
@ -107,7 +107,7 @@ func (b *BaseApi) UpdateLogOption(c *gin.Context) {
// @Success 200
// @Security ApiKeyAuth
// @Router /containers/ipv6option/update [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json ipv6 配置","formatEN":"Updated the docker daemon.json ipv6 option"}
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 ipv6 配置","formatEN":"Updated the ipv6 option"}
func (b *BaseApi) UpdateIpv6Option(c *gin.Context) {
var req dto.Ipv6Option
if err := helper.CheckBind(&req, c); err != nil {
@ -130,7 +130,7 @@ func (b *BaseApi) UpdateIpv6Option(c *gin.Context) {
// @Success 200
// @Security ApiKeyAuth
// @Router /containers/daemonjson/update/byfile [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 docker daemon.json 配置","formatEN":"Updated the docker daemon.json configuration"}
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新配置文件","formatEN":"Updated configuration file"}
func (b *BaseApi) UpdateDaemonJsonByFile(c *gin.Context) {
var req dto.DaemonJsonUpdateByFile
if err := helper.CheckBindAndValidate(&req, c); err != nil {

16
cmd/server/docs/docs.go

@ -1444,8 +1444,8 @@ const docTemplate = `{
"key",
"value"
],
"formatEN": "Updated the docker daemon.json configuration [key]=\u003e[value]",
"formatZH": "更新 docker daemon.json 配置 [key]=\u003e[value]",
"formatEN": "Updated configuration [key]",
"formatZH": "更新配置 [key]",
"paramKeys": []
}
}
@ -1484,8 +1484,8 @@ const docTemplate = `{
"x-panel-log": {
"BeforeFunctions": [],
"bodyKeys": [],
"formatEN": "Updated the docker daemon.json configuration",
"formatZH": "更新 docker daemon.json 配置",
"formatEN": "Updated configuration file",
"formatZH": "更新配置文件",
"paramKeys": []
}
}
@ -2094,8 +2094,8 @@ const docTemplate = `{
"x-panel-log": {
"BeforeFunctions": [],
"bodyKeys": [],
"formatEN": "Updated the docker daemon.json ipv6 option",
"formatZH": "更新 docker daemon.json ipv6 配置",
"formatEN": "Updated the ipv6 option",
"formatZH": "更新 ipv6 配置",
"paramKeys": []
}
}
@ -2233,8 +2233,8 @@ const docTemplate = `{
"x-panel-log": {
"BeforeFunctions": [],
"bodyKeys": [],
"formatEN": "Updated the docker daemon.json log option",
"formatZH": "更新 docker daemon.json 日志配置",
"formatEN": "Updated the log option",
"formatZH": "更新日志配置",
"paramKeys": []
}
}

16
cmd/server/docs/swagger.json

@ -1437,8 +1437,8 @@
"key",
"value"
],
"formatEN": "Updated the docker daemon.json configuration [key]=\u003e[value]",
"formatZH": "更新 docker daemon.json 配置 [key]=\u003e[value]",
"formatEN": "Updated configuration [key]",
"formatZH": "更新配置 [key]",
"paramKeys": []
}
}
@ -1477,8 +1477,8 @@
"x-panel-log": {
"BeforeFunctions": [],
"bodyKeys": [],
"formatEN": "Updated the docker daemon.json configuration",
"formatZH": "更新 docker daemon.json 配置",
"formatEN": "Updated configuration file",
"formatZH": "更新配置文件",
"paramKeys": []
}
}
@ -2087,8 +2087,8 @@
"x-panel-log": {
"BeforeFunctions": [],
"bodyKeys": [],
"formatEN": "Updated the docker daemon.json ipv6 option",
"formatZH": "更新 docker daemon.json ipv6 配置",
"formatEN": "Updated the ipv6 option",
"formatZH": "更新 ipv6 配置",
"paramKeys": []
}
}
@ -2226,8 +2226,8 @@
"x-panel-log": {
"BeforeFunctions": [],
"bodyKeys": [],
"formatEN": "Updated the docker daemon.json log option",
"formatZH": "更新 docker daemon.json 日志配置",
"formatEN": "Updated the log option",
"formatZH": "更新日志配置",
"paramKeys": []
}
}

16
cmd/server/docs/swagger.yaml

@ -5948,8 +5948,8 @@ paths:
bodyKeys:
- key
- value
formatEN: Updated the docker daemon.json configuration [key]=>[value]
formatZH: 更新 docker daemon.json 配置 [key]=>[value]
formatEN: Updated configuration [key]
formatZH: 更新配置 [key]
paramKeys: []
/containers/daemonjson/update/byfile:
post:
@ -5974,8 +5974,8 @@ paths:
x-panel-log:
BeforeFunctions: []
bodyKeys: []
formatEN: Updated the docker daemon.json configuration
formatZH: 更新 docker daemon.json 配置
formatEN: Updated configuration file
formatZH: 更新配置文件
paramKeys: []
/containers/docker/operate:
post:
@ -6363,8 +6363,8 @@ paths:
x-panel-log:
BeforeFunctions: []
bodyKeys: []
formatEN: Updated the docker daemon.json ipv6 option
formatZH: 更新 docker daemon.json ipv6 配置
formatEN: Updated the ipv6 option
formatZH: 更新 ipv6 配置
paramKeys: []
/containers/limit:
get:
@ -6448,8 +6448,8 @@ paths:
x-panel-log:
BeforeFunctions: []
bodyKeys: []
formatEN: Updated the docker daemon.json log option
formatZH: 更新 docker daemon.json 日志配置
formatEN: Updated the log option
formatZH: 更新日志配置
paramKeys: []
/containers/network:
get:

11
frontend/src/utils/util.ts

@ -518,3 +518,14 @@ export function getAction(action: string) {
export function getLanguage() {
return localStorage.getItem('lang') || 'zh';
}
export function emptyLineFilter(str: string, spilt: string) {
let list = str.split(spilt);
let results = [];
for (let i = 0; i < list.length; i++) {
if (list[i].trim() !== '') {
results.push(list[i]);
}
}
return results.join(spilt);
}

3
frontend/src/views/container/setting/mirror/index.vue

@ -46,6 +46,7 @@ import ConfirmDialog from '@/components/confirm-dialog/index.vue';
import { updateDaemonJson } from '@/api/modules/container';
import DrawerHeader from '@/components/drawer-header/index.vue';
import { FormInstance } from 'element-plus';
import { emptyLineFilter } from '@/utils/util';
const emit = defineEmits<{ (e: 'search'): void }>();
@ -101,7 +102,7 @@ const onSave = async (formEl: FormInstance | undefined) => {
const onSubmit = async () => {
loading.value = true;
await updateDaemonJson('Mirrors', form.mirrors.replaceAll('\n', ','))
await updateDaemonJson('Mirrors', emptyLineFilter(form.mirrors, '\n').replaceAll('\n', ','))
.then(() => {
loading.value = false;
emit('search');

3
frontend/src/views/container/setting/registry/index.vue

@ -46,6 +46,7 @@ import ConfirmDialog from '@/components/confirm-dialog/index.vue';
import { updateDaemonJson } from '@/api/modules/container';
import DrawerHeader from '@/components/drawer-header/index.vue';
import { FormInstance } from 'element-plus';
import { emptyLineFilter } from '@/utils/util';
const emit = defineEmits<{ (e: 'search'): void }>();
@ -97,7 +98,7 @@ const onSave = async () => {
const onSubmit = async () => {
loading.value = true;
await updateDaemonJson('Registries', form.registries.replaceAll('\n', ','))
await updateDaemonJson('Registries', emptyLineFilter(form.registries, '\n').replaceAll('\n', ','))
.then(() => {
loading.value = false;
handleClose();

Loading…
Cancel
Save