Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions deploy.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
package main

import (
"os"
"os/exec"
"github.com/flowup/cloudfunc/shim"
"fmt"
"html/template"
"os"
"os/exec"
"path/filepath"
"strconv"

"github.com/flowup/cloudfunc/shim"
)

// Function represents a configuration of a single function
type Function struct {
Source string `mapstructure:"source"`
Name string `mapstructure:"name"`
StageBucket string `mapstructure:"bucket"`
Memory int `mapstructure:"memory"`
Timeout int `mapstructure:"timeout"`
Memory int `mapstructure:"memory"`
Timeout int `mapstructure:"timeout"`
}

// ToArray creates an array of function arguments that are passed into the
Expand Down Expand Up @@ -43,7 +45,7 @@ func (f *Function) ToArray() []string {
// Deploy performs deployment of a given function configuration
func Deploy(function *Function) error {
// set the folder name constant
folderName := "__deploy__" + function.Name
folderName := filepath.Join("__deploy__" + function.Name)

// create the deployment folder and defer it's removal
err := os.Mkdir(folderName, os.ModePerm)
Expand Down Expand Up @@ -71,7 +73,7 @@ func Deploy(function *Function) error {
return err
}

shimFile, err := os.Create(folderName + "/index.js")
shimFile, err := os.Create(filepath.Join(folderName + "index.js"))
if err != nil {
return err
}
Expand All @@ -82,7 +84,6 @@ func Deploy(function *Function) error {
// change dir to the deployment folder and back
os.Chdir(folderName)


fmt.Println("Deploying function", function.Name, "to bucket", function.StageBucket)
// deploy the function
args := []string{"beta", "functions", "deploy", function.Name}
Expand Down