github.com/aporeto-inc/trireme-lib@v10.358.0+incompatible/monitor/internal/uid/config.go (about)

     1  package uidmonitor
     2  
     3  import (
     4  	"go.aporeto.io/trireme-lib/monitor/extractors"
     5  )
     6  
     7  // Config is the configuration options to start a CNI monitor
     8  type Config struct {
     9  	EventMetadataExtractor extractors.EventMetadataExtractor
    10  	StoredPath             string
    11  	ReleasePath            string
    12  }
    13  
    14  // DefaultConfig provides default configuration for uid monitor
    15  func DefaultConfig() *Config {
    16  
    17  	return &Config{
    18  		EventMetadataExtractor: extractors.UIDMetadataExtractor,
    19  		StoredPath:             "/var/run/trireme_uid",
    20  		ReleasePath:            "",
    21  	}
    22  }
    23  
    24  // SetupDefaultConfig adds defaults to a partial configuration
    25  func SetupDefaultConfig(uidConfig *Config) *Config {
    26  
    27  	defaultConfig := DefaultConfig()
    28  
    29  	if uidConfig.ReleasePath == "" {
    30  		uidConfig.ReleasePath = defaultConfig.ReleasePath
    31  	}
    32  	if uidConfig.StoredPath == "" {
    33  		uidConfig.StoredPath = defaultConfig.StoredPath
    34  	}
    35  	if uidConfig.EventMetadataExtractor == nil {
    36  		uidConfig.EventMetadataExtractor = defaultConfig.EventMetadataExtractor
    37  	}
    38  
    39  	return uidConfig
    40  }