yu 0.1.2 → 0.1.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/README.md +3 -1
- data/lib/yu/version.rb +1 -1
- data/lib/yu.rb +49 -27
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fb3821b7af04978cc7fb9598a4263938a47da4c
|
4
|
+
data.tar.gz: f4cf06e57ac66b22d476ced6416d6482a6318518
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ec66d2b6c26aed578535573ea52925fc9cefae9ec65b7f51a32bcc534ea2a6614bcbc73f762e5e489c6b19b8195b4230bd5b9bc12fd75fb5b26bf670a5287d5
|
7
|
+
data.tar.gz: 9ed4968074a7998327b8e1d6c1887e89c68e6641d4fe011e6c32abf8e80b15cd9564ed4b6e8d53cc25cce3b700f61384ff6bf5904426d242e3b5531c3fb44ccb
|
data/README.md
CHANGED
@@ -21,11 +21,13 @@ yu test api
|
|
21
21
|
# Get a bash shell for a service
|
22
22
|
yu shell web
|
23
23
|
# Get a bash shell for testing a service
|
24
|
-
yu shell
|
24
|
+
yu shell --test api
|
25
25
|
# Build base images for all services
|
26
26
|
yu build
|
27
27
|
# Build base image for specific service(s)
|
28
28
|
yu build api web
|
29
|
+
# Reset everything
|
30
|
+
yu reset
|
29
31
|
```
|
30
32
|
|
31
33
|
## Development
|
data/lib/yu/version.rb
CHANGED
data/lib/yu.rb
CHANGED
@@ -12,27 +12,33 @@ module Yu
|
|
12
12
|
def call
|
13
13
|
program :name, 'yu'
|
14
14
|
program :version, VERSION
|
15
|
-
program :description, '
|
15
|
+
program :description, 'Helps you manage your microservices'
|
16
16
|
|
17
17
|
command :test do |c|
|
18
18
|
c.syntax = 'yu test'
|
19
|
-
c.description = 'Run
|
19
|
+
c.description = 'Run tests for service(s)'
|
20
20
|
c.action(method(:test))
|
21
21
|
end
|
22
22
|
|
23
23
|
command :build do |c|
|
24
24
|
c.syntax = 'yu build'
|
25
|
-
c.description = 'Build
|
25
|
+
c.description = 'Build image for service(s)'
|
26
26
|
c.action(method(:build))
|
27
27
|
end
|
28
28
|
|
29
29
|
command :shell do |c|
|
30
30
|
c.syntax = 'yu shell'
|
31
|
-
c.description = 'Start a shell container'
|
31
|
+
c.description = 'Start a shell container for a service'
|
32
32
|
c.option '--test'
|
33
33
|
c.action(method(:shell))
|
34
34
|
end
|
35
35
|
|
36
|
+
command :reset do |c|
|
37
|
+
c.syntax = 'yu reset'
|
38
|
+
c.description = 'Reset everything'
|
39
|
+
c.action(method(:reset))
|
40
|
+
end
|
41
|
+
|
36
42
|
global_option('-V', '--verbose', 'Verbose output') { $verbose_mode = true }
|
37
43
|
|
38
44
|
run!
|
@@ -51,7 +57,6 @@ module Yu
|
|
51
57
|
info "Running tests for #{container}..."
|
52
58
|
run_command(
|
53
59
|
"docker-compose run --rm #{container} bin/test",
|
54
|
-
showing_output: true,
|
55
60
|
exit_on_failure: false,
|
56
61
|
)
|
57
62
|
end
|
@@ -88,24 +93,24 @@ module Yu
|
|
88
93
|
end
|
89
94
|
end
|
90
95
|
|
91
|
-
def
|
92
|
-
info "Packaging gems
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
96
|
+
def reset(args, options)
|
97
|
+
info "Packaging gems in all services containing a Gemfile"
|
98
|
+
gemfiled_containers.each(&method(:package_gems_for_container))
|
99
|
+
info "Killing any running containers"
|
100
|
+
run_command("docker-compose kill")
|
101
|
+
info "Removing all existing containers"
|
102
|
+
run_command "docker-compose rm --force"
|
103
|
+
info "Building fresh images"
|
104
|
+
run_command "docker-compose build"
|
105
|
+
if File.exists? 'seed'
|
106
|
+
info "Seeding system state"
|
107
|
+
run_command "./seed"
|
108
|
+
end
|
109
|
+
info "Bringing all containers up"
|
110
|
+
run_command "docker-compose up -d --no-recreate"
|
106
111
|
end
|
107
112
|
|
108
|
-
def run_command(command, showing_output:
|
113
|
+
def run_command(command, showing_output: true, exit_on_failure: true)
|
109
114
|
unless showing_output || verbose_mode?
|
110
115
|
command = "#{command} &>/dev/null"
|
111
116
|
end
|
@@ -128,21 +133,38 @@ module Yu
|
|
128
133
|
end
|
129
134
|
end
|
130
135
|
|
131
|
-
def
|
132
|
-
|
136
|
+
def package_gems_for_container(container)
|
137
|
+
info "Packaging gems for #{container}"
|
138
|
+
run_command("cd #{container} && bundle package --all")
|
133
139
|
end
|
134
140
|
|
135
|
-
def
|
136
|
-
|
141
|
+
def gemfiled_containers
|
142
|
+
containers_with_file("Gemfile")
|
137
143
|
end
|
138
144
|
|
139
|
-
def
|
140
|
-
|
145
|
+
def testable_containers
|
146
|
+
containers_with_file("bin/test")
|
147
|
+
end
|
148
|
+
|
149
|
+
def normalise_container_name_from_dir(container_name_or_dir)
|
150
|
+
File.basename(container_name_or_dir)
|
151
|
+
end
|
152
|
+
|
153
|
+
def containers_with_file(file)
|
154
|
+
Dir.glob("*/#{file}").map { |dir_path| dir_path.split("/").first }
|
141
155
|
end
|
142
156
|
|
143
157
|
def execute_command(command)
|
144
158
|
info "Executing: #{command}" if verbose_mode?
|
145
159
|
exec(command)
|
146
160
|
end
|
161
|
+
|
162
|
+
def info(message)
|
163
|
+
say "[yu] #{message}"
|
164
|
+
end
|
165
|
+
|
166
|
+
def verbose_mode?
|
167
|
+
!!$verbose_mode
|
168
|
+
end
|
147
169
|
end
|
148
170
|
end
|