Skip to content

Commit b46710e

Browse files
fix: make git password not required (#951)
* fix: make password not required * fix: preserve git.password * fix: preserve git.password only if not present * fix: strip passwords from editSettings --------- Co-authored-by: svcAPLBot <174728082+svcAPLBot@users.noreply.github.com>
1 parent bb03334 commit b46710e

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/api/v1/settings/{settingId}.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Debug from 'debug'
22
import { Response } from 'express'
33
import { OpenApiRequestExt, Settings } from 'src/otomi-models'
4+
import { omit } from 'lodash'
45

56
const debug = Debug('otomi:api:v1:settings')
67

@@ -13,5 +14,9 @@ export const editSettings = async (req: OpenApiRequestExt, res: Response): Promi
1314
const ids = Object.keys(req.body as Settings)
1415
debug(`editSettings(${ids.join(',')})`)
1516
const v = await req.otomi.editSettings(req.body as Settings, settingId)
16-
res.json(v)
17+
if (v?.otomi) {
18+
res.json(omit(v, ['otomi.adminPassword', 'otomi.git.password']))
19+
} else {
20+
res.json(v)
21+
}
1722
}

src/openapi/settings.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ Settings:
261261
required:
262262
- repoUrl
263263
- username
264-
- password
265264
- email
266265
- branch
267266
adminPassword:

src/otomi-stack.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CoreV1Api, User as k8sUser, KubeConfig, V1ObjectReference } from '@kubernetes/client-node'
1+
import { CoreV1Api, KubeConfig, User as k8sUser, V1ObjectReference } from '@kubernetes/client-node'
22
import Debug from 'debug'
33

44
import { getRegions, ObjectStorageKeyRegions } from '@linode/api-v4'
@@ -503,11 +503,15 @@ export default class OtomiStack {
503503
const settings = this.getSettings()
504504
await this.editIngressApps(settings, data, settingId)
505505
const updatedSettingsData: any = { ...data }
506-
// Preserve the otomi.adminPassword when editing otomi settings
506+
// Preserve the otomi.adminPassword and otomi.git.password if not present when editing otomi settings
507507
if (settingId === 'otomi') {
508508
updatedSettingsData.otomi = {
509509
...updatedSettingsData.otomi,
510510
adminPassword: settings.otomi?.adminPassword,
511+
git: {
512+
...updatedSettingsData.otomi?.git,
513+
...(!updatedSettingsData.otomi?.git?.password && { password: settings.otomi?.git?.password }),
514+
},
511515
}
512516
// convert otomi.nodeSelector to object
513517
if (Array.isArray(updatedSettingsData.otomi.nodeSelector)) {

0 commit comments

Comments
 (0)