Skip to content

Commit ef982ee

Browse files
committed
Merge remote-tracking branch 'origin/dev' into test
2 parents 3972d48 + c757639 commit ef982ee

File tree

6 files changed

+67
-112
lines changed

6 files changed

+67
-112
lines changed

configs/config.yaml

-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ data:
2424
connection: "/data/sqlite3/answer.db"
2525
cache:
2626
file_path: "/data/cache/cache.db"
27-
ssl:
28-
enabled: "no"
29-
mode: "require"
30-
cert_file: "/data/cache/ssl/certs/server-ca.pem"
31-
key_file: "/data/cache/ssl/certs/client-cert.pem"
32-
pem_file: "/data/cache/ssl/certs/client-key.pem"
3327
i18n:
3428
bundle_dir: "/data/i18n"
3529
swaggerui:

i18n/en_US.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -1663,15 +1663,15 @@ ui:
16631663
label: Off
16641664
ssl_mode:
16651665
label: SSL Mode
1666-
key_file:
1667-
placeholder: Key file path
1668-
msg: Path to Key file cannot be empty
1669-
cert_file:
1670-
placeholder: Cert file path
1671-
msg: Path to Cert file cannot be empty
1672-
pem_file:
1673-
placeholder: Pem file path
1674-
msg: Path to Pem file cannot be empty
1666+
ssl_root_cert:
1667+
placeholder: sslrootcert file path
1668+
msg: Path to sslrootcert file cannot be empty
1669+
ssl_cert:
1670+
placeholder: sslcert file path
1671+
msg: Path to sslcert file cannot be empty
1672+
ssl_key:
1673+
placeholder: sslkey file path
1674+
msg: Path to sslkey file cannot be empty
16751675
config_yaml:
16761676
title: Create config.yaml
16771677
label: The config.yaml file created.

i18n/zh_CN.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1627,14 +1627,14 @@ ui:
16271627
label:
16281628
ssl_mode:
16291629
label: SSL 模式
1630-
key_file:
1631-
placeholder: Key 文件路径
1630+
ssl_root_cert:
1631+
placeholder: sslrootcert 文件路径
16321632
msg: 文件路径不能为空
1633-
cert_file:
1634-
placeholder: Cert 文件路径
1633+
ssl_cert:
1634+
placeholder: sslcert 文件路径
16351635
msg: 文件路径不能为空
1636-
pem_file:
1637-
placeholder: Pem 文件路径
1636+
ssl_key:
1637+
placeholder: sslkey 文件路径
16381638
msg: 文件路径不能为空
16391639
config_yaml:
16401640
title: 创建 config.yaml

internal/install/install_req.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/apache/answer/pkg/checker"
3030
"github.com/apache/answer/pkg/dir"
3131
"github.com/segmentfault/pacman/errors"
32-
"github.com/segmentfault/pacman/log"
3332
"xorm.io/xorm/schemas"
3433
)
3534

