Add runtime option to function API (#228)

This commit is contained in:
Janos Dobronszki
2021-10-12 10:35:40 +01:00
committed by GitHub
parent 6bf352a1fc
commit 7841367210
8 changed files with 160 additions and 53 deletions

View File

@@ -126,10 +126,13 @@ func (e *Function) Deploy(ctx context.Context, req *function.DeployRequest, rsp
if err != nil {
return err
}
if req.Runtime == "" {
return fmt.Errorf("missing runtime field, please specify nodejs14, go116 etc")
}
go func() {
// https://jsoverson.medium.com/how-to-deploy-node-js-functions-to-google-cloud-8bba05e9c10a
cmd := exec.Command("gcloud", "functions", "deploy", multitenantPrefix+"-"+req.Name, "--region", "europe-west1", "--allow-unauthenticated", "--entry-point", req.Entrypoint, "--trigger-http", "--project", e.project, "--runtime", "nodejs14")
cmd := exec.Command("gcloud", "functions", "deploy", multitenantPrefix+"-"+req.Name, "--region", "europe-west1", "--allow-unauthenticated", "--entry-point", req.Entrypoint, "--trigger-http", "--project", e.project, "--runtime", req.Runtime)
cmd.Dir = filepath.Join(gitter.RepoDir(), req.Subfolder)
outp, err := cmd.CombinedOutput()
if err != nil {
@@ -147,6 +150,7 @@ func (e *Function) Deploy(ctx context.Context, req *function.DeployRequest, rsp
"repo": req.Repo,
"subfolder": req.Subfolder,
"entrypoint": req.Entrypoint,
"runtime": req.Runtime,
})
err = s.UnmarshalJSON(jso)
if err != nil {