@@ -26,7 +26,8 @@ import (
2626 "github.com/specterops/bloodhound/cmd/api/src/api/dbpool"
2727 "github.com/specterops/bloodhound/cmd/api/src/api/tools"
2828 "github.com/specterops/bloodhound/cmd/api/src/config"
29- "github.com/specterops/bloodhound/cmd/api/src/services/storage"
29+ storageService "github.com/specterops/bloodhound/cmd/api/src/services/storage"
30+ "github.com/specterops/bloodhound/packages/go/storage"
3031 "github.com/specterops/dawgs"
3132 "github.com/specterops/dawgs/drivers/neo4j"
3233 "github.com/specterops/dawgs/drivers/pg"
@@ -39,7 +40,7 @@ import (
3940// access to the FileServiceRetained, the FileServiceResolver is created prior to the
4041// PreMigrationDaemons and the Entrypoint. This could then be passed in.
4142type RuntimeDependencies struct {
42- FileServiceResolver storage .FileServiceResolver
43+ FileServiceResolver storageService .FileServiceResolver
4344}
4445
4546func ensureDirectory (path string ) error {
@@ -48,7 +49,7 @@ func ensureDirectory(path string) error {
4849 return err
4950 }
5051
51- if err := os .MkdirAll (path , 0755 ); err != nil {
52+ if err := os .MkdirAll (path , 0o755 ); err != nil {
5253 return fmt .Errorf ("unable to create directory %s: %w" , path , err )
5354 }
5455 }
@@ -86,6 +87,26 @@ func EnsureServerDirectories(cfg config.Configuration) error {
8687 return nil
8788}
8889
90+ var requiredFileServices = []storage.FileServiceName {
91+ storage .FileServiceIngest ,
92+ storage .FileServiceRetained ,
93+ storage .FileServiceCollectors ,
94+ storage .FileServiceWork ,
95+ }
96+
97+ // EnsureFileServices confirms that the required file services are created in the supplied fileServiceResolver.
98+ func EnsureFileServices (
99+ fileServiceResolver storageService.FileServiceResolver ,
100+ ) error {
101+ for _ , serviceName := range requiredFileServices {
102+ if _ , err := fileServiceResolver .Resolve (serviceName ); err != nil {
103+ return fmt .Errorf ("failed to resolve %s file service: %w" , serviceName , err )
104+ }
105+ }
106+
107+ return nil
108+ }
109+
89110// DefaultConfigFilePath returns the location of the config file
90111func DefaultConfigFilePath () string {
91112 return "/etc/bhapi/bhapi.json"
0 commit comments