Class: EzPaaS::CLI::Commands::Deployments

Inherits:
ServerCommands show all
Defined in:
lib/ezpaas/cli/commands/deployments.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ezpaas/cli/commands/deployments.rb', line 52

def destroy
  pastel = Pastel.new
  prompt = TTY::Prompt.new

  app = options[:app]

  puts
  puts '🚨  🚨  🚨   ' + pastel.red("WARNING: You're about to take this app down. People won't be able to access it until you scale it up again.") + '   🚨  🚨  🚨'
  puts

  if prompt.yes?('Are you sure?', default: false)
    success_msg = pastel.green('Application scaling completed')
    server_comm_wrap(success_msg) do
      sse_client.destroy(app) do |message|
        puts message
      end
    end
  else
    puts
    puts pastel.blue('Phew!') + ' App scaling aborted.'
  end


end

#pushObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ezpaas/cli/commands/deployments.rb', line 18

def push
  pastel = Pastel.new

  app = options[:app]
  dir = options[:dir]
  branch = options[:branch]

  puts 'Opening git repository at ' + pastel.blue(dir)
  git = Git.open(dir)
  branch = git.branches[branch]

  begin
    path = Dir::Tmpname.create('ezpaas') do |file|
      puts 'Archiving ' + pastel.blue(branch) + ' branch'
      branch.archive(file, {format: 'tar'})
    end

    url_str = URI::join(options[:server], "proxy/#{app}/").to_s
    success_msg = pastel.green('Application deployment completed')
    success_msg += "\n" + 'Access your application at ' + pastel.blue(url_str)

    server_comm_wrap(success_msg) do
      sse_client.deploy(app, path) do |message|
        puts message
      end
    end

  ensure
    File.delete(path)
  end
end

#scale(*scales) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/ezpaas/cli/commands/deployments.rb', line 79

def scale(*scales)
  pastel = Pastel.new

  app = options[:app]

  if scales.empty?
    raise 'You must provide scaling arguments'
  end

  new_scale = {}

  scales.each do |s|
    components = s.split '='
    raise 'Invalid scale format' unless components.count == 2 and components.first.is_a? String and (components.last.to_i.to_s == components.last) and components.last.to_i >= 0
    new_scale[components.first] = components.last.to_i
  end

  puts

  success_msg = pastel.green('Application scaling completed')

  server_comm_wrap(success_msg) do
    sse_client.scale(app, new_scale) do |message|
      puts message
    end
  end
end