github.com/google/fleetspeak@v0.1.15-0.20240426164851-4f31f62c1aea/fleetspeak/src/client/generic/config_unix.go (about) 1 //go:build linux || darwin 2 3 package generic 4 5 import ( 6 "errors" 7 "fmt" 8 9 "github.com/google/fleetspeak/fleetspeak/src/client/config" 10 11 gpb "github.com/google/fleetspeak/fleetspeak/src/client/generic/proto/fleetspeak_client_generic" 12 ) 13 14 func makePersistenceHandler(cfg *gpb.Config) (config.PersistenceHandler, error) { 15 if cfg.PersistenceHandler == nil { 16 return nil, errors.New("persistence_handler is required") 17 } 18 switch h := cfg.PersistenceHandler.(type) { 19 case *gpb.Config_FilesystemHandler: 20 return config.NewFilesystemPersistenceHandler(h.FilesystemHandler.ConfigurationDirectory, h.FilesystemHandler.StateFile) 21 default: 22 return nil, fmt.Errorf("persistence_handler has unsupported type: %T", cfg.PersistenceHandler) 23 } 24 }