ecs_compose 0.1.0.pre20 → 0.1.0.pre21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f69d1d6f4f1d2529604e03ab2ceae49643304be
4
- data.tar.gz: 925b5817f4ba8ae75030e6fb9be06d77d9d06174
3
+ metadata.gz: 55d8fcc5850ff69d5a1e58e11aa5a8f2833fd88a
4
+ data.tar.gz: 60e180a4221b945ef1e5751c77c5c17b8a8b9482
5
5
  SHA512:
6
- metadata.gz: 5e8f426785be843d9ebd8162250fe90e4a8c1afc32ad48b80965b5f6c511d8fcebcf0eeb20fb1dfb509287471a0369de4fe5143f32ca71482eac3b96a0543333
7
- data.tar.gz: 69e45ae4c4772f5bc3a561c04fd06045adc81e7e806353d7891caab42451c92a65d56b59722c5b7975ee23b45f1254d4585ce4d5d8802ebc1c121ba19582344c
6
+ metadata.gz: e15686e4f614e94e2016b2eb2575f44801b7440ad1bca95b77293270eef9009ca88aec87a5c0d55787e1af6b0f08d1e1954605350143bc19b95a77a46829673e
7
+ data.tar.gz: 2de5e884c78d17fedadea416f98debad47e17ee05ed8c25432a80f6693646fb84a68d5aef0d13c9ef79f8126ceabdd793c95173f4121de7c27248a93701d615a
data/exe/ecs-compose CHANGED
@@ -26,6 +26,12 @@ Options:
26
26
  -i, --file-info (task:<name> | service:<name>)
27
27
  Specify the task type and task name for a
28
28
  docker-compose.yml file
29
+ -p, --project-name <project-name>
30
+ Will be prepended to the names of task definitions
31
+ and services, to permit running multiple versions of
32
+ an app on a single cluster. If your task name is
33
+ "foo", and your project name is "staging", then it
34
+ will be registered and run as "staging-foo".
29
35
  --cluster <cluster> ECS cluster to use [default: default]
30
36
  -e <name>=<value> Set an environment variable
31
37
  --entrypoint <entrypoint>
@@ -195,9 +201,11 @@ class App
195
201
  # Create a manifest, either by reading it in, or synthesizing it from a
196
202
  # `docker-compose.yml` file and some extra arguments.
197
203
  def load_manifest
204
+ project_name = options.fetch("--project-name") || nil
198
205
  case mode
199
206
  when :manifest
200
- Manifest.read_from_manifest(options.fetch('--manifest') || DEFAULT_MANIFEST)
207
+ Manifest.read_from_manifest(options.fetch('--manifest') || DEFAULT_MANIFEST,
208
+ project_name)
201
209
  when :file
202
210
  info = options.fetch('--file-info')
203
211
  if info.nil?
@@ -208,7 +216,7 @@ class App
208
216
  end
209
217
  type, name = $1, $2
210
218
  Manifest.read_from_file(options.fetch('--file') || DEFAULT_FILE,
211
- type.to_sym, name)
219
+ project_name, type.to_sym, name)
212
220
  else raise "Unknown mode: #{mode}"
213
221
  end
214
222
  end
@@ -4,22 +4,37 @@ module EcsCompose
4
4
 
5
5
  # A collection of multiple task definitions, including names and types.
6
6
  class Manifest
7
- # Build a manifest from a single `docker-compose.yml` file, using the
8
- # supplied type and name.
9
- def self.read_from_file(path, type, name)
10
- new([TaskDefinition.new(type, name, File.read(path))])
11
- end
7
+ class << self
8
+ # Build a manifest from a single `docker-compose.yml` file, using the
9
+ # supplied type and name.
10
+ def read_from_file(path, project_name, type, name)
11
+ new([TaskDefinition.new(type,
12
+ compound_name(project_name, name),
13
+ File.read(path))])
14
+ end
15
+
16
+ # Read in a complete manifest.
17
+ def read_from_manifest(path, project_name)
18
+ dir = File.dirname(path)
19
+ yaml = Psych.load_file(path)
20
+ defs = yaml.fetch('task_definitions').map do |name, info|
21
+ TaskDefinition.new(info.fetch('type').to_sym,
22
+ compound_name(project_name, name),
23
+ File.read(File.join(dir, info.fetch('path'))))
24
+ end
25
+ new(defs)
26
+ end
27
+
28
+ private
12
29
 
13
- # Read in a complete manifest.
14
- def self.read_from_manifest(path)
15
- dir = File.dirname(path)
16
- yaml = Psych.load_file(path)
17
- defs = yaml.fetch('task_definitions').map do |name, info|
18
- TaskDefinition.new(info.fetch('type').to_sym,
19
- name,
20
- File.read(File.join(dir, info.fetch('path'))))
30
+ # If we've been supplied with a `project_name`, build a compound name.
31
+ def compound_name(project_name, name)
32
+ if project_name.nil?
33
+ name
34
+ else
35
+ "#{project_name}-#{name}"
36
+ end
21
37
  end
22
- new(defs)
23
38
  end
24
39
 
25
40
  attr_reader :task_definitions
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs_compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre20
4
+ version: 0.1.0.pre21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kidd
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-13 00:00:00.000000000 Z
11
+ date: 2015-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt