Files
fission-console/console/internal/runtime/archive.go
T

23 lines
866 B
Go

package runtime
// BuildDeployArchive creates a deployment archive for a given language and code.
// For Node.js, it creates a zip with an ESM wrapper.
// For script languages (PHP, Ruby), it creates a zip with the correct entrypoint filename.
// For others, it returns the code as is.
func BuildDeployArchive(lang, code string) ([]byte, error) {
switch lang {
case "nodejs":
return BuildJSDeployZip(code)
case "php":
return BuildScriptZip(code, "main.php")
case "ruby":
return BuildScriptZip(code, "handler.rb")
case "python", "go", "perl": // Go is a special case handled in CreateFunction, but for archive purposes it's just the source.
return []byte(code), nil
default:
// Allow unknown languages but treat them as simple scripts.
// The environment itself will fail later if the language is truly unsupported.
return []byte(code), nil
}
}