Skip to content

Commit 9638586

Browse files
committed
Merge remote-tracking branch 'origin/main' into hide-falco
2 parents 63edb4d + 5f64fc3 commit 9638586

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/git.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { rmSync } from 'fs'
55
import { copy, ensureDir, pathExists, readFile, writeFile } from 'fs-extra'
66
import { unlink } from 'fs/promises'
77
import { glob } from 'glob'
8-
import stringifyJson from 'json-stable-stringify'
98
import jsonpath from 'jsonpath'
109
import { cloneDeep, get, isEmpty, merge, set, unset } from 'lodash'
1110
import { basename, dirname, join } from 'path'
@@ -198,8 +197,7 @@ export class Git {
198197
// ok, write new content
199198
const absolutePath = join(this.path, file)
200199
debug(`Writing to file: ${absolutePath}`)
201-
const sortedData = JSON.parse(stringifyJson(data) as string)
202-
const content = isEmpty(sortedData) ? '' : stringifyYaml(sortedData, undefined, 4)
200+
const content = stringifyYaml(data, undefined, { indent: 4, sortMapEntries: true })
203201
const dir = dirname(absolutePath)
204202
await ensureDir(dir)
205203
await writeFile(absolutePath, content, 'utf8')

src/otomi-stack.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,14 @@ export default class OtomiStack {
342342
cleanSecretPaths.push(p)
343343
} else {
344344
teams.forEach((teamId: string) => {
345-
if (p.indexOf(teamProp) === 0)
345+
if (p.indexOf(teamProp) === 0) {
346346
cleanSecretPaths.push(
347347
p
348348
.replace(teamProp, `teamConfig.${teamId}`)
349349
// add spec to the path for v2 endpoints
350350
.replace(`teamConfig.${teamId}.settings`, `teamConfig.${teamId}.settings.spec`),
351351
)
352+
}
352353
})
353354
}
354355
})
@@ -801,7 +802,7 @@ export default class OtomiStack {
801802
const configKey = this.getConfigKey('AplTeamWorkloadValues')
802803
const repo = this.createTeamConfigInRepo(teamId, configKey, [values])
803804
const fileMap = getFileMaps('').find((fm) => fm.kind === 'AplTeamWorkloadValues')!
804-
await this.git.saveConfig(repo, fileMap)
805+
await this.git.saveConfig(repo, fileMap, false)
805806
}
806807

807808
async saveTeamPolicy(teamId: string, data: AplPolicyResponse): Promise<void> {
@@ -1553,11 +1554,12 @@ export default class OtomiStack {
15531554

15541555
async createAplBuild(teamId: string, data: AplBuildRequest): Promise<AplBuildResponse> {
15551556
const buildName = `${data?.spec?.imageName}-${data?.spec?.tag}`
1556-
if (buildName.length > 128)
1557+
if (buildName.length > 128) {
15571558
throw new HttpError(
15581559
400,
15591560
'Invalid container image name, the combined image name and tag must not exceed 128 characters.',
15601561
)
1562+
}
15611563
try {
15621564
const build = this.repoService.getTeamConfigService(teamId).createBuild(data)
15631565
await this.saveTeamConfigItem(build)
@@ -1570,8 +1572,9 @@ export default class OtomiStack {
15701572
)
15711573
return build
15721574
} catch (err) {
1573-
if (err.code === 409)
1575+
if (err.code === 409) {
15741576
err.publicMessage = 'Container image name already exists, the combined image name and tag must be unique.'
1577+
}
15751578
throw err
15761579
}
15771580
}
@@ -1749,8 +1752,9 @@ export default class OtomiStack {
17491752
fileContent = fileContent.replace(regex, variables[key] as string)
17501753
})
17511754
if (file === 'tty_02_Pod.yaml') fileContent = podContentAddTargetTeam(fileContent)
1752-
if (!sessionUser.isPlatformAdmin && file === 'tty_03_Rolebinding.yaml')
1755+
if (!sessionUser.isPlatformAdmin && file === 'tty_03_Rolebinding.yaml') {
17531756
fileContent = rolebindingContentsForUsers(fileContent)
1757+
}
17541758
return fileContent
17551759
}),
17561760
)
@@ -1778,8 +1782,9 @@ export default class OtomiStack {
17781782
const { sub, isPlatformAdmin, teams } = sessionUser as { sub: string; isPlatformAdmin: boolean; teams: string[] }
17791783
const userTeams = teams.map((teamName) => `team-${teamName}`)
17801784
try {
1781-
if (await checkPodExists('team-admin', `tty-${sessionUser.sub}`))
1785+
if (await checkPodExists('team-admin', `tty-${sessionUser.sub}`)) {
17821786
await k8sdelete({ sub, isPlatformAdmin, userTeams })
1787+
}
17831788
} catch (error) {
17841789
debug('Failed to delete cloudtty')
17851790
}

0 commit comments

Comments
 (0)