MCPcopy Create free account
hub / github.com/activecm/rita / ReadFileConfig

Function ReadFileConfig

config/config.go:153–174  ·  view source on GitHub ↗

ReadFileConfig attempts to read the config file at the specified path and returns a config object, using the default config if the file was unable to be read.

(afs afero.Fs, path string)

Source from the content-addressed store, hash-verified

151// ReadFileConfig attempts to read the config file at the specified path and
152// returns a config object, using the default config if the file was unable to be read.
153func ReadFileConfig(afs afero.Fs, path string) (*Config, error) {
154 // read the config file
155 contents, err := util.GetFileContents(afs, path)
156 if err != nil {
157 return nil, err
158 }
159 // fmt.Println("contents:", contents)
160 var cfg Config
161 // // parse the JSON config file
162 // if err := hjson.Unmarshal(contents, &cfg); err != nil {
163 // return nil, err
164 // }
165 if err := unmarshal(contents, &cfg, nil); err != nil {
166 return nil, fmt.Errorf("%w, located by default at '%s', please correct the issue in the config and try again:\n\t- %w", errReadingConfigFile, path, err)
167 }
168 // // set the environment variables
169 // if err := setEnv(&cfg); err != nil {
170 // return nil, fmt.Errorf("unable to set environment: %w", err)
171 // }
172
173 return &cfg, nil
174}
175
176// ReadConfigFromMemory reads the config from bytes already read into memory as opposed to reading from a file
177// It also provides its own environment struct that must already be completely set

Callers 15

TestProxyBeaconsFunction · 0.92
TestOpenSNIFunction · 0.92
TestImportTrackingFunction · 0.92
TestMinMaxTimestampsFunction · 0.92
TestMetaDatabaseFunction · 0.92
TestProxyRollingFunction · 0.92
TestNetworkIDFunction · 0.92
SetupSuiteMethod · 0.92

Calls 2

GetFileContentsFunction · 0.92
unmarshalFunction · 0.85

Tested by 15

TestProxyBeaconsFunction · 0.74
TestOpenSNIFunction · 0.74
TestImportTrackingFunction · 0.74
TestMinMaxTimestampsFunction · 0.74
TestMetaDatabaseFunction · 0.74
TestProxyRollingFunction · 0.74
TestNetworkIDFunction · 0.74
SetupSuiteMethod · 0.74