ludwig 0.0.1
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 +7 -0
- data/bin/ludwig +9 -0
- data/lib/ludwig/cli.rb +28 -0
- data/lib/ludwig/composer.rb +25 -0
- data/lib/ludwig/service.rb +56 -0
- data/lib/ludwig/version.rb +3 -0
- data/lib/ludwig.rb +7 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1308e74e6c6b8419fc5f64af8ad95e00a4176f91
|
4
|
+
data.tar.gz: a2f468a431fe2aaf5bf1707a094e676319b6471a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75e200979f63bd43851477499a762e399a59f23bc22d033fce53130c5c1db465c0dc6f06af67aa7db1e12590a95685cf592ba7f602aec0f2ee4d3d06dab19015
|
7
|
+
data.tar.gz: 4f47ad8a3ca96f910f3b45155f1dd49170e96c22271b30d41d9dc1da569eb82afc6daec465711efaf4c3461347a7ef5c817597e92a240e43eb1d15a1280d7b2e
|
data/bin/ludwig
ADDED
data/lib/ludwig/cli.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Ludwig
|
4
|
+
class CLI
|
5
|
+
include Commander::Methods
|
6
|
+
def run
|
7
|
+
program :version, Ludwig::VERSION
|
8
|
+
program :description, 'Ludwig, the famous composer'
|
9
|
+
|
10
|
+
@config = "ludwig.yml"
|
11
|
+
|
12
|
+
global_option('-d', '--debug', 'Enable debug mode') { $debug = true }
|
13
|
+
global_option('-c', '--config filename', String, 'Set config filename') { |config| @config = config }
|
14
|
+
|
15
|
+
command :up do |c|
|
16
|
+
c.syntax = 'ludwig up [options]'
|
17
|
+
c.summary = 'Generate docker-compose.yml and launch docker-compose'
|
18
|
+
c.action do |args, options|
|
19
|
+
config = YAML.load_file(@config)
|
20
|
+
composer = Ludwig::Composer.new(config, options)
|
21
|
+
composer.write_yaml
|
22
|
+
system("docker-compose up")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
run!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
module Ludwig
|
4
|
+
class Composer < Struct.new(:config, :options)
|
5
|
+
def write_yaml
|
6
|
+
File.open('docker-compose.yml','w') do |h|
|
7
|
+
h.write generate_yaml
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def sanitize(input)
|
12
|
+
input.gsub(/-/, "_")
|
13
|
+
end
|
14
|
+
|
15
|
+
def generate_yaml
|
16
|
+
config["available_projects"].each_with_object({}) do |project, new_compose_data|
|
17
|
+
data = YAML.load_file("../#{project}/docker-compose.yml")
|
18
|
+
data.each do |service_name, service_data|
|
19
|
+
service = Service.new(service_name, service_data, project, config)
|
20
|
+
new_compose_data["#{sanitize(project)}_#{service_name}"] = service.generate_yaml
|
21
|
+
end
|
22
|
+
end.to_yaml
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
module Ludwig
|
4
|
+
class Service < Struct.new(:name, :data, :project, :config)
|
5
|
+
ACTION_MAP = {
|
6
|
+
volumes: :volumes_action,
|
7
|
+
links: :links_action,
|
8
|
+
env_file: :prefix_path,
|
9
|
+
build: :prefix_path
|
10
|
+
}
|
11
|
+
|
12
|
+
def generate_yaml
|
13
|
+
data.each_with_object({}) do |(service, service_data), new_data|
|
14
|
+
new_data[service] = execute_action(service, service_data)
|
15
|
+
if extra_links = config["extra_links"][service]
|
16
|
+
extra_links.each do |app|
|
17
|
+
new_data["links"] ||= []
|
18
|
+
new_data["links"] << "#{sanitize(app)}_#{config["default_app"]}:#{sanitize(app)}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute_action(key, obj)
|
25
|
+
action = ACTION_MAP[key.to_sym]
|
26
|
+
action ? send(action, obj) : obj
|
27
|
+
end
|
28
|
+
|
29
|
+
def volumes_action(volumes)
|
30
|
+
volumes.map do |volume|
|
31
|
+
local, remote = volume.split(":")
|
32
|
+
if local =~ /^\.\/?/
|
33
|
+
"#{prefix_path(local)}:#{remote}"
|
34
|
+
else
|
35
|
+
volume
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def links_action(links)
|
41
|
+
links.map do |link|
|
42
|
+
link_name, link_alias = link.split(":")
|
43
|
+
link_alias = link_name if link_alias.nil?
|
44
|
+
"#{sanitize(project)}_#{link_name}:#{link_alias}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def prefix_path(path)
|
49
|
+
"../#{project}/#{path}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def sanitize(input)
|
53
|
+
input.gsub(/-/, "_")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/ludwig.rb
ADDED
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ludwig
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Stolz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: commander
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Named after Ludwig van Beethoven, this project orchistrates multiple
|
84
|
+
projects with docker-compose.yml files.
|
85
|
+
email: bstolz@articulate.com
|
86
|
+
executables:
|
87
|
+
- ludwig
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- bin/ludwig
|
92
|
+
- lib/ludwig.rb
|
93
|
+
- lib/ludwig/cli.rb
|
94
|
+
- lib/ludwig/composer.rb
|
95
|
+
- lib/ludwig/service.rb
|
96
|
+
- lib/ludwig/version.rb
|
97
|
+
homepage:
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.4.5.1
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: Ludwig
|
121
|
+
test_files: []
|