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| -%> +