From e17f421b5e593ca05174efecf31787a1b940f1e3 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Wed, 3 Jul 2024 15:00:06 -0300 Subject: [PATCH] General rewrite to support scales different than 1 --- src/commands/status.cr | 18 ++++++++++-------- src/funko.cr | 11 +++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/commands/status.cr b/src/commands/status.cr index a2d6519..0b242bc 100644 --- a/src/commands/status.cr +++ b/src/commands/status.cr @@ -3,16 +3,18 @@ module Faaso struct Status def local(options, name) funko = Funko::Funko.from_names([name])[0] - Log.info { "Name: #{funko.name}" } - Log.info { "Scale: #{funko.scale}" } - containers = funko.containers - Log.info { "Containers: #{funko.containers.size}" } - containers.each do |container| + status = funko.docker_status + + Log.info { "Name: #{status["name"]}" } + Log.info { "Scale: #{status["scale"]}" } + + Log.info { "Containers: #{status["containers"].size}" } + status["containers"].each do |container| Log.info { " #{container.@names[0]} #{container.status}" } end - images = funko.images - Log.info { "Images: #{images.size}" } - images.each do |image| + + Log.info { "Images: #{status["images"].size}" } + status["images"].each do |image| Log.info { " #{image.repo_tags} #{image.created}" } end end diff --git a/src/funko.cr b/src/funko.cr index f4ac2ac..d4c6a23 100644 --- a/src/funko.cr +++ b/src/funko.cr @@ -145,6 +145,7 @@ module Funko end # Return a list of image IDs for this funko, most recent first + # FIXME: use self.images and add filters def image_history docker_api = Docr::API.new(Docr::Client.new) begin @@ -165,6 +166,16 @@ module Funko } end + # A comprehensive status for the funko: + def docker_status + { + "name" => name, + "containers" => containers, + "images" => images, + "scale" => scale, + } + end + # Descriptive status for the funko def status status = self.containers.map { |container|