Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit a2272ef

Browse files
oneclickexport: add code host configs export functionality (#39855)
1 parent 72e5dc3 commit a2272ef

File tree

3 files changed

+439
-37
lines changed

3 files changed

+439
-37
lines changed

cmd/frontend/oneclickexport/export.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package oneclickexport
33
import (
44
"archive/zip"
55
"bytes"
6+
"context"
67
"io"
78
"os"
89
"path/filepath"
@@ -13,7 +14,7 @@ import (
1314
type Exporter interface {
1415
// Export accepts an ExportRequest and returns bytes of a zip archive
1516
// with requested data.
16-
Export(request ExportRequest) ([]byte, error)
17+
Export(ctx context.Context, request ExportRequest) ([]byte, error)
1718
}
1819

1920
var _ Exporter = &DataExporter{}
@@ -24,7 +25,8 @@ type DataExporter struct {
2425
}
2526

2627
type ExportRequest struct {
27-
IncludeSiteConfig bool `json:"includeSiteConfig"`
28+
IncludeSiteConfig bool `json:"includeSiteConfig"`
29+
IncludeCodeHostConfig bool `json:"includeCodeHostConfig"`
2830
}
2931

3032
// Export generates and returns a ZIP archive with the data, specified in request.
@@ -33,7 +35,7 @@ type ExportRequest struct {
3335
// this directory is zipped in the end)
3436
// 2) ExportRequest is read and each corresponding processor is invoked
3537
// 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) {
3739
// 1) creating a tmp dir
3840
dir, err := os.MkdirTemp(os.TempDir(), "export-*")
3941
if err != nil {
@@ -43,7 +45,10 @@ func (e *DataExporter) Export(request ExportRequest) ([]byte, error) {
4345

4446
// 2) tmp dir is passed to every processor
4547
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)
4752
}
4853

4954
// 3) after all request parts are processed, zip the tmp dir and return its bytes

0 commit comments

Comments
 (0)