deployman 1.0.0 → 1.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.
- data/bin/deployman +2 -0
- data/lib/deployman/app/install.rb +24 -0
- data/lib/deployman/app/optionparser.rb +8 -2
- data/lib/deployman/component/filemanager.rb +23 -0
- data/lib/deployman/net/get.rb +22 -0
- metadata +3 -1
data/bin/deployman
CHANGED
@@ -10,10 +10,12 @@ require 'deployman/app/configuration'
|
|
10
10
|
require 'deployman/app/postsetup'
|
11
11
|
require 'deployman/component'
|
12
12
|
require 'deployman/component/downloader'
|
13
|
+
require 'deployman/component/filemanager'
|
13
14
|
require 'deployman/component/spinningclock'
|
14
15
|
require 'deployman/component/output'
|
15
16
|
require 'deployman/net'
|
16
17
|
require 'deployman/net/post'
|
18
|
+
require 'deployman/net/get'
|
17
19
|
require 'deployman/extractor'
|
18
20
|
require 'deployman/extractor/zip'
|
19
21
|
|
@@ -55,6 +55,11 @@ module Deployman::App::Install
|
|
55
55
|
create_configfile(owner, software, release, zip_url, dest)
|
56
56
|
puts "done!"
|
57
57
|
|
58
|
+
# createfiles from api
|
59
|
+
print "> Creating Files from API..."
|
60
|
+
createfiles_from_api(dest)
|
61
|
+
puts "done!"
|
62
|
+
|
58
63
|
# run deploy.rb
|
59
64
|
print "> Deploying..."
|
60
65
|
deployrb(dest)
|
@@ -82,6 +87,8 @@ module Deployman::App::Install
|
|
82
87
|
FileUtils.rm_rf(release_path)
|
83
88
|
end
|
84
89
|
|
90
|
+
# CREATE CONFIGFILE
|
91
|
+
#
|
85
92
|
def self.create_configfile (owner, software, release, zip_url, dest)
|
86
93
|
begin
|
87
94
|
config = {
|
@@ -100,6 +107,23 @@ module Deployman::App::Install
|
|
100
107
|
end
|
101
108
|
end
|
102
109
|
|
110
|
+
# CREATE FILES FROM API
|
111
|
+
#
|
112
|
+
def self.createfiles_from_api (dest)
|
113
|
+
begin
|
114
|
+
# foreach all fileUrls
|
115
|
+
@@options[:createfiles_from_api].each do |fileUrl|
|
116
|
+
# get file data from api request
|
117
|
+
data = Deployman::Net::Get.send fileUrl
|
118
|
+
# create file
|
119
|
+
Deployman::Component::Filemanager.create_file(dest + '/' + data['path'], data['content'])
|
120
|
+
end
|
121
|
+
rescue Exception => e
|
122
|
+
warn "ERROR: #{e.message}"
|
123
|
+
raise "Creating Files from API failed!"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
103
127
|
# RUN_DEPLOYRB
|
104
128
|
# dest = "/sandbox/liveserver/customerName/software/repoOnwer/repoName/releases/v2.2.0"
|
105
129
|
#
|
@@ -38,7 +38,7 @@ module Deployman::App::Optionparser
|
|
38
38
|
|
39
39
|
# config
|
40
40
|
options[:config] = {}
|
41
|
-
opts.on('--config VALUES', Array, "add custom config values (works only in combination with --install)") do |setting|
|
41
|
+
opts.on('--config VALUES', Array, "add custom config values (works only in combination with --install)\n\t\t\t\t\t VALUES = <key>,<value>,<key>,<value>,...") do |setting|
|
42
42
|
raise OptionParser::MissingArgument if setting.length % 2 != 0
|
43
43
|
# create key-value pairs from setting
|
44
44
|
config = {}
|
@@ -50,10 +50,16 @@ module Deployman::App::Optionparser
|
|
50
50
|
|
51
51
|
# callback
|
52
52
|
options[:callback] = false
|
53
|
-
opts.on('--callback URL', "callbacks status of installation (running/finished/error)
|
53
|
+
opts.on('--callback URL', "callbacks status of installation (running/finished/error) + stdout + stderr\n\t\t\t\t\t JSON-Format: { \"status\" => \"running\", \"stdout\" => <STDOUT>, \"stderr\" => <STDERR> }") do |setting|
|
54
54
|
options[:callback] = setting
|
55
55
|
end
|
56
56
|
|
57
|
+
# createfiles from api
|
58
|
+
options[:createfiles_from_api] = {}
|
59
|
+
opts.on('--createfiles_from_api VALUES', Array, "creates files from given api-urls (works only in combination with --install),\n\t\t\t\t\t VALUES = <api_url1>,<api_url2>,...\n\t\t\t\t\t The api call has to return the file in following json-format:\n\t\t\t\t\t {\"path\":\"path/to/file.txt\",\"content\":\"content of file\"}") do |setting|
|
60
|
+
options[:createfiles_from_api] = setting
|
61
|
+
end
|
62
|
+
|
57
63
|
# help
|
58
64
|
opts.on( '-h', '--help', 'Display help screen' ) do
|
59
65
|
puts opts
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Deployman::Component::Filemanager
|
4
|
+
|
5
|
+
# create file
|
6
|
+
#
|
7
|
+
def self.create_file(path, content)
|
8
|
+
|
9
|
+
# create unexisting folders from path
|
10
|
+
dirname = File.dirname(path)
|
11
|
+
unless File.directory?(dirname)
|
12
|
+
FileUtils.mkdir_p(dirname)
|
13
|
+
end
|
14
|
+
|
15
|
+
# create file
|
16
|
+
# existing file will be overwritten
|
17
|
+
File.open(path, 'wb') do |file|
|
18
|
+
file.write(content)
|
19
|
+
file.close
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Deployman::Net::Get
|
4
|
+
|
5
|
+
def self.send (url)
|
6
|
+
|
7
|
+
# create http object
|
8
|
+
uri = URI.parse(url)
|
9
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
10
|
+
|
11
|
+
# create request object
|
12
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
13
|
+
|
14
|
+
# do request and get response
|
15
|
+
response = http.request(request)
|
16
|
+
|
17
|
+
# parse JSON to array
|
18
|
+
resp_data = JSON.parse(response.body)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deployman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- lib/deployman/component/downloader.rb
|
56
56
|
- lib/deployman/component/spinningclock.rb
|
57
57
|
- lib/deployman/component/output.rb
|
58
|
+
- lib/deployman/component/filemanager.rb
|
58
59
|
- lib/deployman/app/postsetup.rb
|
59
60
|
- lib/deployman/app/optionparser.rb
|
60
61
|
- lib/deployman/app/configuration.rb
|
@@ -62,6 +63,7 @@ files:
|
|
62
63
|
- lib/deployman/extractor.rb
|
63
64
|
- lib/deployman/component.rb
|
64
65
|
- lib/deployman/extractor/zip.rb
|
66
|
+
- lib/deployman/net/get.rb
|
65
67
|
- lib/deployman/net/post.rb
|
66
68
|
- lib/deployman/app.rb
|
67
69
|
- bin/deployman
|