@@ -20,23 +20,24 @@ import (
2020 "github.com/couchbase/sync_gateway/db"
2121)
2222
23- type SyncFnDryRunLogging struct {
23+ type DryRunLogging struct {
2424 Errors []string `json:"errors"`
2525 Info []string `json:"info"`
2626}
2727
2828type SyncFnDryRun struct {
29- Channels base.Set `json:"channels"`
30- Access channels.AccessMap `json:"access"`
31- Roles channels.AccessMap `json:"roles"`
32- Exception string `json:"exception,omitempty"`
33- Expiry * uint32 `json:"expiry,omitempty"`
34- Logging SyncFnDryRunLogging `json:"logging"`
29+ Channels base.Set `json:"channels"`
30+ Access channels.AccessMap `json:"access"`
31+ Roles channels.AccessMap `json:"roles"`
32+ Exception string `json:"exception,omitempty"`
33+ Expiry * uint32 `json:"expiry,omitempty"`
34+ Logging DryRunLogging `json:"logging"`
3535}
3636
3737type ImportFilterDryRun struct {
38- ShouldImport bool `json:"shouldImport"`
39- Error string `json:"error"`
38+ ShouldImport bool `json:"shouldImport"`
39+ Error string `json:"error"`
40+ Logging DryRunLogging `json:"logging"`
4041}
4142
4243type SyncFnDryRunPayload struct {
@@ -173,7 +174,7 @@ func (h *handler) handleSyncFnDryRun() error {
173174 errMsg := syncFnDryRunErr .Error ()
174175 resp := SyncFnDryRun {
175176 Exception : errMsg ,
176- Logging : SyncFnDryRunLogging {Errors : logErrors , Info : logInfo },
177+ Logging : DryRunLogging {Errors : logErrors , Info : logInfo },
177178 }
178179 h .writeJSON (resp )
179180 return nil
@@ -189,7 +190,7 @@ func (h *handler) handleSyncFnDryRun() error {
189190 output .Roles ,
190191 errorMsg ,
191192 output .Expiry ,
192- SyncFnDryRunLogging {Errors : logErrors , Info : logInfo },
193+ DryRunLogging {Errors : logErrors , Info : logInfo },
193194 }
194195 h .writeJSON (resp )
195196 return nil
@@ -220,7 +221,16 @@ func (h *handler) handleImportFilterDryRun() error {
220221 } else {
221222 doc = importFilterPayload .Doc
222223 }
223- shouldImport , err := h .collection .ImportFilterDryRun (h .ctx (), doc , importFilterPayload .Function )
224+
225+ logErrors := make ([]string , 0 )
226+ logInfo := make ([]string , 0 )
227+ errorLogFn := func (s string ) {
228+ logErrors = append (logErrors , s )
229+ }
230+ infoLogFn := func (s string ) {
231+ logInfo = append (logInfo , s )
232+ }
233+ shouldImport , err := h .collection .ImportFilterDryRun (h .ctx (), doc , importFilterPayload .Function , errorLogFn , infoLogFn )
224234 errorMsg := ""
225235 if err != nil {
226236 var importFilterDryRunErr * base.ImportFilterDryRunError
@@ -232,6 +242,7 @@ func (h *handler) handleImportFilterDryRun() error {
232242 resp := ImportFilterDryRun {
233243 shouldImport ,
234244 errorMsg ,
245+ DryRunLogging {Errors : logErrors , Info : logInfo },
235246 }
236247 h .writeJSON (resp )
237248 return nil
0 commit comments