Method: Puppet::Environments::Cached#list

Defined in:
lib/puppet/environments.rb

#listArray<Puppet::Node::Environment>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns All of the environments known to the loader.

Returns:



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/puppet/environments.rb', line 363

def list
  # Evict all that have expired, in the same way as `get`
  clear_all_expired

  # Evict all that was removed from disk
  cached_envs = @cache.keys.map!(&:to_sym)
  loader_envs = @loader.list.map!(&:name)
  removed_envs = cached_envs - loader_envs

  removed_envs.each do |env_name|
    Puppet.debug { "Environment no longer exists '#{env_name}'"}
    clear(env_name)
  end

  @loader.list.map do |env|
    name = env.name
    old_entry = @cache[name]
    if old_entry
      old_entry.value
    else
      add_entry(name, entry(env))
      env
    end
  end
end