feat: added downloading templated archives
This commit is contained in:
parent
1ebea8cb73
commit
98f9acad5d
5 changed files with 48 additions and 23 deletions
|
|
@ -115,7 +115,7 @@ func (p *Jinja2) Run(store storage.KVStore, args []string) error {
|
|||
}
|
||||
|
||||
// write render templates to data store output
|
||||
store.Set("out", output.String())
|
||||
store.Set("out", output.Bytes())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ func (p *SmdClient) Run(store storage.KVStore, args []string) error {
|
|||
// write data back to shared data store to be used by other plugins
|
||||
bytes, err = json.Marshal(client)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(smd) failed to marshal SMD client: %v")
|
||||
return fmt.Errorf("(smd) failed to marshal SMD client: %v", err)
|
||||
}
|
||||
store.Set("shared", bytes)
|
||||
|
||||
|
|
|
|||
|
|
@ -53,13 +53,14 @@ func (s *Service) Download() http.HandlerFunc {
|
|||
// determine if path is directory, file, or exists
|
||||
if fileInfo, err = os.Stat(path); err == nil {
|
||||
if fileInfo.IsDir() {
|
||||
// get the final archive path
|
||||
archivePath := fmt.Sprintf("%d.tar.gz", time.Now().Unix())
|
||||
|
||||
log.Debug().
|
||||
Str("archive_path", archivePath).
|
||||
Str("type", "directory").
|
||||
Msg("Service.Download()")
|
||||
|
||||
// get the final archive path
|
||||
archivePath := fmt.Sprintf("%d.tar.gz", time.Now().Unix())
|
||||
out, err = os.Create(archivePath)
|
||||
if err != nil {
|
||||
s.writeErrorResponse(w, fmt.Sprintf("failed to create named file: %v", err), http.StatusInternalServerError)
|
||||
|
|
@ -157,7 +158,7 @@ func (s *Service) Download() http.HandlerFunc {
|
|||
s.writeErrorResponse(w, fmt.Sprintf("failed to get data from hook: %v", err), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Write([]byte(data.(string)))
|
||||
w.Write(data.([]byte))
|
||||
} else {
|
||||
w.Write(contents)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue