@@ -233,9 +233,7 @@ subCommands:
233233 name : " source"
234234 description : " function source file path"
235235 shorthand : " s"
236- default : |
237- def main(event, context):
238- return "Hello World!"
236+ default : " "
239237 - type : path
240238 name : " dependencies"
241239 description : " function dependencies file path"
@@ -258,6 +256,11 @@ subCommands:
258256 shorthand : o
259257 description : " Output format. It can be json or yaml."
260258 default : " "
259+ - type : string
260+ name : " version"
261+ description : " specifies which version of python runtime should be used {3.12|3.14}"
262+ shorthand : " v"
263+ default : " 3.12"
261264 with :
262265 output : ${{ .flags.output.value }}
263266 dryRun : ${{ .flags.dryrun.value }}
@@ -269,14 +272,23 @@ subCommands:
269272 namespace : ${{ .flags.namespace.value }}
270273 spec :
271274 runtimeImageOverride : ${{ .flags.runtimeimageoverride.value }}
272- runtime : python312
275+ runtime : python${{ .flags.version.value | replace "." "" }}
273276 replicas : ${{ .flags.replicas.value }}
274277 env : ${{ .flags.env.value | toEnvs }}
275278 secretMounts : ${{ .flags.secretmount.value | toArray "{'secretName':'{{.key}}','mountPath':'{{.value}}'}" }}
276279 source :
277280 inline :
278281 source : |
282+ ${{ if .flags.source.value -}}
279283 ${{ .flags.source.value | newLineIndent 20 }}
284+ ${{- else -}}${{ if eq .flags.version.value "3.12" -}}
285+ def main(event, context):
286+ return "Hello World!"
287+ ${{- else -}}
288+ import sdk
289+ def main():
290+ return "Hello World!"
291+ ${{- end }}${{- end }}
280292 dependencies : |
281293 ${{ .flags.dependencies.value | newLineIndent 20 }}
282294 - metadata :
@@ -304,12 +316,7 @@ subCommands:
304316 name : " source"
305317 description : " function source file path"
306318 shorthand : " s"
307- default : |
308- module.exports = {
309- main: function(event, context) {
310- return 'Hello World!'
311- }
312- }
319+ default : " "
313320 - type : path
314321 name : " dependencies"
315322 description : " function dependencies file path"
@@ -362,7 +369,18 @@ subCommands:
362369 source :
363370 inline :
364371 source : |
372+ ${{ if .flags.source.value -}}
365373 ${{ .flags.source.value | newLineIndent 20 }}
374+ ${{- else}}${{ if lt (.flags.version.value | atoi) 26 -}}
375+ module.exports = {
376+ main: function(event, context) {
377+ return 'Hello Worsld!'
378+ }
379+ }
380+ ${{- else -}}
381+ export function main(req, res) {
382+ res.send('Hello World!');
383+ }${{- end }}${{- end }}
366384 dependencies : |
367385 ${{ .flags.dependencies.value | newLineIndent 20 }}
368386
0 commit comments