class DeisInteractive::Rails::Base

Attributes

app[R]
process[R]

Public Class Methods

new(app, process) click to toggle source
# 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

Public Instance Methods

deis_remote() click to toggle source
# 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() click to toggle source
# File lib/deis-interactive/rails/base.rb, line 31
def git_remote_response
  `git remote -v`
end
inferred_app() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/deis-interactive/rails/base.rb, line 15
def processes_pattern
  patterns = [app]
  patterns << process if process
  patterns.join("-")
end