@@ -181,6 +181,7 @@ interface FunctionInfo {
181181 name : string ;
182182 dir : string ;
183183 port : number ;
184+ type : string ;
184185}
185186
186187const K8S_TEMPLATES_DIR : string = path . resolve ( TEMPLATES_DIR , 'k8s' ) ;
@@ -220,18 +221,20 @@ function generateFunctionsConfigMap(fns: FunctionInfo[], perFunction?: FunctionI
220221}
221222
222223function generateSkaffoldYaml ( fns : FunctionInfo [ ] ) : void {
223- const profileTemplate = readTemplate ( 'skaffold-profile.yaml' ) ;
224+ const nodeProfileTemplate = readTemplate ( 'skaffold-profile.yaml' ) ;
225+ const pythonProfileTemplate = readTemplate ( 'skaffold-profile-python.yaml' ) ;
224226 const skaffoldTemplate = readTemplate ( 'skaffold.yaml' ) ;
225227
226- // Render per-function profiles from template
227- const perFnProfiles = fns . map ( ( fn ) =>
228- renderTemplate ( profileTemplate , {
228+ // Render per-function profiles from template (select based on type)
229+ const perFnProfiles = fns . map ( ( fn ) => {
230+ const template = fn . type === 'python' ? pythonProfileTemplate : nodeProfileTemplate ;
231+ return renderTemplate ( template , {
229232 name : fn . name ,
230233 dir : fn . dir ,
231234 port : String ( fn . port ) ,
232235 namespace : K8S_NAMESPACE ,
233- } ) . trimEnd ( )
234- ) . join ( '\n' ) ;
236+ } ) . trimEnd ( ) ;
237+ } ) . join ( '\n' ) ;
235238
236239 // Build dynamic lists for aggregate profiles
237240 const allRawYaml = fns
@@ -247,10 +250,24 @@ function generateSkaffoldYaml(fns: FunctionInfo[]): void {
247250 ] . join ( '\n' ) )
248251 . join ( '\n' ) ;
249252
253+ // Add Python artifacts if there are Python functions
254+ const hasPython = fns . some ( ( fn ) => fn . type === 'python' ) ;
255+ const pythonArtifacts = hasPython ? ` - image: constructive-functions-python
256+ context: .
257+ docker:
258+ dockerfile: Dockerfile.python.dev
259+ sync:
260+ manual:
261+ - src: 'functions/**/*.py'
262+ dest: /usr/src/app
263+ - src: 'generated/**/*.py'
264+ dest: /usr/src/app` : '' ;
265+
250266 const skaffold = renderTemplate ( skaffoldTemplate , {
251267 per_function_profiles : perFnProfiles ,
252268 all_raw_yaml : allRawYaml ,
253269 all_port_forwards : allPortForwards ,
270+ python_artifacts : pythonArtifacts ,
254271 namespace : K8S_NAMESPACE ,
255272 } ) ;
256273
@@ -327,17 +344,21 @@ function main(): void {
327344 }
328345 }
329346
330- // Symlink handler.ts
331- const handlerTarget = path . join ( fnDir , 'handler.ts' ) ;
332- if ( fs . existsSync ( handlerTarget ) ) {
333- const linked = ensureSymlink ( handlerTarget , path . join ( genDir , 'handler.ts' ) ) ;
347+ // Symlink handler.ts or handler.py
348+ const handlerTsTarget = path . join ( fnDir , 'handler.ts' ) ;
349+ const handlerPyTarget = path . join ( fnDir , 'handler.py' ) ;
350+ if ( fs . existsSync ( handlerTsTarget ) ) {
351+ const linked = ensureSymlink ( handlerTsTarget , path . join ( genDir , 'handler.ts' ) ) ;
334352 if ( linked ) console . log ( ` - handler.ts -> functions/${ fnName } /handler.ts` ) ;
353+ } else if ( fs . existsSync ( handlerPyTarget ) ) {
354+ const linked = ensureSymlink ( handlerPyTarget , path . join ( genDir , 'handler.py' ) ) ;
355+ if ( linked ) console . log ( ` - handler.py -> functions/${ fnName } /handler.py` ) ;
335356 }
336357
337- // Symlink any .d.ts files
358+ // Symlink any .d.ts or .py files (excluding handler.py which is handled above)
338359 const files = fs . readdirSync ( fnDir ) as string [ ] ;
339360 for ( const file of files ) {
340- if ( file . endsWith ( '.d.ts' ) ) {
361+ if ( file . endsWith ( '.d.ts' ) || ( file . endsWith ( '.py' ) && file !== 'handler.py' ) ) {
341362 const target = path . join ( fnDir , file ) ;
342363 const linked = ensureSymlink ( target , path . join ( genDir , file ) ) ;
343364 if ( linked ) console . log ( ` - ${ file } -> functions/${ fnName } /${ file } ` ) ;
@@ -388,6 +409,7 @@ function main(): void {
388409 name : allManifests [ i ] . name ,
389410 dir,
390411 port : allManifests [ i ] . port ,
412+ type : allManifests [ i ] . type || DEFAULT_TEMPLATE ,
391413 } ) ) ,
392414 } ;
393415
0 commit comments