MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / discover_with_spec

Function discover_with_spec

crates/openshell-providers/src/discovery.rs:9–31  ·  view source on GitHub ↗
(
    spec: &ProviderDiscoverySpec,
    context: &dyn DiscoveryContext,
)

Source from the content-addressed store, hash-verified

7use std::collections::HashSet;
8
9pub fn discover_with_spec(
10 spec: &ProviderDiscoverySpec,
11 context: &dyn DiscoveryContext,
12) -> Result<Option<DiscoveredProvider>, ProviderError> {
13 let mut discovered = DiscoveredProvider::default();
14
15 for key in spec.credential_env_vars {
16 if let Some(value) = context.env_var(key)
17 && !value.trim().is_empty()
18 {
19 discovered
20 .credentials
21 .entry((*key).to_string())
22 .or_insert(value);
23 }
24 }
25
26 if discovered.is_empty() {
27 Ok(None)
28 } else {
29 Ok(Some(discovered))
30 }
31}
32
33pub fn discover_from_profile(
34 profile: &ProviderTypeProfile,

Callers 5

discover_existingMethod · 0.85
discover_existingMethod · 0.85
discover_existingMethod · 0.85
discover_existingMethod · 0.85

Calls 2

env_varMethod · 0.45
is_emptyMethod · 0.45

Tested by 1