Class: DeisInteractive::Rails::Base
- Inherits:
-
Object
- Object
- DeisInteractive::Rails::Base
- Defined in:
- lib/deis-interactive/rails/base.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#process ⇒ Object
readonly
Returns the value of attribute process.
Instance Method Summary collapse
- #deis_remote ⇒ Object
- #git_remote_response ⇒ Object
- #inferred_app ⇒ Object
-
#initialize(app, process) ⇒ Base
constructor
A new instance of Base.
- #pod_ids ⇒ Object
- #processes_pattern ⇒ Object
Constructor Details
#initialize(app, process) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 12 13 |
# File 'lib/deis-interactive/rails/base.rb', line 6 def initialize(app, process) @app = app || inferred_app @process = process if @app.nil? puts "App name can't be inferred. Please pass the app name with -a APP" exit 1 end end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
4 5 6 |
# File 'lib/deis-interactive/rails/base.rb', line 4 def app @app end |
#process ⇒ Object (readonly)
Returns the value of attribute process.
4 5 6 |
# File 'lib/deis-interactive/rails/base.rb', line 4 def process @process end |
Instance Method Details
#deis_remote ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/deis-interactive/rails/base.rb', line 35 def deis_remote remotes = git_remote_response.split("\n") remotes.each do |remote| name, url, type = remote.split(" ") if name == "deis" return url end end nil end |
#git_remote_response ⇒ Object
31 32 33 |
# File 'lib/deis-interactive/rails/base.rb', line 31 def git_remote_response `git remote -v` end |
#inferred_app ⇒ Object
47 48 49 50 51 |
# File 'lib/deis-interactive/rails/base.rb', line 47 def inferred_app url = deis_remote return nil if url.nil? url.split("/").last.gsub(".git", "") end |
#pod_ids ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/deis-interactive/rails/base.rb', line 21 def pod_ids @pod_ids ||= ( puts "Fetching pod ids..." output= `kubectl get pods --namespace #{app} -o name | grep #{processes_pattern}` output.split("\n").reject(&:empty?).map do |str| str.split("/").last end ) end |
#processes_pattern ⇒ Object
15 16 17 18 19 |
# File 'lib/deis-interactive/rails/base.rb', line 15 def processes_pattern patterns = [app] patterns << process if process patterns.join("-") end |