haile 0.4.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a16daa6bbc6b67d20a9e756a6aeb7baf64430be
4
- data.tar.gz: 0eadc9c22aca25c4b730cdf087e75b604743fffc
3
+ metadata.gz: db770953f74bb5bcb8041ce341cdefc7e2fd2669
4
+ data.tar.gz: d098d73d67bd058ad36451cb2ffb65fb8dfe03c7
5
5
  SHA512:
6
- metadata.gz: 8c828cf52e75b8e988e0ded8c44df36ef32795bf669a6bf9a21a437ad7d0ef6efff174b103443dd0bd05274aea41559e4f8ac369fbb88ded993c7c67a3eac650
7
- data.tar.gz: 4100fb8fcffaaaee8e8a737f9665c11d840daa5a9a37b5d548fc98ca854a8f5d4789d79869847e03deed094df5c575a59772e22327179066a99b556ed9a236c8
6
+ metadata.gz: 0852eefb5573646bde1b98b0b323a1ccc5602f124de955aaf6a098a3166d1cf0e902cf65e79bba8aa0c7d8329b007cc585ffa9b34b80ced0718947f729176fcf
7
+ data.tar.gz: 5a478cd0deeff304daa58aac98cf8dcee85c781ff82c5184e47526f596eefbc2043d0d033aa68bb91b412ccef3c968e267b909ff37111f25995259bd49930b74
data/bin/haile CHANGED
@@ -3,7 +3,7 @@
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'haile'))
4
4
  require 'trollop'
5
5
 
6
- SUB_COMMANDS = %w[endpoints kill kill_tasks start scale list list_tasks search docker_deploy]
6
+ SUB_COMMANDS = %w[endpoints kill kill_tasks upstart scale list list_tasks search docker_deploy]
7
7
 
8
8
  global_opts = Trollop.options do
9
9
  version Haile::VERSION
@@ -12,14 +12,14 @@ Usage: haile [global options] [command] [options]
12
12
 
13
13
  Available commands:
14
14
 
15
- kill Kill an app and remove it from Marathon.
16
- kill_tasks Kill a task or tasks belonging to a specified app.
17
- list Show a list of running apps and their options.
18
- list_tasks Show a list of an app's running tasks.
19
- scale Scale the number of app instances.
20
- search Search the current list of apps.
21
- start Start a new app.
22
- docker_deploy Update the docker image tag of an app.
15
+ kill Kill an app and remove it from Marathon.
16
+ kill_tasks Kill a task or tasks belonging to a specified app.
17
+ list Show a list of running apps and their options.
18
+ list_tasks Show a list of an app's running tasks.
19
+ scale Scale the number of app instances.
20
+ search Search the current list of apps.
21
+ upstart Start a new app, or update existing app from a config file
22
+ docker_deploy Update the docker image tag of an app.
23
23
 
24
24
  Global options:
25
25
  EOS
@@ -48,17 +48,9 @@ cmd_opts = case cmd
48
48
  Trollop.options do
49
49
  opt :id, 'A unique identifier for the app.', :short => '-i', :required => true, :type => String
50
50
  end
51
- when 'start'
51
+ when 'upstart'
52
52
  Trollop.options do
53
- opt :id, 'A unique identifier for the app.', :required => true, :short => '-i', :type => String
54
- opt :command, 'The command to start the app.', :short => '-C', :type => String
55
- opt :executor, 'The mesos executor to be used to launch the app.', :short => '-X', :type => String
56
- opt :num_instances, 'The number of instances to run (default 1).', :default => 1, :short => '-n'
57
- opt :cpus, 'The number of CPUs to give to this app, can be a fraction (default 1.0).', :default => 1.0, :short => '-c'
58
- opt :mem, 'The memory limit for this app, in MB, can be a fraction (default 10.0).', :default => 10.0, :short => '-m'
59
- opt :uri, 'URIs to download and unpack into the working directory.', :short => '-u', :type => :strings
60
- opt :env, 'Environment variables to add to the process, as NAME=VALUE.', :short => '-e', :type => :strings
61
- opt :constraint, 'Placement constraint for tasks, e.g. hostname:UNIQUE or rackid:CLUSTER', :type => :strings
53
+ opt :config, 'The JSON config file for this app.', :required => true, :short => '-c', :type => String
62
54
  end
