Compare commits

..

No commits in common. "ef8f5c357f420fce28b133150a81aa11e81facee" and "eea98ff8f64162d38961d0690f2cab2413b03970" have entirely different histories.

3 changed files with 19 additions and 12 deletions

1
.gitignore vendored
View File

@ -7,4 +7,3 @@ export/
secrets/
.rucksack
.rucksack.toc
.faaso.yml

View File

@ -10,7 +10,7 @@ module Faaso
# In both cases stopped instances after the required
# scale is reached are deleted.
struct Scale
def local(options, name : String, scale : Int) : Int32
def local(options, name, scale) : Int32
funko = Funko::Funko.from_names([name])[0]
# Asked about scale
if funko.image_history.empty?
@ -22,23 +22,31 @@ module Faaso
return 0
end
# Asked to set scale
funko.scale(scale)
funko.scale(scale.as(String).to_i)
0
end
def remote(options, name : String, scale : Int) : Int32
def remote(options, name, scale) : Int32
user, password = Config.auth
Faaso.check_version
if !scale
response = Crest.get(
Crest.get(
"#{Config.server}funkos/#{name}/scale/", \
user: user, password: password)
Log.info { " => " + response.body }
user: user, password: password) do |response|
loop do
Log.info { response.body_io.gets }
break if response.body_io.closed?
end
end
else
response = Crest.post(
Crest.post(
"#{Config.server}funkos/#{name}/scale/",
{"scale" => scale}, user: user, password: password)
Log.info { " => " + response.body }
{"scale" => scale}, user: user, password: password) do |response|
loop do
Log.info { response.body_io.gets }
break if response.body_io.closed?
end
end
end
0
rescue ex : Crest::InternalServerError
@ -46,7 +54,7 @@ module Faaso
1
end
def run(options, name : String, scale : Int) : Int32
def run(options, name, scale) : Int32
if options["--local"]
return local(options, name, scale)
end

View File

@ -51,7 +51,7 @@ when .fetch("login", false)
when .fetch("new", false)
status = Faaso::Commands::New.new.run(ans, ans["FOLDER"].as(Array(String))[0])
when .fetch("scale", false)
status = Faaso::Commands::Scale.new.run(ans, ans["FUNKO"].as(String), ans["SCALE"].as(String).to_i)
status = Faaso::Commands::Scale.new.run(ans, ans["FUNKO"].as(String), ans["SCALE"])
when .fetch("secret", false)
status = Faaso::Commands::Secret.new.run(ans, ans["FUNKO"].as(String), ans["SECRET"].as(String))
when .fetch("status", false)