collectQueueSecrets function
Map<String, String>
collectQueueSecrets(
- List<
ProviderQueueEntry> entries, - SecureKeyCache keys, {
- Map<
String, String> ? env,
Collects the secrets snapshot for the queue: each entry's apiKeyEnv
resolves from the environment, else the secure store (env wins — the
same precedence as the roles snapshot).
Implementation
Map<String, String> collectQueueSecrets(
List<ProviderQueueEntry> entries,
SecureKeyCache keys, {
Map<String, String>? env,
}) {
final environment = env ?? Platform.environment;
final secrets = <String, String>{};
for (final entry in entries) {
final name = entry.apiKeyEnv;
if (name == null || secrets.containsKey(name)) continue;
final fromEnv = environment[name];
if (fromEnv != null && fromEnv.isNotEmpty) {
secrets[name] = fromEnv;
continue;
}
final stored = keys.read(name);
if (stored != null) secrets[name] = stored;
}
return secrets;
}