|
1 | | -require 'yaml' |
2 | | -require 'json' |
3 | | -require 'fileutils' |
4 | | -require 'tmpdir' |
| 1 | +require "yaml" |
| 2 | +require "json" |
| 3 | +require "fileutils" |
| 4 | +require "tmpdir" |
5 | 5 |
|
6 | 6 | garden_archive_path = ARGV[0] |
7 | 7 |
|
8 | | -%w{ |
| 8 | +%w[ |
9 | 9 | /var/vcap/sys/run/garden |
10 | 10 | /var/vcap/sys/log/garden |
11 | 11 | /var/vcap/data/garden/depo |
12 | 12 | /var/vcap/data/garden/bin |
13 | 13 | /var/vcap/data/tmp |
14 | | -}.each {|path| FileUtils.mkdir_p path} |
| 14 | +].each { |path| FileUtils.mkdir_p path } |
15 | 15 |
|
16 | | -installed_garden_job_path = File.join('/', 'var', 'vcap', 'jobs', 'garden') |
| 16 | +installed_garden_job_path = File.join("/", "var", "vcap", "jobs", "garden") |
17 | 17 |
|
18 | 18 | Dir.mktmpdir do |workspace| |
19 | 19 | `tar xzf #{garden_archive_path} -C #{workspace}` |
20 | | - garden_job_path = File.join(workspace, 'garden') |
| 20 | + garden_job_path = File.join(workspace, "garden") |
21 | 21 | FileUtils.mkdir_p garden_job_path |
22 | | - `tar xzf #{File.join(workspace, 'jobs', 'garden.tgz')} -C #{garden_job_path}` |
23 | | - garden_job_spec_path = File.join(garden_job_path, 'job.MF') |
| 22 | + `tar xzf #{File.join(workspace, "jobs", "garden.tgz")} -C #{garden_job_path}` |
| 23 | + garden_job_spec_path = File.join(garden_job_path, "job.MF") |
24 | 24 | job_spec = YAML.load_file(garden_job_spec_path) |
25 | | - job_spec['packages'].each do |package_name| |
26 | | - package_path = File.join('/', 'var', 'vcap', 'packages', package_name) |
| 25 | + job_spec["packages"].each do |package_name| |
| 26 | + package_path = File.join("/", "var", "vcap", "packages", package_name) |
27 | 27 | FileUtils.mkdir_p(package_path) |
28 | | - `tar xzf #{File.join(workspace, 'compiled_packages', "#{package_name}.tgz")} -C #{package_path}` |
| 28 | + `tar xzf #{File.join(workspace, "compiled_packages", "#{package_name}.tgz")} -C #{package_path}` |
29 | 29 | end |
30 | | - context_path = File.join(workspace, 'context.json') |
| 30 | + context_path = File.join(workspace, "context.json") |
31 | 31 | context = { |
32 | | - 'default_properties' => job_spec['properties'].map { |key, value| [key, value['default']]}.to_h, |
33 | | - 'job_properties' => { |
34 | | - 'garden' => { |
35 | | - 'allow_host_access': true, |
36 | | - 'debug_listen_address': '127.0.0.1:17013', |
37 | | - 'default_container_grace_time': '0', |
38 | | - 'destroy_containers_on_start': true, |
39 | | - 'graph_cleanup_threshold_in_mb': '0', |
40 | | - 'listen_address': '127.0.0.1:7777', |
41 | | - 'listen_network': 'tcp', |
| 32 | + "default_properties" => job_spec["properties"].map { |key, value| [key, value["default"]] }.to_h, |
| 33 | + "job_properties" => { |
| 34 | + "garden" => { |
| 35 | + allow_host_access: true, |
| 36 | + debug_listen_address: "127.0.0.1:17013", |
| 37 | + default_container_grace_time: "0", |
| 38 | + destroy_containers_on_start: true, |
| 39 | + graph_cleanup_threshold_in_mb: "0", |
| 40 | + listen_address: "127.0.0.1:7777", |
| 41 | + listen_network: "tcp" |
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | File.write(context_path, context.to_json) |
46 | | - templates = job_spec['templates'] |
| 46 | + templates = job_spec["templates"] |
47 | 47 | templates.each do |src, dst| |
48 | | - src_path = File.join(garden_job_path, 'templates', src) |
| 48 | + src_path = File.join(garden_job_path, "templates", src) |
49 | 49 | dest_path = File.join(installed_garden_job_path, dst) |
50 | 50 | FileUtils.mkdir_p(File.dirname(dest_path)) |
51 | | - `ruby #{File.join(__dir__, 'template-renderer.rb')} #{context_path} #{src_path} #{dest_path}` |
| 51 | + `ruby #{File.join(__dir__, "template-renderer.rb")} #{context_path} #{src_path} #{dest_path}` |
52 | 52 | end |
53 | 53 | end |
54 | 54 |
|
55 | | -`chmod +x #{File.join(installed_garden_job_path, 'bin', '*')}` |
| 55 | +`chmod +x #{File.join(installed_garden_job_path, "bin", "*")}` |
0 commit comments