MCPcopy Create free account
hub / github.com/CrowdStrike/perseus / parseSharedQueryOpts

Function parseSharedQueryOpts

query.go:320–339  ·  view source on GitHub ↗

parseSharedQueryOpts reads the process environment variables and CLI flags to populate a clientConfig instance

(cmd *cobra.Command, _ []string)

Source from the content-addressed store, hash-verified

318// parseSharedQueryOpts reads the process environment variables and CLI flags to populate a clientConfig
319// instance
320func parseSharedQueryOpts(cmd *cobra.Command, _ []string) (clientConfig, error) {
321 // parse parameters and setup options
322 var (
323 opts []clientOption
324 conf clientConfig
325 )
326 opts = append(opts, readClientConfigEnv()...)
327 opts = append(opts, readClientConfigFlags(cmd.Flags())...)
328 for _, fn := range opts {
329 if err := fn(&conf); err != nil {
330 return clientConfig{}, fmt.Errorf("could not apply client config option: %w", err)
331 }
332 }
333 // validate config
334 if conf.serverAddr == "" {
335 return clientConfig{}, fmt.Errorf("the Perseus server address must be specified")
336 }
337
338 return conf, nil
339}
340
341// lookupLatestModuleVersion invokes the Perseus API to retrieve the highest known semantic version for
342// the specified module.

Callers 4

runListModulesCmdFunction · 0.85
runListModuleVersionsCmdFunction · 0.85
runQueryModuleGraphCmdFunction · 0.85
runFindPathsCommandFunction · 0.85

Calls 2

readClientConfigEnvFunction · 0.85
readClientConfigFlagsFunction · 0.85

Tested by

no test coverage detected