@@ -554,7 +554,6 @@ export async function loadToSpec(
554
554
if ( hasCorrespondingDecryptedFile ( filePath , files ) ) return
555
555
promises . push ( deps . loadFileToSpec ( filePath , fileMap , spec ) )
556
556
} )
557
-
558
557
await Promise . all ( promises )
559
558
}
560
559
@@ -565,18 +564,30 @@ export async function loadFileToSpec(
565
564
deps = { loadYaml } ,
566
565
) : Promise < void > {
567
566
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
577
589
}
578
590
}
579
-
580
591
export async function getKmsSettings ( envDir : string , deps = { loadToSpec } ) : Promise < Record < string , any > > {
581
592
const kmsFiles = getFileMap ( 'AplKms' , envDir )
582
593
const spec = { }
0 commit comments