Skip to content

Commit 15d1d59

Browse files
authored
fix(cmd): add logging and error handling in monitoring commands (#788)
Signed-off-by: wuhuizuo <wuhuizuo@126.com>
1 parent 484da81 commit 15d1d59

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

cmd/monitoring.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ func getTag(defaultTag string, fixTag string) string {
247247
}
248248

249249
func fetchDirectory(rservice *common.GitRepoService, owner string, repoName string, path string, ref string) []*common.RepositoryContent {
250+
log.Printf("fetch dir %s from %s/%s at rev:%s", path, owner, repoName, ref)
250251
fileContent, monitorDirectory, err := rservice.GetContents(owner, repoName, path, &common.RepositoryContentGetOptions{
251252
Ref: ref,
252253
})
@@ -310,11 +311,15 @@ func ProcessRules(rules []*common.RepositoryContent, service *common.GitRepoServ
310311
}).Peek(func(t streamtypes.T) {
311312
content := t.(string)
312313
// ansible
314+
log.Printf("write file: %s in folder: %s", name, ansibleRuleDir)
313315
common.WriteFile(ansibleRuleDir, name, content)
314316
}).ForEach(func(t streamtypes.T) {
315317
content := t.(string)
316318
// operatotr
317-
operator.WriteRule(content, name, operatorRuleDir, operatorReplaceExpr)
319+
log.Printf("write file: %s in folder: %s", name, operatorRuleDir)
320+
if err := operator.WriteRule(content, name, operatorRuleDir, operatorReplaceExpr); err != nil {
321+
log.Fatal(errors.Wrap(err, "failed to write rule"))
322+
}
318323
})
319324
}
320325

0 commit comments

Comments
 (0)