@@ -3,6 +3,7 @@ package oneclickexport
3
3
import (
4
4
"archive/zip"
5
5
"bytes"
6
+ "context"
6
7
"io"
7
8
"os"
8
9
"path/filepath"
@@ -13,7 +14,7 @@ import (
13
14
type Exporter interface {
14
15
// Export accepts an ExportRequest and returns bytes of a zip archive
15
16
// with requested data.
16
- Export (request ExportRequest ) ([]byte , error )
17
+ Export (ctx context. Context , request ExportRequest ) ([]byte , error )
17
18
}
18
19
19
20
var _ Exporter = & DataExporter {}
@@ -24,7 +25,8 @@ type DataExporter struct {
24
25
}
25
26
26
27
type ExportRequest struct {
27
- IncludeSiteConfig bool `json:"includeSiteConfig"`
28
+ IncludeSiteConfig bool `json:"includeSiteConfig"`
29
+ IncludeCodeHostConfig bool `json:"includeCodeHostConfig"`
28
30
}
29
31
30
32
// Export generates and returns a ZIP archive with the data, specified in request.
@@ -33,7 +35,7 @@ type ExportRequest struct {
33
35
// this directory is zipped in the end)
34
36
// 2) ExportRequest is read and each corresponding processor is invoked
35
37
// 3) Tmp directory is zipped after all the Processors finished their job
36
- func (e * DataExporter ) Export (request ExportRequest ) ([]byte , error ) {
38
+ func (e * DataExporter ) Export (ctx context. Context , request ExportRequest ) ([]byte , error ) {
37
39
// 1) creating a tmp dir
38
40
dir , err := os .MkdirTemp (os .TempDir (), "export-*" )
39
41
if err != nil {
@@ -43,7 +45,10 @@ func (e *DataExporter) Export(request ExportRequest) ([]byte, error) {
43
45
44
46
// 2) tmp dir is passed to every processor
45
47
if request .IncludeSiteConfig {
46
- e .configProcessors ["siteConfig" ].Process (ConfigRequest {}, dir )
48
+ e .configProcessors ["siteConfig" ].Process (ctx , ConfigRequest {}, dir )
49
+ }
50
+ if request .IncludeCodeHostConfig {
51
+ e .configProcessors ["codeHostConfig" ].Process (ctx , ConfigRequest {}, dir )
47
52
}
48
53
49
54
// 3) after all request parts are processed, zip the tmp dir and return its bytes
0 commit comments