fantasia-cli 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bd78ca674aba49e498938fce174433f63292f5416adea9d72345ba753872d6e2
4
+ data.tar.gz: c3d2390db9f67eb7456856acba34f245fef3abc9c0449798f300dac84614d8dc
5
+ SHA512:
6
+ metadata.gz: 61e40efcaa3ef5741d599c23287c5ba3c08b2ea561b236bb5dcb815c649f0d4ffb1c5a4fb4285212ac23a38c11cfe24015b2c7eba337ba59fc2448338b505762
7
+ data.tar.gz: 73e7443fe1ba6c744b5117644c20191e1d1688cfa0f460a22bfbd20fb376dbfc4eceff2e860bd4d5ec637192c1e4e7843bc7e06ede1497ac9fef2893f915e9f6
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /*.gem
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in fantasia.gemspec
6
+ gemspec
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fantasia (0.1.0)
5
+ colorize (~> 0.8)
6
+ faraday (~> 0.14)
7
+ thor (~> 0.20)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ colorize (0.8.1)
13
+ faraday (0.14.0)
14
+ multipart-post (>= 1.2, < 3)
15
+ multipart-post (2.0.0)
16
+ rake (10.5.0)
17
+ thor (0.20.0)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ bundler (~> 1.16)
24
+ fantasia!
25
+ rake (~> 10.0)
26
+
27
+ BUNDLED WITH
28
+ 1.16.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Nathan Baum
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # Fantasia
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fantasia`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'fantasia'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install fantasia
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fantasia.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fantasia"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'fantasia/cli'
4
+ Fantasia::CLI.start
@@ -0,0 +1,38 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "fantasia/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fantasia-cli"
8
+ spec.version = Fantasia::VERSION
9
+ spec.authors = ["Nathan Baum"]
10
+ spec.email = ["n@p12a.org.uk"]
11
+
12
+ spec.summary = "CLI for interacting with Fantasia"
13
+ # spec.homepage = "TODO: Put your gem's website or public repo URL here."
14
+ spec.license = "MIT"
15
+
16
+ # # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ # if spec.respond_to?(:metadata)
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
+ # else
21
+ # raise "RubyGems 2.0 or newer is required to protect against " \
22
+ # "public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency "thor", "~> 0.20"
33
+ spec.add_dependency "faraday", "~> 0.14"
34
+ spec.add_dependency "colorize", "~> 0.8"
35
+
36
+ spec.add_development_dependency "bundler", "~> 1.16"
37
+ spec.add_development_dependency "rake", "~> 10.0"
38
+ end
@@ -0,0 +1,4 @@
1
+ module Fantasia
2
+ end
3
+
4
+ require "fantasia/version"
@@ -0,0 +1,77 @@
1
+ require 'thor'
2
+ require 'faraday'
3
+ require 'colorize'
4
+ require 'yaml'
5
+ require 'json'
6
+
7
+ module Fantasia
8
+
9
+ class CLI < Thor
10
+
11
+ class_option :force, type: :boolean, aliases: "-f", desc: "Ignore unstaged git changes"
12
+
13
+ desc 'build', 'Build the stack locally'
14
+ def build
15
+ if system("git diff-files --quiet") || options[:force]
16
+ system("docker-compose build") || exit(1)
17
+ else
18
+ puts "There are unstaged changes. Commit or stash them, or use the force option."
19
+ exit(1)
20
+ end
21
+ end
22
+
23
+ desc 'push', 'Push the stack to the registry'
24
+ def push
25
+ system("docker-compose push") || exit(1)
26
+ end
27
+
28
+ desc 'update', 'Update the stack in Fantasia'
29
+ def update
30
+ spec = YAML.load(File.read "fantasia.yml")
31
+ secrets = YAML.load(File.read(spec["secrets"] || "fantasia.secrets.yml"))
32
+ url = spec["url"]
33
+ http = Faraday.new("#{url}api/v1/")
34
+ name = spec["stack"]
35
+ http.authorization(:Bearer, secrets[name])
36
+ r = http.post "stack", {
37
+ fantasia_file: spec.to_yaml,
38
+ compose_file: File.read(spec["compose-file"] || "docker-compose.yml")
39
+ }
40
+ r = JSON.parse(r.body)
41
+ if r["success"]
42
+ puts "ok".colorize(:green)
43
+ else
44
+ puts r["message"].colorize(:red)
45
+ exit 1
46
+ end
47
+ end
48
+
49
+ desc 'deploy', 'Build, push, and update the stack'
50
+ def deploy
51
+ invoke :build
52
+ invoke :push
53
+ invoke :update
54
+ end
55
+
56
+ desc 'show', 'Show stack information'
57
+ def show
58
+ spec = YAML.load(File.read "fantasia.yml")
59
+ secrets = YAML.load(File.read(spec["secrets"] || "fantasia.secrets.yml"))
60
+ url = spec["url"]
61
+ http = Faraday.new("#{url}api/v1/")
62
+ name = spec["stack"]
63
+ http.authorization(:Bearer, secrets[name])
64
+ r = JSON.parse(http.get("stack").body)
65
+ puts "#{"State".colorize(:green)}: #{r["state"]}"
66
+ puts "#{"Portainer ID".colorize(:green)}: #{r["portainer_id"]}"
67
+ puts
68
+ puts "Fantasia config".colorize(:green)
69
+ puts r["fantasia_file"]
70
+ puts
71
+ puts "Compose config".colorize(:green)
72
+ puts r["compose_file"]
73
+ end
74
+
75
+ end
76
+
77
+ end
@@ -0,0 +1,3 @@
1
+ module Fantasia
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fantasia-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Baum
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-02-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.20'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.20'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.14'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.8'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description:
84
+ email:
85
+ - n@p12a.org.uk
86
+ executables:
87
+ - fantasia
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - exe/fantasia
100
+ - fantasia.gemspec
101
+ - lib/fantasia.rb
102
+ - lib/fantasia/cli.rb
103
+ - lib/fantasia/version.rb
104
+ homepage:
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.7.3
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: CLI for interacting with Fantasia
128
+ test_files: []