63
55
  when 'scale'
64
56
  Trollop.options do
@@ -124,19 +116,8 @@ end
124
116
  case cmd
125
117
  when 'endpoints'
126
118
  puts haile.endpoints(cmd_opts[:id]).parsed_response
127
- when 'start'
128
- app_opts = {
129
- :instances => cmd_opts[:num_instances] || 1,
130
- :uris => cmd_opts[:uri] || [],
131
- :cmd => cmd_opts[:command],
132
- :env => cmd_opts[:env].nil? ? {} : Hash[cmd_opts[:env].map { |e| e.split('=', 2) }],
133
- :cpus => cmd_opts[:cpus] || 1.0,
134
- :mem => cmd_opts[:mem] || 10.0,
135
- :constraints => (cmd_opts[:constraint] || []).map { |c| c.split(':') }
136
- }
137
- app_opts[:executor] = cmd_opts[:executor] unless cmd_opts[:executor] == nil
138
- puts "Starting app '#{cmd_opts[:id]}'"
139
- puts haile.start(cmd_opts[:id], app_opts)
119
+ when 'upstart'
120
+ haile.upstart(cmd_opts[:config])
140
121
  when 'scale'
141
122
  puts "Scaling app '#{cmd_opts[:id]}' to #{cmd_opts[:num_instances]} instances"
142
123
  res = haile.scale(cmd_opts[:id], cmd_opts[:num_instances])
data/haile.gemspec CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.add_dependency "trollop", "~> 2.0"
21
21
  spec.add_dependency "httparty", "~> 0.11"
22
22
  spec.add_dependency "multi_json", "~> 1.8"
23
+ spec.add_dependency 'colorize', '~> 0.7.7', '>= 0.7.7'
23
24
 
24
25
  spec.add_development_dependency "bundler", "~> 1.3"
25
26
  spec.add_development_dependency "rake", "~> 0"
data/lib/haile/client.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'uri'
2
2
  require 'multi_json'
3
+ require 'colorize'
3
4
 
4
5
  module Haile
5
6
  class Client
@@ -60,10 +61,17 @@ module Haile
60
61
  wrap_request(:get, url)
61
62
  end
62
63
 
63
- def start(id, opts)
64
- body = opts.dup
65
- body[:id] = id
66
- wrap_request(:post, '/v2/apps/', :body => body)
64
+ def upstart(config_file)
65
+ body = JSON.parse(open(config_file).read)
66
+ id = body['id']
67
+ app = wrap_request(:get, "/v2/apps/#{id}").parsed_response['app']
68
+ if !!app
69
+ puts "Updating app #{id}...".green
70
+ wrap_request(:put, "/v2/apps/#{id}", :body => body)
71
+ else
72
+ puts "Starting app #{id}...".blue
73
+ wrap_request(:post, '/v2/apps/', :body => body)
74
+ end
67
75
  end
68
76
 
69
77
  def docker_deploy(id, image)
@@ -82,8 +90,7 @@ module Haile
82
90
  "with a docker image."
83
91
  return Haile::Response.error(msg)
84
92
  end
85
- resp = wrap_request(:put, "/v2/apps/#{id}", :body => app)
86
- puts "#{id}: #{resp.to_s}"
93
+ wrap_request(:put, "/v2/apps/#{id}", :body => app)
87
94
  end
88
95
 
89
96
  def scale(id, num_instances)
data/lib/haile/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Haile
2
- VERSION = "0.4.3"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobi Knaup
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-17 00:00:00.000000000 Z
12
+ date: 2016-09-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: trollop
@@ -53,6 +53,26 @@ dependencies:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '1.8'
56
+ - !ruby/object:Gem::Dependency
57
+ name: colorize
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 0.7.7
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 0.7.7
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: 0.7.7
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.7.7
56
76
  - !ruby/object:Gem::Dependency
57
77
  name: bundler
58
78
  requirement: !ruby/object:Gem::Requirement
@@ -119,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
139
  version: '0'
120
140
  requirements: []
121
141
  rubyforge_project:
122
- rubygems_version: 2.6.10
142
+ rubygems_version: 2.5.1
123
143
  signing_key:
124
144
  specification_version: 4
125
145
  summary: Ruby client for Marathon REST API