-
Notifications
You must be signed in to change notification settings - Fork 313
/
helper.go
60 lines (51 loc) · 2.06 KB
/
helper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package validations
import (
"encoding/json"
"fmt"
backendconfig "github.com/rudderlabs/rudder-server/config/backend-config"
"github.com/rudderlabs/rudder-server/services/filemanager"
"github.com/rudderlabs/rudder-server/utils/misc"
warehouseutils "github.com/rudderlabs/rudder-server/warehouse/utils"
)
func warehouse(req *DestinationValidationRequest) warehouseutils.Warehouse {
destination := req.Destination
randomSourceId, randomSourceName := warehouseutils.RandHex(), warehouseutils.RandHex()
return warehouseutils.Warehouse{
Source: backendconfig.SourceT{
ID: randomSourceId,
Name: randomSourceName,
},
Destination: destination,
Namespace: warehouseutils.ToSafeNamespace(destination.DestinationDefinition.Name, TestNamespace),
Type: destination.DestinationDefinition.Name,
Identifier: warehouseutils.GetWarehouseIdentifier(destination.DestinationDefinition.Name, randomSourceId, destination.ID),
}
}
func fileManager(req *DestinationValidationRequest) (fileManager filemanager.FileManager, err error) {
destination := req.Destination
provider := warehouseutils.ObjectStorageType(destination.DestinationDefinition.Name, destination.Config, misc.IsConfiguredToUseRudderObjectStorage(destination.Config))
fileManager, err = fileManagerFactory.New(&filemanager.SettingsT{
Provider: provider,
Config: misc.GetObjectStorageConfig(misc.ObjectStorageOptsT{
Provider: provider,
Config: destination.Config,
UseRudderStorage: misc.IsConfiguredToUseRudderObjectStorage(destination.Config),
WorkspaceID: req.Destination.WorkspaceID,
}),
})
fileManager.SetTimeout(fileManagerTimeout)
if err != nil {
pkgLogger.Errorf("[DCT]: Failed to initiate file manager config for testing this destination id %s: err %v", destination.ID, err)
return
}
return
}
func parseOptions(req json.RawMessage, v interface{}) error {
if err := json.Unmarshal(req, v); err != nil {
return err
}
return nil
}
func stagingTableName() string {
return fmt.Sprintf(`%s_%s`, warehouseutils.CTStagingTablePrefix, warehouseutils.RandHex())
}