brpm_content_framework 0.2.40 → 0.2.41
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/build_docker_image +55 -0
- data/bin/publish_docker_image +75 -0
- data/config.yml +1 -1
- data/docker/{Dockerfile → framework/Dockerfile} +3 -3
- data/docker/{docker_execute_automation → framework/docker_execute_automation} +0 -0
- data/docker/modules/Dockerfile +10 -0
- data/lib/brpm_script_executor.rb +17 -13
- data/lib/utilities.rb +8 -0
- metadata +9 -5
- data/infrastructure/scripts/publish_module_version.sh +0 -45
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjRlMWMyZWNkZDMwMTQwNjE5MDUwMTExOTgzNGM0ODA0ODE3OWUxYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTdhNTdmZGFmN2Q1OGY1NmZkM2RlNmJmYTQ3Yzg4Y2E0ODJkNWE4Yw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmNhNmFiZjczMzRhNmUxNTRiNTU5M2FlYWQyOGE4YzIxYWRkNzA2N2QzMDUx
|
10
|
+
ZDU2NTZhMGYyNGIxMGNlNzM2NmMxNmI4YWU0MjA0Y2EyMzIwMjhhNGE3OGYw
|
11
|
+
ZTU4MGMxODQ1ZjZhYjhkNjE0YjUzY2VlZjdkZDRkODBmMzE2NDE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjljM2U0MjA0MWMzMmRjMTUwNDBlMzIxOWMzOTE3OTI4ODhkMDlmNjY4MTk3
|
14
|
+
MmI5OTQ0ZDhmZjc0NWFlNTYzYzY5MDA1Y2E4ZGM0MmVmNjFhOWQ1NjRmNDA0
|
15
|
+
MWY5MjljN2IxZmJiYzUwM2U5MzgxMTJlZjJhYjI2MzgyYjQxYWY=
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "brpm_auto"
|
3
|
+
|
4
|
+
if ARGV.size < 1
|
5
|
+
puts "Missing arguments."
|
6
|
+
puts "Usage: \n build_docker_image <path to module>"
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
|
10
|
+
begin
|
11
|
+
BrpmAuto.setup({ "log_file" => "/tmp/brpm_install.log", "also_log_to_console" => "true" })
|
12
|
+
|
13
|
+
module_path = File.expand_path(ARGV[0])
|
14
|
+
|
15
|
+
module_name = File.basename(module_path)
|
16
|
+
module_config = YAML.load_file("#{module_path}/config.yml")
|
17
|
+
module_version = module_config["version"]
|
18
|
+
|
19
|
+
BrpmAuto.log "Module #{module_name} #{module_version}"
|
20
|
+
|
21
|
+
if module_name == "brpm_content_framework"
|
22
|
+
dockerfile_path = File.expand_path("#{File.dirname(__FILE__)}/../docker/framework/Dockerfile")
|
23
|
+
else
|
24
|
+
dockerfile_path = File.expand_path("#{File.dirname(__FILE__)}/../docker/modules/Dockerfile")
|
25
|
+
end
|
26
|
+
|
27
|
+
dockerfile_content = File.read(dockerfile_path)
|
28
|
+
dockerfile_original_content = File.read(dockerfile_path)
|
29
|
+
|
30
|
+
unless module_name == "brpm_content_framework"
|
31
|
+
dockerfile_content.sub!(/(?<=ENV MODULE )(.*)/, module_name)
|
32
|
+
end
|
33
|
+
dockerfile_content.sub!(/(?<=ENV VERSION )(.*)/, module_version)
|
34
|
+
|
35
|
+
File.open(dockerfile_path, "w") do |file|
|
36
|
+
file << dockerfile_content
|
37
|
+
end
|
38
|
+
|
39
|
+
BrpmAuto.log ""
|
40
|
+
BrpmAuto.log ">>> Building docker image bmcrlm/#{module_name}:#{module_version}..."
|
41
|
+
_, stderr, _, status = BrpmAuto.execute_command("docker build -t bmcrlm/#{module_name}:#{module_version} #{File.dirname(dockerfile_path)}") do |stdout_err|
|
42
|
+
BrpmAuto.log " #{stdout_err.chomp}"
|
43
|
+
end
|
44
|
+
raise "The process failed with status #{status.exitstatus}.\n#{stderr}" unless status.success?
|
45
|
+
|
46
|
+
File.open(dockerfile_path, "w") do |file|
|
47
|
+
file << dockerfile_original_content
|
48
|
+
end
|
49
|
+
|
50
|
+
rescue Exception => e
|
51
|
+
BrpmAuto.log_error "#{e}"
|
52
|
+
BrpmAuto.log "\n\t" + e.backtrace.join("\n\t")
|
53
|
+
|
54
|
+
raise e
|
55
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "brpm_auto"
|
3
|
+
|
4
|
+
if ARGV.size < 1
|
5
|
+
puts "Missing arguments."
|
6
|
+
puts "Usage: \n publish_docker_image <path to module>"
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
|
10
|
+
begin
|
11
|
+
BrpmAuto.setup({ "log_file" => "/tmp/brpm_install.log", "also_log_to_console" => "true" })
|
12
|
+
|
13
|
+
module_path = File.expand_path(ARGV[0])
|
14
|
+
|
15
|
+
module_name = File.basename(module_path)
|
16
|
+
module_config = YAML.load_file("#{module_path}/config.yml")
|
17
|
+
module_version = module_config["version"]
|
18
|
+
|
19
|
+
BrpmAuto.log "Module #{module_name} #{module_version}"
|
20
|
+
|
21
|
+
if module_name == "brpm_content_framework"
|
22
|
+
dockerfile_path = File.expand_path("#{File.dirname(__FILE__)}/../docker/framework/Dockerfile")
|
23
|
+
else
|
24
|
+
dockerfile_path = File.expand_path("#{File.dirname(__FILE__)}/../docker/modules/Dockerfile")
|
25
|
+
end
|
26
|
+
|
27
|
+
dockerfile_content = File.read(dockerfile_path)
|
28
|
+
dockerfile_original_content = File.read(dockerfile_path)
|
29
|
+
|
30
|
+
unless module_name == "brpm_content_framework"
|
31
|
+
dockerfile_content.sub!(/(?<=ENV MODULE )(.*)/, module_name)
|
32
|
+
end
|
33
|
+
dockerfile_content.sub!(/(?<=ENV VERSION )(.*)/, module_version)
|
34
|
+
|
35
|
+
File.open(dockerfile_path, "w") do |file|
|
36
|
+
file << dockerfile_content
|
37
|
+
end
|
38
|
+
|
39
|
+
BrpmAuto.log ""
|
40
|
+
BrpmAuto.log ">>> Building docker image bmcrlm/#{module_name}:#{module_version}..."
|
41
|
+
_, stderr, _, status = BrpmAuto.execute_command("docker build -t bmcrlm/#{module_name}:#{module_version} #{File.dirname(dockerfile_path)}") do |stdout_err|
|
42
|
+
BrpmAuto.log " #{stdout_err.chomp}"
|
43
|
+
end
|
44
|
+
raise "The process failed with status #{status.exitstatus}.\n#{stderr}" unless status.success?
|
45
|
+
|
46
|
+
File.open(dockerfile_path, "w") do |file|
|
47
|
+
file << dockerfile_original_content
|
48
|
+
end
|
49
|
+
|
50
|
+
BrpmAuto.log ""
|
51
|
+
BrpmAuto.log ">>> Publishing docker image bmcrlm/#{module_name}:#{module_version} to the docker hub..."
|
52
|
+
_, stderr, _, status = BrpmAuto.execute_command("docker push bmcrlm/#{module_name}:#{module_version}") do |stdout_err|
|
53
|
+
BrpmAuto.log " #{stdout_err.chomp}"
|
54
|
+
end
|
55
|
+
raise "The process failed with status #{status.exitstatus}.\n#{stderr}" unless status.success?
|
56
|
+
|
57
|
+
if module_name == "brpm_content_framework"
|
58
|
+
BrpmAuto.log ""
|
59
|
+
BrpmAuto.log ">>> Tagging docker image bmcrlm/#{module_name}:#{module_version} as bmcrlm/#{module_name}:latest..."
|
60
|
+
_, stderr, _, status = BrpmAuto.execute_command("docker tag -f bmcrlm/#{module_name}:#{module_version} bmcrlm/#{module_name}:latest") do |stdout_err|
|
61
|
+
BrpmAuto.log " #{stdout_err.chomp}"
|
62
|
+
end
|
63
|
+
raise "The process failed with status #{status.exitstatus}.\n#{stderr}" unless status.success?
|
64
|
+
_, stderr, _, status = BrpmAuto.execute_command("docker push bmcrlm/#{module_name}:latest") do |stdout_err|
|
65
|
+
BrpmAuto.log " #{stdout_err.chomp}"
|
66
|
+
end
|
67
|
+
raise "The process failed with status #{status.exitstatus}.\n#{stderr}" unless status.success?
|
68
|
+
end
|
69
|
+
|
70
|
+
rescue Exception => e
|
71
|
+
BrpmAuto.log_error "#{e}"
|
72
|
+
BrpmAuto.log "\n\t" + e.backtrace.join("\n\t")
|
73
|
+
|
74
|
+
raise e
|
75
|
+
end
|
data/config.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
FROM atlashealth/ruby:1.9.3
|
2
2
|
MAINTAINER Niek Bartholomeus <niek.bartholomeus@gmail.com>
|
3
3
|
|
4
|
-
ENV BRPM_CONTENT_FRAMEWORK_VERSION 1.0.0
|
5
4
|
ENV GEM_HOME /usr/lib/ruby/gems/1.9.1
|
5
|
+
ENV VERSION 1.0.0
|
6
6
|
|
7
|
-
RUN gem install brpm_content_framework -v $
|
8
|
-
cd $GEM_HOME/gems/brpm_content_framework-$
|
7
|
+
RUN gem install brpm_content_framework -v $VERSION && \
|
8
|
+
cd $GEM_HOME/gems/brpm_content_framework-$VERSION && \
|
9
9
|
bundle install && \
|
10
10
|
rm -rf $GEM_HOME/cache
|
11
11
|
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
FROM bmcrlm/brpm_content_framework
|
2
|
+
MAINTAINER Niek Bartholomeus <niek.bartholomeus@gmail.com>
|
3
|
+
|
4
|
+
ENV MODULE module
|
5
|
+
ENV VERSION 1.0.0
|
6
|
+
|
7
|
+
RUN gem install $MODULE -v $VERSION && \
|
8
|
+
cd $GEM_HOME/gems/$MODULE-$VERSION && \
|
9
|
+
bundle install && \
|
10
|
+
rm -rf $GEM_HOME/cache
|
data/lib/brpm_script_executor.rb
CHANGED
@@ -73,13 +73,8 @@ class BrpmScriptExecutor
|
|
73
73
|
command += " \"#{max_records}\"" if max_records
|
74
74
|
end
|
75
75
|
|
76
|
-
_, stderr, _, status = BrpmAuto.execute_command(command) do |stdout_err|
|
77
|
-
BrpmAuto.log " stdout:#{stdout_err.chomp}"
|
78
|
-
end
|
79
|
-
|
80
76
|
else
|
81
|
-
|
82
|
-
env_vars["GEM_HOME"] = ENV["BRPM_CONTENT_HOME"] || "#{ENV["BRPM_HOME"]}/modules"
|
77
|
+
env_var_gem_home = "export GEM_HOME=#{ENV["BRPM_CONTENT_HOME"] || "#{ENV["BRPM_HOME"]}/modules"} && "
|
83
78
|
|
84
79
|
module_path = get_module_gem_path(modul, module_version)
|
85
80
|
|
@@ -92,24 +87,33 @@ class BrpmScriptExecutor
|
|
92
87
|
gemfile_path = "#{module_path}/Gemfile"
|
93
88
|
if File.exists?(gemfile_path)
|
94
89
|
BrpmAuto.log "Using Gemfile #{gemfile_path}."
|
95
|
-
|
90
|
+
env_var_bundler = "export BUNDLE_GEMFILE=#{gemfile_path} && "
|
96
91
|
require_bundler = "require 'bundler/setup';"
|
97
92
|
else
|
98
93
|
BrpmAuto.log("This module doesn't have a Gemfile.")
|
94
|
+
env_var_bundler = ""
|
99
95
|
require_bundler = ""
|
100
96
|
end
|
101
97
|
|
102
98
|
BrpmAuto.log "Executing the script in a separate process..."
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
99
|
+
ruby_command = <<EOR
|
100
|
+
#{require_bundler}
|
101
|
+
require \\"brpm_script_executor\\"
|
102
|
+
BrpmScriptExecutor.execute_automation_script_from_other_process(\\"#{modul}\\", \\"#{name}\\", \\"#{params_path}\\", \\"#{automation_type}\\", \\"#{parent_id}\\", \\"#{offset}\\", \\"#{max_records}\\")
|
103
|
+
EOR
|
104
|
+
command = "#{env_var_gem_home}#{env_var_bundler}ruby -e \"#{ruby_command}\""
|
105
|
+
end
|
106
|
+
|
107
|
+
result = Bundler.with_clean_env do
|
108
|
+
BrpmAuto.execute_shell(command)
|
108
109
|
end
|
109
110
|
|
110
111
|
FileUtils.rm(params_path) if File.exists?(params_path)
|
111
112
|
|
112
|
-
|
113
|
+
unless result["status"] == 0
|
114
|
+
BrpmAuto.log "stdout:#{result["stdout"]}"
|
115
|
+
raise "The process failed with status #{result["status"]}.\n#{result["stderr"]}"
|
116
|
+
end
|
113
117
|
|
114
118
|
BrpmAuto.log "The process finished succesfully."
|
115
119
|
|
data/lib/utilities.rb
CHANGED
@@ -318,6 +318,14 @@ module Utilities
|
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
321
|
+
def replace_in_file(file_path, pattern, replacement)
|
322
|
+
file_content = File.read(file_path)
|
323
|
+
|
324
|
+
File.open(file_path, "w") do |file|
|
325
|
+
file << file_content.gsub(pattern, replacement)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
321
329
|
private
|
322
330
|
|
323
331
|
#TODO: still needed? the framework's error handling should take care of this already
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brpm_content_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.41
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niek Bartholomeus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -157,7 +157,9 @@ email: niek.bartholomeus@gmail.com
|
|
157
157
|
executables:
|
158
158
|
- brpm_install
|
159
159
|
- brpm_uninstall
|
160
|
+
- build_docker_image
|
160
161
|
- event_handler
|
162
|
+
- publish_docker_image
|
161
163
|
- webhook_receiver
|
162
164
|
extensions: []
|
163
165
|
extra_rdoc_files: []
|
@@ -176,11 +178,14 @@ files:
|
|
176
178
|
- automations/install_module.rb
|
177
179
|
- bin/brpm_install
|
178
180
|
- bin/brpm_uninstall
|
181
|
+
- bin/build_docker_image
|
179
182
|
- bin/event_handler
|
183
|
+
- bin/publish_docker_image
|
180
184
|
- bin/webhook_receiver
|
181
185
|
- config.yml
|
182
|
-
- docker/Dockerfile
|
183
|
-
- docker/docker_execute_automation
|
186
|
+
- docker/framework/Dockerfile
|
187
|
+
- docker/framework/docker_execute_automation
|
188
|
+
- docker/modules/Dockerfile
|
184
189
|
- infrastructure/.bashrc
|
185
190
|
- infrastructure/.brpm
|
186
191
|
- infrastructure/config/customer_include.rb
|
@@ -204,7 +209,6 @@ files:
|
|
204
209
|
- infrastructure/scripts/install_brpm.sh
|
205
210
|
- infrastructure/scripts/maintenance.sh
|
206
211
|
- infrastructure/scripts/patch_brpm.sh
|
207
|
-
- infrastructure/scripts/publish_module_version.sh
|
208
212
|
- infrastructure/scripts/restore_database.sh
|
209
213
|
- infrastructure/scripts/run_event_handler.cmd
|
210
214
|
- infrastructure/scripts/run_event_handler.sh
|
@@ -1,45 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
USAGE="publish_module_version.sh <module name>"
|
3
|
-
|
4
|
-
MODULE_NAME=$1
|
5
|
-
|
6
|
-
if [ -z "$MODULE_NAME" ]; then
|
7
|
-
echo "Module name is not specified. Aborting."
|
8
|
-
echo "Usage: $USAGE"
|
9
|
-
exit 1
|
10
|
-
fi
|
11
|
-
|
12
|
-
cd $(dirname $0)/../../../$MODULE_NAME
|
13
|
-
|
14
|
-
echo ""
|
15
|
-
echo ">>> Publishing module $MODULE_NAME as a gem to rubygems.org..."
|
16
|
-
rake release
|
17
|
-
if [ -f "docker/Dockerfile" ]; then
|
18
|
-
MODULE_VERSION=$(eval "sed -n \"s=version: \(.*\)=\1=p\" config.yml")
|
19
|
-
|
20
|
-
cd docker
|
21
|
-
|
22
|
-
if [[ "$MODULE_NAME" == brpm_content_framework ]]; then
|
23
|
-
OLD_MODULE_VERSION=$(eval "sed -n \"s=ENV BRPM_CONTENT_FRAMEWORK_VERSION \(.*\)=\1=p\" Dockerfile")
|
24
|
-
else
|
25
|
-
OLD_MODULE_VERSION=$(eval "sed -n \"s=ENV VERSION \(.*\)=\1=p\" Dockerfile")
|
26
|
-
fi
|
27
|
-
sed -i "" s/$OLD_MODULE_VERSION/$MODULE_VERSION/ Dockerfile
|
28
|
-
|
29
|
-
echo ""
|
30
|
-
echo ">>> Building docker image bmcrlm/$MODULE_NAME:$MODULE_VERSION..."
|
31
|
-
docker build -t bmcrlm/$MODULE_NAME:$MODULE_VERSION . || { echo 'Aborting' ; exit 1; }
|
32
|
-
|
33
|
-
sed -i "" s/$MODULE_VERSION/$OLD_MODULE_VERSION/ Dockerfile
|
34
|
-
|
35
|
-
echo ""
|
36
|
-
echo ">>> Publishing docker image bmcrlm/$MODULE_NAME:$MODULE_VERSION to the docker hub..."
|
37
|
-
docker push bmcrlm/$MODULE_NAME:$MODULE_VERSION || { echo 'Aborting' ; exit 1; }
|
38
|
-
|
39
|
-
if [[ "$MODULE_NAME" == brpm_content_framework ]]; then
|
40
|
-
echo ""
|
41
|
-
echo ">>> Tagging bmcrlm/$MODULE_NAME:$MODULE_VERSION as bmcrlm/$MODULE_NAME:latest..."
|
42
|
-
docker tag -f bmcrlm/$MODULE_NAME:$MODULE_VERSION bmcrlm/$MODULE_NAME:latest || { echo 'Aborting' ; exit 1; }
|
43
|
-
docker push bmcrlm/$MODULE_NAME:latest || { echo 'Aborting' ; exit 1; }
|
44
|
-
fi
|
45
|
-
fi
|