Module: Flynn::CLI::Tools
- Defined in:
- lib/flynn/cli/tools.rb,
lib/flynn/cli/tools/logger.rb,
lib/flynn/cli/tools/version.rb,
lib/flynn/cli/tools/cloudflare.rb,
lib/flynn/cli/tools/option_parser.rb,
lib/flynn/cli/tools/commander_setup.rb
Defined Under Namespace
Modules: CommanderSetup
Classes: CloudFlare, Logger, OptionParser
Constant Summary
collapse
- VERSION =
"0.0.4"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
19
20
21
|
# File 'lib/flynn/cli/tools.rb', line 19
def logger
@logger
end
|
.options ⇒ Object
Returns the value of attribute options.
18
19
20
|
# File 'lib/flynn/cli/tools.rb', line 18
def options
@options
end
|
Class Method Details
._flynn_images ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/flynn/cli/tools.rb', line 66
def self._flynn_images
return @images if @images
require 'json'
require 'httparty'
res = JSON.parse HTTParty.get("https://dl.flynn.io/ec2/images.json").body
@images = []
res["versions"].each do |version|
image = version["images"].select{|img| img["region"] == self.aws_region}[0]
@images.push({
flynn_version: version["version"],
region: image["region"],
image: image["id"],
name: image["name"]
})
end
@images
end
|
.app_env ⇒ Object
45
46
47
|
# File 'lib/flynn/cli/tools.rb', line 45
def self.app_env
@app_env ||= self.capture "cat .flynn-env | grep RAILS_ENV | cut -f 2 -d ="
end
|
.app_env=(app) ⇒ Object
49
50
51
|
# File 'lib/flynn/cli/tools.rb', line 49
def self.app_env= app
@app_env = app
end
|
.aws_region ⇒ Object
93
94
95
|
# File 'lib/flynn/cli/tools.rb', line 93
def self.aws_region
@region ||= self.capture "aws configure get region"
end
|
.capture(command) ⇒ Object
107
108
109
110
|
# File 'lib/flynn/cli/tools.rb', line 107
def self.capture command
logger.debug "Running: #{command}" unless options[:quiet]
`#{command}`.strip
end
|
.exit_if_failed ⇒ Object
112
113
114
|
# File 'lib/flynn/cli/tools.rb', line 112
def self.exit_if_failed
exit $?.exitstatus unless $?.success?
end
|
.flynn_cluster ⇒ Object
37
38
39
|
# File 'lib/flynn/cli/tools.rb', line 37
def self.flynn_cluster
@cluster ||= self.capture "flynn cluster default | tail -n 1 | awk '{print $1}'"
end
|
.flynn_cluster=(cluster) ⇒ Object
41
42
43
|
# File 'lib/flynn/cli/tools.rb', line 41
def self.flynn_cluster= cluster
@cluster = cluster
end
|
.flynn_images(version = nil) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/flynn/cli/tools.rb', line 53
def self.flynn_images version = nil
images = self._flynn_images
return images unless version
images.each do |img|
return [img] if img[:flynn_version] <= version
end
end
|
.system(*args, allow_dry: true) ⇒ Object
101
102
103
104
105
|
# File 'lib/flynn/cli/tools.rb', line 101
def self.system *args, allow_dry: true
dry = allow_dry && options[:dry_run]
logger.debug "#{dry ? 'Dry ' : ''}Running: #{args.join " "}" unless options[:quiet]
super *args unless dry
end
|
.system!(*args) ⇒ Object
97
98
99
|
# File 'lib/flynn/cli/tools.rb', line 97
def self.system! *args
self.system *args, allow_dry: false
end
|