@@ -16,36 +16,41 @@ import (
16
16
17
17
// Inserter - Inserter
18
18
type Inserter struct {
19
+ commonInserter * CommonInserter
20
+
19
21
jsonInserter * JSONInserter
20
22
yamlInserter * YAMLInserter
21
23
jsInserter * JSInserter
22
24
}
23
25
24
26
// NewInserter - Inserter constructor
25
- func NewInserter (client * firestore.Client ) * Inserter {
26
- ci := NewCommonInserter (client )
27
+ func NewInserter (client * firestore.Client , refIDs RefIDs ) * Inserter {
28
+ ci := NewCommonInserter (client , refIDs )
27
29
return & Inserter {
28
- jsonInserter : NewJSONInserter (ci ),
29
- jsInserter : NewJSInserter (ci ),
30
- yamlInserter : NewYAMLInserter (ci ),
30
+ commonInserter : ci ,
31
+ jsonInserter : NewJSONInserter (ci ),
32
+ jsInserter : NewJSInserter (ci ),
33
+ yamlInserter : NewYAMLInserter (ci ),
31
34
}
32
35
}
33
36
34
37
// Execute - ダミーデータソースの読み込みと実行処理呼び出しを行う
35
- func (i * Inserter ) Execute (ctx context.Context , cfg * config.Config ) error {
38
+ func (i * Inserter ) Execute (ctx context.Context , cfg * config.Config ) ( RefIDs , error ) {
36
39
targetDir := cfg .Targets
37
40
for _ , t := range targetDir {
38
41
if ! files .Exists (t ) {
39
- return xerrors .Errorf ("cannot find target directory: %s" , targetDir )
42
+ return nil , xerrors .Errorf ("cannot find target directory: %s" , targetDir )
40
43
}
41
44
42
45
err := filepath .Walk (t , i .executeFile (ctx ))
43
46
if err != nil {
44
- return xerrors .Errorf ("failed to execute file: %w" , err )
47
+ return nil , xerrors .Errorf ("failed to execute file: %w" , err )
45
48
}
46
49
}
47
50
48
- return nil
51
+ refIDs := i .commonInserter .RefIDs ()
52
+
53
+ return refIDs , nil
49
54
}
50
55
51
56
func (i * Inserter ) executeFile (ctx context.Context ) func (path string , info os.FileInfo , _ error ) error {
0 commit comments