Class: Fantasia::CLI
- Inherits:
-
Thor
- Object
- Thor
- Fantasia::CLI
- Defined in:
- lib/fantasia/cli.rb
Instance Method Summary collapse
Instance Method Details
#build ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fantasia/cli.rb', line 14 def build if !system("git diff-index --quiet HEAD --") if [:force] STDERR.puts "Ignoring uncommitted changes. This is probably a bad idea.".colorize(:red) else STDERR.puts "There are uncommitted changes. Commit, stash, or revert them, or use the force option.".colorize(:red) exit(1) end end system("docker-compose build") || exit(1) end |
#deploy ⇒ Object
53 54 55 56 57 |
# File 'lib/fantasia/cli.rb', line 53 def deploy invoke :build invoke :push invoke :update end |
#push ⇒ Object
27 28 29 |
# File 'lib/fantasia/cli.rb', line 27 def push system("docker-compose push") || exit(1) end |
#show ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fantasia/cli.rb', line 60 def show spec = YAML.load(File.read "fantasia.yml") secrets = YAML.load(File.read(spec["secrets"] || "fantasia.secrets.yml")) url = spec["url"] http = Faraday.new("#{url}api/v1/") name = spec["stack"] http.(:Bearer, secrets[name]) r = JSON.parse(http.get("stack").body) puts "#{"State".colorize(:green)}: #{r["state"]}" puts "#{"Portainer ID".colorize(:green)}: #{r["portainer_id"]}" puts puts "Fantasia config".colorize(:green) puts r["fantasia_file"] puts puts "Compose config".colorize(:green) puts r["compose_file"] end |
#update ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fantasia/cli.rb', line 32 def update spec = YAML.load(File.read "fantasia.yml") secrets = YAML.load(File.read(spec["secrets"] || "fantasia.secrets.yml")) url = spec["url"] http = Faraday.new("#{url}api/v1/") name = spec["stack"] http.(:Bearer, secrets[name]) r = http.post "stack", { fantasia_file: spec.to_yaml, compose_file: File.read(spec["compose-file"] || "docker-compose.yml") } r = JSON.parse(r.body) if r["success"] puts r["message"].colorize(:green) else puts r["message"].colorize(:red) exit 1 end end |