@@ -42,17 +41,17 @@ type CheckConfigFileResp struct {
4241

4342
// CheckDatabaseReq check database
4443
type CheckDatabaseReq struct {
45-
DbType string `validate:"required,oneof=postgres sqlite3 mysql" json:"db_type"`
46-
DbUsername string `json:"db_username"`
47-
DbPassword string `json:"db_password"`
48-
DbHost string `json:"db_host"`
49-
DbName string `json:"db_name"`
50-
DbFile string `json:"db_file"`
51-
Ssl bool `json:"ssl_enabled"`
52-
SslMode string `json:"ssl_mode"`
53-
SslCrt string `json:"pem_file"`
54-
SslKey string `json:"key_file"`
55-
SslCrtClient string `json:"cert_file"`
44+
DbType string `validate:"required,oneof=postgres sqlite3 mysql" json:"db_type"`
45+
DbUsername string `json:"db_username"`
46+
DbPassword string `json:"db_password"`
47+
DbHost string `json:"db_host"`
48+
DbName string `json:"db_name"`
49+
DbFile string `json:"db_file"`
50+
Ssl bool `json:"ssl_enabled"`
51+
SslMode string `json:"ssl_mode"`
52+
SslRootCert string `json:"ssl_root_cert"`
53+
SslKey string `json:"ssl_key"`
54+
SslCert string `json:"ssl_cert"`
5655
}
5756

5857
// GetConnection get connection string
@@ -73,17 +72,18 @@ func (r *CheckDatabaseReq) GetConnection() string {
7372
return fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=%s",
7473
host, port, r.DbUsername, r.DbPassword, r.DbName, r.SslMode)
7574
} else if r.SslMode == "verify-ca" || r.SslMode == "verify-full" {
76-
if dir.CheckFileExist(r.SslCrt) {
77-
log.Warnf("ssl crt file not exist: %s", r.SslCrt)
75+
connection := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=%s",
76+
host, port, r.DbUsername, r.DbPassword, r.DbName, r.SslMode)
77+
if len(r.SslRootCert) > 0 && dir.CheckFileExist(r.SslRootCert) {
78+
connection += fmt.Sprintf(" sslrootcert=%s", r.SslRootCert)
7879
}
79-
if dir.CheckFileExist(r.SslCrtClient) {
80-
log.Warnf("ssl crt client file not exist: %s", r.SslCrtClient)
80+
if len(r.SslCert) > 0 && dir.CheckFileExist(r.SslCert) {
81+
connection += fmt.Sprintf(" sslcert=%s", r.SslCert)
8182
}
82-
if dir.CheckFileExist(r.SslKey) {
83-
log.Warnf("ssl key file not exist: %s", r.SslKey)
83+
if len(r.SslKey) > 0 && dir.CheckFileExist(r.SslKey) {
84+
connection += fmt.Sprintf(" sslkey=%s", r.SslKey)
8485
}
85-
return fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=%s sslrootcert=%s sslcert=%s sslkey=%s",
86-
host, port, r.DbUsername, r.DbPassword, r.DbName, r.SslMode, r.SslCrt, r.SslCrtClient, r.SslKey)
86+
return connection
8787
}
8888
}
8989
return ""

ui/src/pages/Install/components/SecondStep/index.tsx

+23-62
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,8 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
6363

