diff --git a/src/daemon.cr b/src/daemon.cr index 6faea8a..fa90381 100644 --- a/src/daemon.cr +++ b/src/daemon.cr @@ -8,12 +8,17 @@ require "uuid" # FIXME: make configurable basic_auth "admin", "admin" -current_config = "" +current_config = File.read("tinyproxy.conf") + +# Get current proxy config +get "/proxy/" do + current_config +end # Bump proxy config to current docker state, returns # new proxy config -get "/" do - "Updating routing" +patch "/proxy/" do + Log.info { "Updating routing" } # Get all the funkos, create routes for them all docker_api = Docr::API.new(Docr::Client.new) containers = docker_api.containers.list(all: true) diff --git a/src/faaso.cr b/src/faaso.cr index 3953c2c..95d162d 100644 --- a/src/faaso.cr +++ b/src/faaso.cr @@ -7,10 +7,7 @@ require "json" require "uuid" # API if you just ran faaso-daemon -FAASO_API = "http://localhost:3000/" - -# API if you are running the proxy image locally -# FAASO_API="http://localhost:8888/admin/" +FAASO_SERVER = ENV.fetch("FAASO_SERVER", "http://localhost:3000/") # Functions as a Service, Ops! module Faaso @@ -80,18 +77,18 @@ module Faaso outf << buf end - url = "#{FAASO_API}funko/build/" + url = "#{FAASO_SERVER}funko/build/" begin - _response = Crest.post( + Log.info { "Uploading funko to #{FAASO_SERVER}" } + response = Crest.post( url, {"funko.tgz" => File.open(tmp), "name" => "funko.tgz"}, user: "admin", password: "admin" ) Log.info { "Build finished successfully." } - # body = JSON.parse(_response.body) - # puts body["stdout"] - # puts body["stderr"] + body = JSON.parse(response.body) + Log.info { body["stdout"] } rescue ex : Crest::InternalServerError Log.error { "Error building funko #{funko.name} from #{funko.path}" } body = JSON.parse(ex.response.body) @@ -129,7 +126,7 @@ module Faaso if !local begin - response = Crest.get("#{FAASO_API}funko/#{funko.name}/up/", + response = Crest.get("#{FAASO_SERVER}funko/#{funko.name}/up/", user: "admin", password: "admin") body = JSON.parse(response.body) Log.info { body["stdout"] } diff --git a/tinyproxy.conf b/tinyproxy.conf index 8ab98e1..a77c81e 100644 --- a/tinyproxy.conf +++ b/tinyproxy.conf @@ -6,3 +6,4 @@ Allow 0.0.0.0/0 ReverseOnly Yes ReverseMagic Yes ReversePath "/admin/" "http://127.0.0.1:3000/" +ReversePath "/faaso/hello/" "http://hello:3000/" \ No newline at end of file