Sha256: 8ab4695c268d260c6761e1868f74d5e23313d08afb4db1117402846b857fa353

Contents?: true

Size: 937 Bytes

Versions: 2

Compression:

Stored size: 937 Bytes

Contents

# frozen_string_literal: true

# tau docker container list
module DockerContainerList
  # List docker containers.
  def docker_container_list
    log.debug 'List docker containers'

    return false unless docker_check_daemon

    _docker_container_list_get_inventory.to_yaml
  end

  private

  # Get the current inventory
  def _docker_container_list_get_inventory
    inventory = _docker_container_list_new_inventory
    _docker_container_lib_get_containers.each do |container|
      name = _docker_container_lib_get_container_name_by_id container
      if docker_container_check_orphaned container
        inventory['orphaned']['hosts'] << name
      else
        inventory['login']['hosts'] << name
      end
    end
    inventory
  end

  # Create a new inventory
  def _docker_container_list_new_inventory
    {
      'login' => {
        'hosts' => []
      },
      'orphaned' => {
        'hosts' => []
      }
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
takeltau-0.43.16 lib/takeltau/docker/container/list.rb
takeltau-0.43.15 lib/takeltau/docker/container/list.rb