ludwig 0.0.2 → 0.0.3
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 +4 -4
- data/lib/ludwig/cli.rb +24 -6
- data/lib/ludwig/composer.rb +2 -2
- data/lib/ludwig/service.rb +14 -11
- data/lib/ludwig/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b60bb41e36584ba8aac79780e599d4e9bea3249
|
4
|
+
data.tar.gz: 8863a356d1a716d4f85fed2b303025ec06cd99ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 170c200fdabfcd32cae8d1afa9bb82083f2eb3c03f3cd007b867e2d8e82ec0161b501e9cf326f44f758076cd45877d297cc56818bda0ee6f10c59eba08c17bec
|
7
|
+
data.tar.gz: 83224d7dc22c138b0178c683eb5bda14cdd4eea9bc425b377c768c5a0b4a70c90393fcd290aa83c8339c36e2a4f9f40bbeefd520daccd20d1ff393cec6c26170
|
data/lib/ludwig/cli.rb
CHANGED
@@ -3,26 +3,44 @@ require 'yaml'
|
|
3
3
|
module Ludwig
|
4
4
|
class CLI
|
5
5
|
include Commander::Methods
|
6
|
+
|
6
7
|
def run
|
7
8
|
program :version, Ludwig::VERSION
|
8
9
|
program :description, 'Ludwig, the famous composer'
|
9
10
|
|
10
|
-
@
|
11
|
+
@config_file = 'ludwig.yml'
|
11
12
|
|
12
13
|
global_option('-d', '--debug', 'Enable debug mode') { $debug = true }
|
13
|
-
global_option('-c', '--config filename', String, 'Set config filename') { |
|
14
|
+
global_option('-c', '--config filename', String, 'Set config filename') { |config_file| @config_file = config_file }
|
14
15
|
|
15
16
|
command :up do |c|
|
16
17
|
c.syntax = 'ludwig up [options]'
|
17
18
|
c.summary = 'Generate docker-compose.yml and launch docker-compose'
|
18
19
|
c.action do |args, options|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
generate_compose_file
|
21
|
+
system 'docker-compose up'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
command :build do |c|
|
26
|
+
c.syntax = 'ludwig build [options]'
|
27
|
+
c.summary = 'Generate docker-compose.yml'
|
28
|
+
c.action do |args, options|
|
29
|
+
generate_compose_file
|
23
30
|
end
|
24
31
|
end
|
32
|
+
|
25
33
|
run!
|
26
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def config
|
39
|
+
@config ||= YAML.load_file @config_file
|
40
|
+
end
|
41
|
+
|
42
|
+
def generate_compose_file
|
43
|
+
Ludwig::Composer.new(config).write_yaml
|
44
|
+
end
|
27
45
|
end
|
28
46
|
end
|
data/lib/ludwig/composer.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Ludwig
|
2
|
-
class Composer < Struct.new(:config
|
2
|
+
class Composer < Struct.new(:config)
|
3
3
|
def write_yaml
|
4
4
|
File.open('docker-compose.yml','w') do |h|
|
5
5
|
h.write generate_yaml
|
@@ -14,7 +14,7 @@ module Ludwig
|
|
14
14
|
config["available_projects"].each_with_object({}) do |project, new_compose_data|
|
15
15
|
data = YAML.load_file("../#{project}/docker-compose.yml")
|
16
16
|
data.each do |service_name, service_data|
|
17
|
-
service = Service.new(service_name, service_data,
|
17
|
+
service = Service.new(project, service_name, service_data, config)
|
18
18
|
new_compose_data["#{sanitize(project)}_#{service_name}"] = service.generate_yaml
|
19
19
|
end
|
20
20
|
end.to_yaml
|
data/lib/ludwig/service.rb
CHANGED
@@ -1,22 +1,25 @@
|
|
1
1
|
module Ludwig
|
2
|
-
class Service < Struct.new(:
|
2
|
+
class Service < Struct.new(:project, :name, :data, :config)
|
3
3
|
ACTION_MAP = {
|
4
|
-
volumes:
|
5
|
-
links:
|
4
|
+
volumes: :volumes_action,
|
5
|
+
links: :links_action,
|
6
6
|
env_file: :prefix_path,
|
7
|
-
build:
|
7
|
+
build: :prefix_path
|
8
8
|
}
|
9
9
|
|
10
10
|
def generate_yaml
|
11
|
-
data.each_with_object({}) do |(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
new_data = data.each_with_object({}) do |(key, value), memo|
|
12
|
+
memo[key] = execute_action(key, value)
|
13
|
+
end
|
14
|
+
|
15
|
+
if extra_links = config["extra_links"][name]
|
16
|
+
new_data["links"] ||= []
|
17
|
+
new_data["links"] += extra_links.map do |app|
|
18
|
+
"#{sanitize(app)}_#{config["default_app"]}:#{sanitize(app)}"
|
18
19
|
end
|
19
20
|
end
|
21
|
+
|
22
|
+
new_data
|
20
23
|
end
|
21
24
|
|
22
25
|
def execute_action(key, obj)
|
data/lib/ludwig/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ludwig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Stolz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|