6464
const checkValidated = (): boolean => {
6565
let bol = true;
66-
const {
67-
db_type,
68-
db_username,
69-
db_password,
70-
db_host,
71-
db_name,
72-
db_file,
73-
ssl_enabled,
74-
ssl_mode,
75-
key_file,
76-
cert_file,
77-
pem_file,
78-
} = data;
66+
const { db_type, db_username, db_password, db_host, db_name, db_file } =
67+
data;
7968

8069
if (db_type.value !== 'sqlite3') {
8170
if (!db_username.value) {
@@ -111,34 +100,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
111100
errorMsg: t('db_name.msg'),
112101
};
113102
}
114-
if (db_type.value === 'postgres') {
115-
if (ssl_enabled.value && ssl_mode.value !== 'require') {
116-
if (!key_file.value) {
117-
bol = false;
118-
data.key_file = {
119-
value: '',
120-
isInvalid: true,
121-
errorMsg: t('key_file.msg'),
122-
};
123-
}
124-
if (!pem_file.value) {
125-
bol = false;
126-
data.pem_file = {
127-
value: '',
128-
isInvalid: true,
129-
errorMsg: t('pem_file.msg'),
130-
};
131-
}
132-
if (!cert_file.value) {
133-
bol = false;
134-
data.cert_file = {
135-
value: '',
136-
isInvalid: true,
137-
errorMsg: t('cert_file.msg'),
138-
};
139-
}
140-
}
141-
}
142103
} else if (!db_file.value) {
143104
bol = false;
144105
data.db_file = {
@@ -255,17 +216,17 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
255216
isInvalid: false,
256217
errorMsg: '',
257218
},
258-
key_file: {
219+
ssl_root_cert: {
259220
value: '',
260221
isInvalid: false,
261222
errorMsg: '',
262223
},
263-
cert_file: {
224+
ssl_cert: {
264225
value: '',
265226
isInvalid: false,
266227
errorMsg: '',
267228
},
268-
pem_file: {
229+
ssl_key: {
269230
value: '',
270231
isInvalid: false,
271232
errorMsg: '',
@@ -304,15 +265,15 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
304265
(data.ssl_mode.value === 'verify-ca' ||
305266
data.ssl_mode.value === 'verify-full') && (
306267
<Row className="mb-3">
307-
<Form.Group as={Col} controlId="key_file">
268+
<Form.Group as={Col} controlId="ssl_root_cert">
308269
<Form.Control
309-
placeholder={t('key_file.placeholder')}
310-
aria-label="key_file"
270+
placeholder={t('ssl_root_cert.placeholder')}
271+
aria-label="ssl_root_cert"
311272
aria-describedby="basic-addon1"
312-
isInvalid={data.key_file.isInvalid}
273+
isInvalid={data.ssl_root_cert.isInvalid}
313274
onChange={(e) => {
314275
changeCallback({
315-
key_file: {
276+
ssl_root_cert: {
316277
value: e.target.value,
317278
isInvalid: false,
318279
errorMsg: '',
@@ -322,18 +283,18 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
322283
required
323284
/>
324285
<Form.Control.Feedback type="invalid">
325-
{`${data.key_file.errorMsg}`}
286+
{`${data.ssl_root_cert.errorMsg}`}
326287
</Form.Control.Feedback>
327288
</Form.Group>
328-
<Form.Group as={Col} controlId="cert_file">
289+
<Form.Group as={Col} controlId="ssl_cert">
329290
<Form.Control
330-
placeholder={t('cert_file.placeholder')}
331-
aria-label="cert_file"
291+
placeholder={t('ssl_cert.placeholder')}
292+
aria-label="ssl_cert"
332293
aria-describedby="basic-addon1"
333-
isInvalid={data.cert_file.isInvalid}
294+
isInvalid={data.ssl_cert.isInvalid}
334295
onChange={(e) => {
335296
changeCallback({
336-
cert_file: {
297+
ssl_cert: {
337298
value: e.target.value,
338299
isInvalid: false,
339300
errorMsg: '',
@@ -343,18 +304,18 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
343304
required
344305
/>
345306
<Form.Control.Feedback type="invalid">
346-
{`${data.cert_file.errorMsg}`}
307+
{`${data.ssl_cert.errorMsg}`}
347308
</Form.Control.Feedback>
348309
</Form.Group>
349-
<Form.Group as={Col} controlId="pem_file">
310+
<Form.Group as={Col} controlId="ssl_key">
350311
<Form.Control
351-
placeholder={t('pem_file.placeholder')}
352-
aria-label="pem_file"
312+
placeholder={t('ssl_key.placeholder')}
313+
aria-label="ssl_key"
353314
aria-describedby="basic-addon1"
354-
isInvalid={data.pem_file.isInvalid}
315+
isInvalid={data.ssl_key.isInvalid}
355316
onChange={(e) => {
356317
changeCallback({
357-
pem_file: {
318+
ssl_key: {
358319
value: e.target.value,
359320
isInvalid: false,
360321
errorMsg: '',
@@ -364,7 +325,7 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
364325
required
365326
/>
366327
<Form.Control.Feedback type="invalid">
367-
{`${data.pem_file.errorMsg}`}
328+
{`${data.ssl_key.errorMsg}`}
368329
</Form.Control.Feedback>
369330
</Form.Group>
370331
</Row>

ui/src/pages/Install/index.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,17 @@ const Index: FC = () => {
151151
isInvalid: false,
152152
errorMsg: '',
153153
},
154-
pem_file: {
154+
ssl_key: {
155155
value: '',
156156
isInvalid: false,
157157
errorMsg: '',
158158
},
159-
key_file: {
159+
ssl_root_cert: {
160160
value: '',
161161
isInvalid: false,
162162
errorMsg: '',
163163
},
164-
cert_file: {
164+
ssl_cert: {
165165
value: '',
166166
isInvalid: false,
167167
errorMsg: '',
@@ -226,9 +226,9 @@ const Index: FC = () => {
226226
db_file: formData.db_file.value,
227227
ssl_enabled: formData.ssl_enabled.value,
228228
ssl_mode: formData.ssl_mode.value,
229-
pem_file: formData.pem_file.value,
230-
key_file: formData.key_file.value,
231-
cert_file: formData.cert_file.value,
229+
ssl_key: formData.ssl_key.value,
230+
ssl_root_cert: formData.ssl_root_cert.value,
231+
ssl_cert: formData.ssl_cert.value,
232232
};
233233
installInit(params)
234234
.then(() => {
@@ -250,9 +250,9 @@ const Index: FC = () => {
250250
db_file: formData.db_file.value,
251251
ssl_enabled: formData.ssl_enabled.value,
252252
ssl_mode: formData.ssl_mode.value,
253-
pem_file: formData.pem_file.value,
254-
key_file: formData.key_file.value,
255-
cert_file: formData.cert_file.value,
253+
ssl_key: formData.ssl_key.value,
254+
ssl_root_cert: formData.ssl_root_cert.value,
255+
ssl_cert: formData.ssl_cert.value,
256256
};
257257
dbCheck(params)
258258
.then(() => {

0 commit comments

Comments
 (0)