From a4f722a1e08d2f483727472388afc23c9840172e Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Tue, 2 Jul 2024 16:56:19 -0300 Subject: [PATCH] Use actual funkos in the admin backend --- src/daemon/funkos.cr | 18 ++---------------- src/views/funkos.ecr | 2 ++ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/daemon/funkos.cr b/src/daemon/funkos.cr index 59bf52a..d99855b 100644 --- a/src/daemon/funkos.cr +++ b/src/daemon/funkos.cr @@ -1,25 +1,11 @@ require "docr" require "kemal" +require "../funko.cr" module Funkos - struct Funko - include JSON::Serializable - property name : String - - def initialize(@name : String) - end - end - get "/funkos/" do |env| - docker_api = Docr::API.new(Docr::Client.new) - containers = docker_api.containers.list(all: true) + funkos : Array(Funko) = Funko.from_docker - funkos = [] of Funko - containers.each { |container| - names = container.names.select &.starts_with? "/faaso-" - next if names.empty? - funkos << Funko.new(name: names[0][7..]) - } funkos.sort! { |a, b| a.name <=> b.name } if env.params.query.fetch("format", "json") == "html" diff --git a/src/views/funkos.ecr b/src/views/funkos.ecr index 73c9a9f..c6dcd68 100644 --- a/src/views/funkos.ecr +++ b/src/views/funkos.ecr @@ -1,5 +1,7 @@ <%- funkos.each do |funko| -%> + <%= funko.name %> sarasa + <%- end -%>