Compare client/server versions and warn if different
This commit is contained in:
parent
889a5a2955
commit
824c94bebc
2
TODO.md
2
TODO.md
@ -6,7 +6,7 @@
|
|||||||
* Config UI in frontend?
|
* Config UI in frontend?
|
||||||
* Support tokens besides basic auth
|
* Support tokens besides basic auth
|
||||||
* Polish frontend UI **A LOT**
|
* Polish frontend UI **A LOT**
|
||||||
* Version checks for consistency between client/server
|
* ✅ Version checks for consistency between client/server
|
||||||
* Have 3 runtimes:
|
* Have 3 runtimes:
|
||||||
* ✅ Crystal + Kemal
|
* ✅ Crystal + Kemal
|
||||||
* ✅ Python + Flask
|
* ✅ Python + Flask
|
||||||
|
@ -15,12 +15,4 @@ http://*:8888 {
|
|||||||
handle_path /admin/* {
|
handle_path /admin/* {
|
||||||
reverse_proxy /* http://127.0.0.1:3000
|
reverse_proxy /* http://127.0.0.1:3000
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_path /faaso/exp/* {
|
|
||||||
reverse_proxy /* http://faaso-exp-6ne49v:3000 {
|
|
||||||
health_uri /ping
|
|
||||||
fail_duration 30s
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,4 +34,4 @@ dependencies:
|
|||||||
github: petoem/inotify.cr
|
github: petoem/inotify.cr
|
||||||
|
|
||||||
scripts:
|
scripts:
|
||||||
postinstall: cat .rucksack >> bin/faaso
|
postinstall: cat .rucksack >> bin/faaso
|
||||||
|
@ -17,6 +17,7 @@ module Faaso
|
|||||||
Log.info { "Building function... #{funko.name} in #{tmp_dir}" }
|
Log.info { "Building function... #{funko.name} in #{tmp_dir}" }
|
||||||
funko.build tmp_dir
|
funko.build tmp_dir
|
||||||
else # Running against a server
|
else # Running against a server
|
||||||
|
Faaso.check_version
|
||||||
# Create a tarball for the funko
|
# Create a tarball for the funko
|
||||||
buf = IO::Memory.new
|
buf = IO::Memory.new
|
||||||
Compress::Gzip::Writer.open(buf) do |gzip|
|
Compress::Gzip::Writer.open(buf) do |gzip|
|
||||||
|
@ -27,6 +27,7 @@ module Faaso
|
|||||||
end
|
end
|
||||||
|
|
||||||
def remote(options, name, scale) : Int32
|
def remote(options, name, scale) : Int32
|
||||||
|
Faaso.check_version
|
||||||
if !scale
|
if !scale
|
||||||
Crest.get(
|
Crest.get(
|
||||||
"#{FAASO_SERVER}funkos/#{name}/scale/", \
|
"#{FAASO_SERVER}funkos/#{name}/scale/", \
|
||||||
|
@ -13,6 +13,7 @@ module Faaso
|
|||||||
end
|
end
|
||||||
|
|
||||||
def remote(options, funko, name, secret) : Int32
|
def remote(options, funko, name, secret) : Int32
|
||||||
|
Faaso.check_version
|
||||||
if options["--add"]
|
if options["--add"]
|
||||||
Crest.post(
|
Crest.post(
|
||||||
"#{FAASO_SERVER}secrets/",
|
"#{FAASO_SERVER}secrets/",
|
||||||
|
@ -26,6 +26,7 @@ module Faaso
|
|||||||
end
|
end
|
||||||
|
|
||||||
def remote(options, name) : Int32
|
def remote(options, name) : Int32
|
||||||
|
Faaso.check_version
|
||||||
Crest.get(
|
Crest.get(
|
||||||
"#{FAASO_SERVER}funkos/#{name}/status/", \
|
"#{FAASO_SERVER}funkos/#{name}/status/", \
|
||||||
user: "admin", password: "admin") do |response|
|
user: "admin", password: "admin") do |response|
|
||||||
|
@ -8,8 +8,16 @@ require "docr"
|
|||||||
require "kemal"
|
require "kemal"
|
||||||
require "uuid"
|
require "uuid"
|
||||||
|
|
||||||
|
macro version
|
||||||
|
"{{ `grep version shard.yml | cut -d: -f2` }}".strip()
|
||||||
|
end
|
||||||
|
|
||||||
get "/" do |env|
|
get "/" do |env|
|
||||||
env.redirect "/index.html"
|
env.redirect "/index.html"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/version" do
|
||||||
|
"#{version}"
|
||||||
|
end
|
||||||
|
|
||||||
Kemal.run
|
Kemal.run
|
||||||
|
13
src/faaso.cr
13
src/faaso.cr
@ -28,9 +28,18 @@ module Faaso
|
|||||||
))
|
))
|
||||||
rescue ex : Docr::Errors::DockerAPIError
|
rescue ex : Docr::Errors::DockerAPIError
|
||||||
raise ex if ex.status_code != 409 # Network already exists
|
raise ex if ex.status_code != 409 # Network already exists
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Commands
|
# Compare version with server's
|
||||||
|
def self.check_version
|
||||||
|
server_version = Crest.get(
|
||||||
|
"#{FAASO_SERVER}version/", \
|
||||||
|
user: "admin", password: "admin").body
|
||||||
|
|
||||||
|
local_version = "#{version}"
|
||||||
|
|
||||||
|
if server_version != local_version
|
||||||
|
Log.warn { "Server is version #{server_version} and client is #{local_version}" }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,6 +3,10 @@ require "colorize"
|
|||||||
require "docopt"
|
require "docopt"
|
||||||
require "rucksack"
|
require "rucksack"
|
||||||
|
|
||||||
|
macro version
|
||||||
|
"{{ `grep version shard.yml | cut -d: -f2` }}".strip()
|
||||||
|
end
|
||||||
|
|
||||||
struct LogFormat < Log::StaticFormatter
|
struct LogFormat < Log::StaticFormatter
|
||||||
@@colors = {
|
@@colors = {
|
||||||
"FATAL" => :red,
|
"FATAL" => :red,
|
||||||
@ -82,6 +86,8 @@ when .fetch("secret", false)
|
|||||||
status = Faaso::Commands::Secret.new.run(ans, ans["FUNKO"].as(String), ans["SECRET"].as(String))
|
status = Faaso::Commands::Secret.new.run(ans, ans["FUNKO"].as(String), ans["SECRET"].as(String))
|
||||||
when .fetch("status", false)
|
when .fetch("status", false)
|
||||||
status = Faaso::Commands::Status.new.run(ans, ans["FUNKO"].as(String))
|
status = Faaso::Commands::Status.new.run(ans, ans["FUNKO"].as(String))
|
||||||
|
when .fetch("version", false)
|
||||||
|
Log.info { "#{version}" }
|
||||||
end
|
end
|
||||||
|
|
||||||
exit(status)
|
exit(status)
|
||||||
|
Loading…
Reference in New Issue
Block a user