github.com/google/fleetspeak@v0.1.15-0.20240426164851-4f31f62c1aea/fleetspeak/src/client/generic/config_windows.go (about)

     1  //go:build windows
     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  	case *gpb.Config_RegistryHandler:
    22  		return config.NewWindowsRegistryPersistenceHandler(h.RegistryHandler.ConfigurationKey, false)
    23  	default:
    24  		return nil, fmt.Errorf("persistence_handler has unsupported type: %T", cfg.PersistenceHandler)
    25  	}
    26  }