Skip to content

Commit 2be2b14

Browse files
committed
feat: load id and name
1 parent 332fdcb commit 2be2b14

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

src/common/repo.ts

+22-11
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,6 @@ export async function loadToSpec(
554554
if (hasCorrespondingDecryptedFile(filePath, files)) return
555555
promises.push(deps.loadFileToSpec(filePath, fileMap, spec))
556556
})
557-
558557
await Promise.all(promises)
559558
}
560559

@@ -565,18 +564,30 @@ export async function loadFileToSpec(
565564
deps = { loadYaml },
566565
): Promise<void> {
567566
const jsonPath = getJsonPath(fileMap, filePath)
568-
const data = await deps.loadYaml(filePath)
569-
if (fileMap.processAs === 'arrayItem') {
570-
const ref: Record<string, any>[] = get(spec, jsonPath)
571-
ref.push(data?.spec)
572-
} else {
573-
const ref: Record<string, any> = get(spec, jsonPath)
574-
// Decrypted secrets may need to be merged with plain text specs
575-
const newRef = merge(cloneDeep(ref), data?.spec)
576-
set(spec, jsonPath, newRef)
567+
const data = (await deps.loadYaml(filePath)) || {}
568+
569+
try {
570+
if (!filePath.includes('secrets.')) {
571+
data.id = data.metadata.name
572+
if (fileMap.resourceGroup === 'team') {
573+
data.teamId = data.metadata.labels['apl.io/teamId']
574+
}
575+
}
576+
if (fileMap.processAs === 'arrayItem') {
577+
const ref: Record<string, any>[] = get(spec, jsonPath)
578+
ref.push(data?.spec)
579+
} else {
580+
const ref: Record<string, any> = get(spec, jsonPath)
581+
// Decrypted secrets may need to be merged with plain text specs
582+
const newRef = merge(cloneDeep(ref), data?.spec)
583+
set(spec, jsonPath, newRef)
584+
}
585+
} catch (e) {
586+
console.log(filePath)
587+
console.log(fileMap)
588+
throw e
577589
}
578590
}
579-
580591
export async function getKmsSettings(envDir: string, deps = { loadToSpec }): Promise<Record<string, any>> {
581592
const kmsFiles = getFileMap('AplKms', envDir)
582593
const spec = {}

0 commit comments

Comments
 (0)