Compare commits

...
8 Commits
12 changed files with 95 additions and 77 deletions
+1 -1
View File
@@ -518,7 +518,7 @@ func (a *AppInstallService) ChangeAppPort(req request.PortUpdate) error {
return nil
}
if err := updateInstallInfoInDB(req.Key, "", "port", true, strconv.FormatInt(req.Port, 10)); err != nil {
if err := updateInstallInfoInDB(req.Key, req.Name, "port", true, strconv.FormatInt(req.Port, 10)); err != nil {
return nil
}
+15 -5
View File
@@ -316,11 +316,6 @@ func (u *ContainerService) ContainerCreate(req dto.ContainerOperate) error {
return buserr.New(constant.ErrContainerName)
}
config, hostConf, networkConf, err := loadConfigInfo(true, req, nil)
if err != nil {
return err
}
global.LOG.Infof("new container info %s has been made, now start to create", req.Name)
if !checkImageExist(client, req.Image) || req.ForcePull {
if err := pullImages(ctx, client, req.Image); err != nil {
if !req.ForcePull {
@@ -329,6 +324,21 @@ func (u *ContainerService) ContainerCreate(req dto.ContainerOperate) error {
global.LOG.Errorf("force pull image %s failed, err: %v", req.Image, err)
}
}
imageInfo, _, err := client.ImageInspectWithRaw(ctx, req.Image)
if err != nil {
return err
}
if len(req.Entrypoint) == 0 {
req.Entrypoint = imageInfo.Config.Entrypoint
}
if len(req.Cmd) == 0 {
req.Cmd = imageInfo.Config.Cmd
}
config, hostConf, networkConf, err := loadConfigInfo(true, req, nil)
if err != nil {
return err
}
global.LOG.Infof("new container info %s has been made, now start to create", req.Name)
container, err := client.ContainerCreate(ctx, config, hostConf, networkConf, &v1.Platform{}, req.Name)
if err != nil {
_ = client.ContainerRemove(ctx, req.Name, types.ContainerRemoveOptions{RemoveVolumes: true, Force: true})
+1 -1
View File
@@ -625,7 +625,7 @@ func loadFailedSecureDatas(line string) dto.SSHHistory {
return data
}
index := 0
if strings.Contains("line", " invalid user") {
if strings.Contains(line, " invalid user") {
index = 2
}
data = dto.SSHHistory{
+5
View File
@@ -133,3 +133,8 @@ var (
var (
ErrFirewall = "ErrFirewall"
)
// cronjob
var (
ErrBashExecute = "ErrBashExecute"
)
+4 -1
View File
@@ -124,4 +124,7 @@ ErrConfigAlreadyExist: "A configuration file with the same name already exists"
ErrUserFindErr: "Failed to find user {{ .name }} {{ .err }}"
#ssh
ErrFirewall: "No firewalld or ufw service is detected. Please check and try again!"
ErrFirewall: "No firewalld or ufw service is detected. Please check and try again!"
#cronjob
ErrBashExecute: "Script execution error, please check the specific information in the task output text area."
+4 -1
View File
@@ -124,4 +124,7 @@ ErrConfigAlreadyExist: "已存在同名配置文件"
ErrUserFindErr: "用戶 {{ .name }} 查找失敗 {{ .err }}"
#ssh
ErrFirewall: "當前未檢測到系統 firewalld 或 ufw 服務,請檢查後重試!"
ErrFirewall: "當前未檢測到系統 firewalld 或 ufw 服務,請檢查後重試!"
#cronjob
ErrBashExecute: "腳本執行錯誤,請在任務輸出文本域中查看具體信息。"
+3
View File
@@ -125,3 +125,6 @@ ErrUserFindErr: "用户 {{ .name }} 查找失败 {{ .err }}"
#ssh
ErrFirewall: "当前未检测到系统 firewalld 或 ufw 服务,请检查后重试!"
#cronjob
ErrBashExecute: "脚本执行错误,请在任务输出文本域中查看具体信息。"
+7 -10
View File
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io"
"os/exec"
"strings"
"time"
@@ -88,23 +89,19 @@ func ExecCronjobWithTimeOut(cmdStr string, workdir string, timeout time.Duration
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
output := new(bytes.Buffer)
cmd.Stdout = io.MultiWriter(output, cmd.Stdout)
cmd.Stderr = io.MultiWriter(output, cmd.Stderr)
err := cmd.Run()
if ctx.Err() == context.DeadlineExceeded {
return "", buserr.New(constant.ErrCmdTimeout)
}
errMsg := ""
if len(stderr.String()) != 0 {
errMsg = fmt.Sprintf("stderr:\n %s", stderr.String())
err = buserr.New(constant.ErrBashExecute)
}
if len(stdout.String()) != 0 {
if len(errMsg) != 0 {
errMsg = fmt.Sprintf("%s \n\n; stdout:\n %s", errMsg, stdout.String())
} else {
errMsg = fmt.Sprintf("stdout:\n %s", stdout.String())
}
}
return errMsg, err
return output.String(), err
}
func Execf(cmdStr string, a ...interface{}) (string, error) {
-26
View File
@@ -1,26 +0,0 @@
package encrypt
import (
"fmt"
"testing"
"github.com/1Panel-dev/1Panel/backend/init/viper"
)
func TestStringEncrypt(t *testing.T) {
viper.Init()
p, err := StringEncrypt("1Panel@2022")
if err != nil {
t.Fatal(err)
}
fmt.Println(p)
}
func TestStringDecrypt(t *testing.T) {
viper.Init()
p, err := StringDecrypt("dXn5bVtea+KVLDrLJlpnPIJNfW8TAMmqX1QNMdSGp88=")
if err != nil {
t.Fatal(err)
}
fmt.Println(p)
}
+1 -1
View File
@@ -77,7 +77,7 @@
</el-button>
</template>
</el-table-column>
<el-table-column :label="$t('cronjob.cronSpec')" :min-width="120">
<el-table-column :label="$t('cronjob.cronSpec')" show-overflow-tooltip :min-width="120">
<template #default="{ row }">
<span v-if="row.specType.indexOf('N') === -1 || row.specType === 'perWeek'">
{{ $t('cronjob.' + row.specType) }}&nbsp;
+33 -25
View File
@@ -125,23 +125,29 @@
<template #main>
<div class="mainClass">
<el-row :gutter="20" v-show="hasRecords" class="mainRowClass">
<el-col :span="8">
<el-col :span="6">
<div>
<ul class="infinite-list" style="overflow: auto">
<li
<el-card
v-for="(item, index) in records"
:key="index"
@click="forDetail(item)"
class="infinite-list-item"
>
<el-icon v-if="item.status === 'Success'"><Select /></el-icon>
<el-icon v-if="item.status === 'Waiting'"><Loading /></el-icon>
<el-icon v-if="item.status === 'Failed'"><CloseBold /></el-icon>
<span v-if="item.id === currentRecord.id" style="color: red">
<el-tag v-if="item.status === 'Success'" type="success">
{{ $t('commons.status.success') }}
</el-tag>
<el-tag v-if="item.status === 'Waiting'" type="info">
{{ $t('commons.status.waiting') }}
</el-tag>
<el-tag v-if="item.status === 'Failed'" type="danger">
{{ $t('commons.status.failed') }}
</el-tag>
<span v-if="item.id === currentRecord.id" class="select-card">
{{ dateFormat(0, 0, item.startTime) }}
</span>
<span v-else>{{ dateFormat(0, 0, item.startTime) }}</span>
</li>
</el-card>
</ul>
<div style="margin-top: 10px; font-size: 12px; float: right">
<el-pagination
@@ -158,7 +164,7 @@
</div>
</div>
</el-col>
<el-col :span="16">
<el-col :span="18">
<el-form label-position="top" :v-key="refresh">
<el-row type="flex" justify="center">
<el-form-item class="descriptionWide" v-if="isBackup()">
@@ -714,30 +720,32 @@ defineExpose({
<style lang="scss" scoped>
.infinite-list {
height: calc(100vh - 435px);
height: calc(100vh - 416px);
padding: 0;
margin: 0;
}
.infinite-list .infinite-list-item {
display: flex;
align-items: center;
justify-content: center;
height: 30px;
background: var(--el-color-primary-light-9);
margin: 10px;
color: var(--el-color-primary);
cursor: pointer;
&:hover {
.el-card {
border: var(--panel-border) !important;
&:hover {
border: 1px solid var(--el-color-primary) !important;
box-shadow: 2px 2px 2px #888888;
}
display: flex;
align-items: center;
justify-content: center;
height: 30px;
background: var(--el-color-primary-light-9);
margin: 10px;
font-weight: 500;
color: red;
height: 40px;
font-size: 14px;
margin: 5px;
cursor: pointer;
}
.el-tag {
margin-right: 15px;
}
}
.select-card {
color: var(--el-color-primary);
}
.descriptionWide {
width: 40%;
}
@@ -54,11 +54,18 @@
prop="varsJson.code"
:rules="rules.driveCode"
>
<el-input clearable v-model.trim="dialogData.rowData!.varsJson['code']">
<template #append>
<el-button @click="jumpAzure">{{ $t('setting.loadCode') }}</el-button>
</template>
</el-input>
<div style="width: 100%">
<el-input
style="width: calc(100% - 80px)"
:autosize="{ minRows: 3, maxRows: 15 }"
type="textarea"
clearable
v-model.trim="dialogData.rowData!.varsJson['code']"
/>
<el-button class="append-button" @click="jumpAzure">
{{ $t('setting.loadCode') }}
</el-button>
</div>
<span class="input-help">
{{ $t('setting.codeHelper') }}
<el-link
@@ -269,7 +276,7 @@ const rules = reactive({
driveCode: [{ validator: checkDriveCode, required: true, trigger: 'blur' }],
});
function checkDriveCode(rule: any, value: any, callback: any) {
const reg = /^[A-Za-z0-9_.-]{32,60}$/;
const reg = /^[A-Za-z0-9_.-]+$/;
if (!reg.test(value)) {
return callback(new Error(i18n.global.t('setting.codeWarning')));
}
@@ -421,3 +428,11 @@ defineExpose({
acceptParams,
});
</script>
<style lang="scss" scoped>
.append-button {
width: 80px;
background-color: var(--el-fill-color-light);
color: var(--el-color-info);
}
</style>