Skip to content

Commit

Permalink
fix directory in templates (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
reddec committed Dec 1, 2020
1 parent e5518ff commit e141719
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions application/lambda/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"bytes"
"context"
"fmt"
"github.com/reddec/trusted-cgi/internal"
"github.com/reddec/trusted-cgi/templates"
"github.com/reddec/trusted-cgi/types"
"io/ioutil"
"os"
"os/exec"
"path/filepath"

"github.com/reddec/trusted-cgi/internal"
"github.com/reddec/trusted-cgi/templates"
"github.com/reddec/trusted-cgi/types"
)

// Create dummy public lambda in defined path with manifest based on execution specified binary with args
Expand Down Expand Up @@ -53,7 +54,11 @@ func FromTemplate(ctx context.Context, template templates.Template, path string)
}
for fileName, content := range template.Files {
destFile := filepath.Join(path, fileName)
err := ioutil.WriteFile(destFile, []byte(content), 0755)
err := os.MkdirAll(filepath.Dir(destFile), 0755)
if err != nil {
return nil, fmt.Errorf("create file %s directory: %w", fileName, err)
}
err = ioutil.WriteFile(destFile, []byte(content), 0755)
if err != nil {
return nil, fmt.Errorf("write file %s content: %w", fileName, err)
}
Expand Down

0 comments on commit e141719

Please sign in to comment.