Skeleton of basic functionality, all as TODOs
This commit is contained in:
67
src/faaso.cr
67
src/faaso.cr
@ -1,6 +1,71 @@
|
||||
require "commander"
|
||||
|
||||
# TODO: Write documentation for `Faaso`
|
||||
module Faaso
|
||||
VERSION = "0.1.0"
|
||||
|
||||
# TODO: Put your code here
|
||||
module Commands
|
||||
class Build
|
||||
@arguments : Array(String) = [] of String
|
||||
@options : Commander::Options
|
||||
|
||||
def initialize(options, arguments)
|
||||
@options = options
|
||||
@arguments = arguments
|
||||
end
|
||||
|
||||
def run
|
||||
@arguments.each do |arg|
|
||||
puts "Building function... #{arg}"
|
||||
# A function is a folder with stuff in it
|
||||
# TODO: decide template based on file extensions or other metadata
|
||||
# TODO: copy template and add function files to it
|
||||
# TODO: build Docker image
|
||||
# TODO: push Docker image to registry
|
||||
# TODO: return image name for testing
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Up
|
||||
@arguments : Array(String) = [] of String
|
||||
@options : Commander::Options
|
||||
|
||||
def initialize(options, arguments)
|
||||
@options = options
|
||||
@arguments = arguments
|
||||
end
|
||||
|
||||
def run
|
||||
@arguments.each do |arg|
|
||||
puts "Starting function... #{arg}"
|
||||
# TODO: Check that we have an image for the function
|
||||
# TODO: Start a container with the image
|
||||
# TODO: Run test for healthcheck
|
||||
# TODO: Map route in reverse proxy to function
|
||||
# TODO: Return function URL for testing
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Down
|
||||
@arguments : Array(String) = [] of String
|
||||
@options : Commander::Options
|
||||
|
||||
def initialize(options, arguments)
|
||||
@options = options
|
||||
@arguments = arguments
|
||||
end
|
||||
|
||||
def run
|
||||
@arguments.each do |arg|
|
||||
puts "Stopping function... #{arg}"
|
||||
# TODO: check if function is running
|
||||
# TODO: stop function container
|
||||
# TODO: delete function container
|
||||
# TODO: remove route from reverse proxy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
36
src/main.cr
Normal file
36
src/main.cr
Normal file
@ -0,0 +1,36 @@
|
||||
require "commander"
|
||||
require "./faaso.cr"
|
||||
|
||||
cli = Commander::Command.new do |cmd|
|
||||
cmd.use = "faaso"
|
||||
cmd.long = "Functions as a Service, Open"
|
||||
|
||||
cmd.commands.add do |command|
|
||||
command.use = "build"
|
||||
command.short = "Build a function"
|
||||
command.long = "Build a function's Docker image and optionally upload it to registry"
|
||||
command.run do |options, arguments|
|
||||
Faaso::Commands::Build.new(options, arguments).run
|
||||
end
|
||||
end
|
||||
|
||||
cmd.commands.add do |command|
|
||||
command.use = "up"
|
||||
command.short = "Start a function"
|
||||
command.long = "Start a function in a container"
|
||||
command.run do |options, arguments|
|
||||
Faaso::Commands::Up.new(options, arguments).run
|
||||
end
|
||||
end
|
||||
|
||||
cmd.commands.add do |command|
|
||||
command.use = "down"
|
||||
command.short = "Stop a function"
|
||||
command.long = "Stop a function in a container"
|
||||
command.run do |options, arguments|
|
||||
Faaso::Commands::Down.new(options, arguments).run
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Commander.run(cli, ARGV)
|
Reference in New Issue
Block a user