MuranoCLI 2.2.3 → 2.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.agignore +13 -0
- data/Rakefile +19 -19
- data/lib/MrMurano.rb +1 -1
- data/lib/MrMurano/Config.rb +5 -0
- data/lib/MrMurano/ReCommander.rb +8 -1
- data/lib/MrMurano/Solution-Cors.rb +1 -0
- data/lib/MrMurano/Solution-Endpoint.rb +3 -1
- data/lib/MrMurano/Solution-File.rb +3 -1
- data/lib/MrMurano/Solution-ServiceConfig.rb +4 -1
- data/lib/MrMurano/Solution-Services.rb +2 -1
- data/lib/MrMurano/Solution.rb +1 -1
- data/lib/MrMurano/SyncUpDown.rb +2 -2
- data/lib/MrMurano/commands.rb +1 -0
- data/lib/MrMurano/commands/business.rb +15 -0
- data/lib/MrMurano/commands/init.rb +6 -4
- data/lib/MrMurano/commands/postgresql.rb +37 -15
- data/lib/MrMurano/commands/solutionCreate.rb +5 -3
- data/lib/MrMurano/commands/status.rb +14 -8
- data/lib/MrMurano/version.rb +1 -1
- data/spec/cmd_domain_spec.rb +1 -1
- data/spec/fixtures/dumped_config +3 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e73fc277539519b2b36d38f2d86a67bd106779e2
|
4
|
+
data.tar.gz: f715f1075a208806e9ff2f9e989f154f312bfde8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 552129eb3e4167a498cd8ad76910fa9efd1793cc1b96331542956009c5e18eacdede1a27bd3017b2d10b77e7aa6add683609459c40ff8bf107b864e23a8cb85d
|
7
|
+
data.tar.gz: 351343bca4f083fbb75ca4452a5878c43268943ea25c905d8d73f55b7de954442c12124eb1e1fe2a18fa2dc04d000fb7596e5cc7dfe6391d43338fb964f98f41
|
data/.agignore
ADDED
data/Rakefile
CHANGED
@@ -31,7 +31,7 @@ gvim lib/MrMurano/version.rb
|
|
31
31
|
git commit -a -m 'version bump'
|
32
32
|
git flow release finish <newversion>
|
33
33
|
# When editing message for tag, add release notes.
|
34
|
-
rake git:all
|
34
|
+
#rake git:all
|
35
35
|
# Wait for all tests to complete.
|
36
36
|
# if all passed: rake gemit
|
37
37
|
EOR
|
@@ -71,24 +71,24 @@ end
|
|
71
71
|
|
72
72
|
###
|
73
73
|
# When new tags are pushed to upstream, the CI will kick-in and build the release
|
74
|
-
namespace :git do
|
75
|
-
desc "Push only develop, master, and tags to origin"
|
76
|
-
task :origin do
|
77
|
-
sh %{git push origin develop}
|
78
|
-
sh %{git push origin master}
|
79
|
-
sh %{git push origin --tags}
|
80
|
-
end
|
81
|
-
|
82
|
-
desc "Push only develop, master, and tags to upstream"
|
83
|
-
task :upstream do
|
84
|
-
sh %{git push upstream develop}
|
85
|
-
sh %{git push upstream master}
|
86
|
-
sh %{git push upstream --tags}
|
87
|
-
end
|
88
|
-
|
89
|
-
desc "Push to origin and upstream"
|
90
|
-
task :all => [:origin, :upstream]
|
91
|
-
end
|
74
|
+
#namespace :git do
|
75
|
+
# desc "Push only develop, master, and tags to origin"
|
76
|
+
# task :origin do
|
77
|
+
# sh %{git push origin develop}
|
78
|
+
# sh %{git push origin master}
|
79
|
+
# sh %{git push origin --tags}
|
80
|
+
# end
|
81
|
+
#
|
82
|
+
# desc "Push only develop, master, and tags to upstream"
|
83
|
+
# task :upstream do
|
84
|
+
# sh %{git push upstream develop}
|
85
|
+
# sh %{git push upstream master}
|
86
|
+
# sh %{git push upstream --tags}
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
# desc "Push to origin and upstream"
|
90
|
+
# task :all => [:origin, :upstream]
|
91
|
+
#end
|
92
92
|
|
93
93
|
desc "Build, install locally, and push gem"
|
94
94
|
task :gemit do
|
data/lib/MrMurano.rb
CHANGED
data/lib/MrMurano/Config.rb
CHANGED
@@ -142,6 +142,8 @@ module MrMurano
|
|
142
142
|
else
|
143
143
|
set('diff.cmd', 'diff -u', :defaults)
|
144
144
|
end
|
145
|
+
|
146
|
+
set('postgresql.migrations_dir', 'sql-migrations', :defaults)
|
145
147
|
end
|
146
148
|
|
147
149
|
## Find the root of this project Directory.
|
@@ -281,6 +283,9 @@ module MrMurano
|
|
281
283
|
|
282
284
|
end
|
283
285
|
|
286
|
+
class ConfigError < StandardError
|
287
|
+
end
|
288
|
+
|
284
289
|
end
|
285
290
|
|
286
291
|
# vim: set ai et sw=2 ts=2 :
|
data/lib/MrMurano/ReCommander.rb
CHANGED
@@ -35,7 +35,14 @@ module Commander
|
|
35
35
|
hooked = MrMurano::Hooked.new(section)
|
36
36
|
hooked.check_run_pre_hook
|
37
37
|
|
38
|
-
|
38
|
+
begin
|
39
|
+
old_run_active_command
|
40
|
+
rescue MrMurano::ConfigError => err
|
41
|
+
puts err.message
|
42
|
+
exit 1
|
43
|
+
rescue StandardError => err
|
44
|
+
raise
|
45
|
+
end
|
39
46
|
|
40
47
|
hooked.check_run_post_hook
|
41
48
|
end
|
@@ -13,6 +13,7 @@ module MrMurano
|
|
13
13
|
|
14
14
|
def fetch(id=nil, &block)
|
15
15
|
ret = get()
|
16
|
+
return [] if ret.is_a? Hash and ret.has_key? :error
|
16
17
|
if ret.kind_of?(Hash) and ret.has_key?(:cors) then
|
17
18
|
# XXX cors is a JSON encoded string. That seems weird. keep an eye on this.
|
18
19
|
data = JSON.parse(ret[:cors], @json_opts)
|
@@ -30,7 +30,9 @@ module MrMurano
|
|
30
30
|
##
|
31
31
|
# This gets all data about all endpoints
|
32
32
|
def list
|
33
|
-
get()
|
33
|
+
ret = get()
|
34
|
+
return [] if ret.is_a? Hash and ret.has_key? :error
|
35
|
+
ret.map do |item|
|
34
36
|
if item[:content_type].nil? or item[:content_type].empty? then
|
35
37
|
item[:content_type] = 'application/json'
|
36
38
|
end
|
@@ -10,7 +10,9 @@ module MrMurano
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def list
|
13
|
-
get()
|
13
|
+
ret = get()
|
14
|
+
return [] if ret.is_a? Hash and ret.has_key? :error
|
15
|
+
ret[:items]
|
14
16
|
end
|
15
17
|
def fetch(id)
|
16
18
|
get('/' + id.to_s)
|
@@ -85,6 +87,7 @@ module MrMurano
|
|
85
87
|
|
86
88
|
def list
|
87
89
|
ret = get()
|
90
|
+
return [] if ret.is_a? Hash and ret.has_key? :error
|
88
91
|
ret[:items]
|
89
92
|
end
|
90
93
|
|
@@ -191,7 +191,7 @@ module MrMurano
|
|
191
191
|
|
192
192
|
def list
|
193
193
|
ret = get()
|
194
|
-
return []
|
194
|
+
return [] if ret.is_a? Hash and ret.has_key? :error
|
195
195
|
ret[:items].map{|i| LibraryItem.new(i)}
|
196
196
|
end
|
197
197
|
|
@@ -250,6 +250,7 @@ module MrMurano
|
|
250
250
|
|
251
251
|
def list
|
252
252
|
ret = get()
|
253
|
+
return [] if ret.is_a? Hash and ret.has_key? :error
|
253
254
|
# eventhandler.skiplist is a list of whitespace seperated dot-paired values.
|
254
255
|
# fe: service.event service service service.event
|
255
256
|
skiplist = ($cfg['eventhandler.skiplist'] or '').split
|
data/lib/MrMurano/Solution.rb
CHANGED
data/lib/MrMurano/SyncUpDown.rb
CHANGED
@@ -658,7 +658,7 @@ module MrMurano
|
|
658
658
|
|
659
659
|
## Get status of things here verses there
|
660
660
|
#
|
661
|
-
# @param options [Hash, Commander::Command::Options] Options on
|
661
|
+
# @param options [Hash, Commander::Command::Options] Options on operation
|
662
662
|
# @param selected [Array<String>] Filters for _matcher
|
663
663
|
# @return [Hash{Symbol=>Array<Item>}] Items grouped by the action that should be taken
|
664
664
|
def status(options={}, selected=[])
|
@@ -694,7 +694,7 @@ module MrMurano
|
|
694
694
|
mrg = herebox[key].reject{|k,v| k==itemkey}
|
695
695
|
mrg = therebox[key].merge(mrg)
|
696
696
|
if docmp(herebox[key], therebox[key]) then
|
697
|
-
mrg[:diff] = dodiff(mrg) if options[:diff] and mrg[:selected]
|
697
|
+
mrg[:diff] = dodiff(mrg.to_h) if options[:diff] and mrg[:selected]
|
698
698
|
tomod << mrg
|
699
699
|
else
|
700
700
|
unchg << mrg
|
data/lib/MrMurano/commands.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'MrMurano/SubCmdGroupContext'
|
2
|
+
|
3
|
+
command :business do |c|
|
4
|
+
c.syntax = %{murano business}
|
5
|
+
c.summary = %{About Business}
|
6
|
+
c.description = %{Sub-commands for working with Businesses}
|
7
|
+
|
8
|
+
c.action do |args, options|
|
9
|
+
::Commander::UI.enable_paging
|
10
|
+
say MrMurano::SubCmdGroupHelp.new(c).get_help
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# vim: set ai et sw=2 ts=2 :
|
15
|
+
|
@@ -63,7 +63,7 @@ command :init do |c|
|
|
63
63
|
if not options.force and not $cfg['solution.id'].nil? then
|
64
64
|
say "Using Solution ID already set to #{$cfg['solution.id']}"
|
65
65
|
else
|
66
|
-
solz = acc.solutions
|
66
|
+
solz = acc.solutions.select{|s| s[:type] == 'dataApi'}
|
67
67
|
if solz.count == 1 then
|
68
68
|
sol = solz.first
|
69
69
|
say "You only have one solution; using #{sol[:domain]}"
|
@@ -83,10 +83,12 @@ command :init do |c|
|
|
83
83
|
end
|
84
84
|
|
85
85
|
# create doesn't return anything, so we need to go look for it.
|
86
|
-
ret = acc.solutions.select
|
87
|
-
|
86
|
+
ret = acc.solutions.select do |i|
|
87
|
+
i[:type] == 'dataApi' and (i[:name] == solname or i[:domain] =~ /#{solname}\./i)
|
88
|
+
end
|
89
|
+
sid = (ret.first or {})[:apiId]
|
88
90
|
if sid.nil? or sid.empty? then
|
89
|
-
acc.error "Solution didn't find an apiId!!!!
|
91
|
+
acc.error "Solution didn't find an apiId!!!! #{name} -> #{ret}"
|
90
92
|
exit 3
|
91
93
|
end
|
92
94
|
$cfg.set('solution.id', sid, :project)
|
@@ -7,12 +7,16 @@ module MrMurano
|
|
7
7
|
@serviceName = 'postgresql'
|
8
8
|
end
|
9
9
|
|
10
|
-
def query(query)
|
11
|
-
|
10
|
+
def query(query, params=nil)
|
11
|
+
aqr = {:sql=>query}
|
12
|
+
aqr[:parameters] = params unless params.nil?
|
13
|
+
call(:query, :post, aqr)
|
12
14
|
end
|
13
15
|
|
14
|
-
def queries(query)
|
15
|
-
|
16
|
+
def queries(query, params=nil)
|
17
|
+
aqr = {:sql=>query}
|
18
|
+
aqr[:parameters] = params unless params.nil?
|
19
|
+
call(:queries, :post, aqr)
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
@@ -20,18 +24,28 @@ end
|
|
20
24
|
command :postgresql do |c|
|
21
25
|
c.syntax = %{murano postgresql <SQL Commands>}
|
22
26
|
c.summary = %{Query the relational database}
|
27
|
+
c.description = %{Query the relational database
|
23
28
|
|
29
|
+
Queries can include $# escapes that are filled from the --param option.
|
30
|
+
}
|
31
|
+
|
32
|
+
c.option '--param LIST',Array, %{Values to fill $# with}
|
24
33
|
c.option '-f', '--file FILE', %{File of SQL commands}
|
25
34
|
c.option '-o', '--output FILE', %{Download to file instead of STDOUT}
|
26
35
|
|
36
|
+
c.example %{murano postgresql 'select * from bob'}, %{Run a SQL command}
|
37
|
+
c.example %{murano postgresql 'select * from prices' -c outformat=csv -o prices.csv}, %{Download all values in prices to a CSV file.}
|
38
|
+
c.example %{murano postgresql 'INSERT INTO prices (price, item) VALUES ($1,$2)' --param 1.24,Food}, %{Insert using parameters.}
|
39
|
+
c.example %{murano postgresql -f cmds.sql}, %{Run multiple commands from a file}
|
40
|
+
|
27
41
|
c.action do |args,options|
|
28
42
|
pg = MrMurano::Postgresql.new
|
29
43
|
if options.file then
|
30
44
|
sqls = File.read(options.file)
|
31
45
|
|
32
|
-
ret = pg.queries
|
46
|
+
ret = pg.queries(sqls, options.param)
|
33
47
|
else
|
34
|
-
ret = pg.query
|
48
|
+
ret = pg.query(args.join(' '), options.param)
|
35
49
|
end
|
36
50
|
|
37
51
|
unless ret[:error].nil? then
|
@@ -58,21 +72,26 @@ end
|
|
58
72
|
|
59
73
|
command 'postgresql migrate' do |c|
|
60
74
|
c.syntax = %{murano postgresql migrate (up|down) <level>}
|
61
|
-
c.summary = %{Run database migration scripts.
|
62
|
-
|
75
|
+
c.summary = %{Run database migration scripts.}
|
76
|
+
c.description = %{Run database migration scripts.
|
63
77
|
|
64
78
|
The names of the script files must be in the "<level>-<name>-<up|down>.sql"
|
65
|
-
format.
|
79
|
+
format. Each file is a series of Postgres SQL commands.
|
66
80
|
|
67
81
|
The current version of the migrations (last <level> ran) will be stored in an
|
68
|
-
extra table in your database. (
|
82
|
+
extra table in your database. (__murano_cli__.migrate_version)
|
69
83
|
|
70
84
|
}
|
71
85
|
|
72
86
|
c.option '--dir DIR', %{Directory where migrations live}
|
73
87
|
|
88
|
+
c.example %{murano postgresql migrate up}, %{Run migrations up to largest version.}
|
89
|
+
c.example %{murano postgresql migrate up 2}, %{Run migrations up to version 2.}
|
90
|
+
c.example %{murano postgresql migrate down 1}, %{Run migrations down to version 1.}
|
91
|
+
c.example %{murano postgresql migrate down 0}, %{Run migrations down to version 0.}
|
92
|
+
|
74
93
|
c.action do |args,options|
|
75
|
-
options.default :dir => File.join($cfg['location.base'], '
|
94
|
+
options.default :dir => File.join($cfg['location.base'], $cfg['postgresql.migrations_dir'])
|
76
95
|
|
77
96
|
direction = args.shift
|
78
97
|
if direction =~ /down/i then
|
@@ -87,8 +106,9 @@ command 'postgresql migrate' do |c|
|
|
87
106
|
|
88
107
|
# get current version of DB.
|
89
108
|
ret = pg.queries %{
|
90
|
-
CREATE
|
91
|
-
|
109
|
+
CREATE SCHEMA IF NOT EXISTS __murano_cli__;
|
110
|
+
CREATE TABLE IF NOT EXISTS __murano_cli__.migrate_version (version integer);
|
111
|
+
SELECT version FROM __murano_cli__.migrate_version ORDER BY version DESC;
|
92
112
|
}.gsub(/^\s+/,'')
|
93
113
|
unless ret[:error].nil? then
|
94
114
|
pp ret
|
@@ -122,6 +142,7 @@ command 'postgresql migrate' do |c|
|
|
122
142
|
end
|
123
143
|
end
|
124
144
|
|
145
|
+
pg.debug "Migrations before: #{migrations}"
|
125
146
|
# Select migrations between current and desired
|
126
147
|
migrations.select! do |m|
|
127
148
|
mvrs, _ = File.basename(m).split('-')
|
@@ -132,6 +153,7 @@ command 'postgresql migrate' do |c|
|
|
132
153
|
mvrs > current_version and mvrs <= want_version
|
133
154
|
end
|
134
155
|
end
|
156
|
+
pg.debug "Migrations after: #{migrations}"
|
135
157
|
|
136
158
|
# Run migrations.
|
137
159
|
migrations.each do |m|
|
@@ -147,10 +169,10 @@ command 'postgresql migrate' do |c|
|
|
147
169
|
exit 5
|
148
170
|
else
|
149
171
|
if direction == 'down' then
|
150
|
-
pg.queries %{DELETE FROM
|
172
|
+
pg.queries %{DELETE FROM __murano_cli__.migrate_version WHERE version = #{mvrs};
|
151
173
|
COMMIT;}.gsub(/^\s+/,'')
|
152
174
|
else
|
153
|
-
pg.queries %{INSERT INTO
|
175
|
+
pg.queries %{INSERT INTO __murano_cli__.migrate_version values (#{mvrs});
|
154
176
|
COMMIT;}.gsub(/^\s+/,'')
|
155
177
|
end
|
156
178
|
end
|
@@ -23,10 +23,12 @@ command 'solution create' do |c|
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# create doesn't return anything, so we need to go look for it.
|
26
|
-
ret = acc.solutions.select
|
27
|
-
|
26
|
+
ret = acc.solutions.select do |i|
|
27
|
+
i[:type] == 'dataApi' and (i[:name] == name or i[:domain] =~ /#{name}\./i)
|
28
|
+
end
|
29
|
+
sid = (ret.first or {})[:apiId]
|
28
30
|
if sid.nil? or sid.empty? then
|
29
|
-
acc.error "Didn't find an apiId!!!!
|
31
|
+
acc.error "Didn't find an apiId!!!! #{name} -> #{ret} "
|
30
32
|
exit 3
|
31
33
|
end
|
32
34
|
if options.save then
|
@@ -69,15 +69,21 @@ command :status do |c|
|
|
69
69
|
@grouped = {:toadd=>[],:todel=>[],:tomod=>[], :unchg=>[]}
|
70
70
|
def gmerge(ret, type, options)
|
71
71
|
if options.grouped then
|
72
|
-
|
73
|
-
ret[kind].each do |item|
|
74
|
-
item = item.to_h
|
75
|
-
item[:pp_type] = type
|
76
|
-
@grouped[kind] << item
|
77
|
-
end
|
78
|
-
end
|
72
|
+
out = @grouped
|
79
73
|
else
|
80
|
-
|
74
|
+
out = {:toadd=>[],:todel=>[],:tomod=>[], :unchg=>[]}
|
75
|
+
end
|
76
|
+
|
77
|
+
[:toadd, :todel, :tomod, :unchg].each do |kind|
|
78
|
+
ret[kind].each do |item|
|
79
|
+
item = item.to_h
|
80
|
+
item[:pp_type] = type
|
81
|
+
out[kind] << item
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
unless options.grouped then
|
86
|
+
pretty(out, options)
|
81
87
|
end
|
82
88
|
end
|
83
89
|
|
data/lib/MrMurano/version.rb
CHANGED
data/spec/cmd_domain_spec.rb
CHANGED
@@ -22,7 +22,7 @@ RSpec.describe 'murano domain', :cmd, :needs_password do
|
|
22
22
|
|
23
23
|
it "show domain" do
|
24
24
|
out, err, status = Open3.capture3(capcmd('murano', 'domain'))
|
25
|
-
expect(out.chomp).to eq("#{@project_name}.apps.exosite.io")
|
25
|
+
expect(out.chomp).to eq("#{@project_name.downcase}.apps.exosite.io")
|
26
26
|
expect(err).to eq('')
|
27
27
|
expect(status.exitstatus).to eq(0)
|
28
28
|
end
|
data/spec/fixtures/dumped_config
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: MuranoCLI
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Conrad Tadpol Tilstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -246,6 +246,7 @@ executables:
|
|
246
246
|
extensions: []
|
247
247
|
extra_rdoc_files: []
|
248
248
|
files:
|
249
|
+
- .agignore
|
249
250
|
- .gitignore
|
250
251
|
- .rspec
|
251
252
|
- .travis.yml
|
@@ -280,6 +281,7 @@ files:
|
|
280
281
|
- lib/MrMurano/SyncUpDown.rb
|
281
282
|
- lib/MrMurano/commands.rb
|
282
283
|
- lib/MrMurano/commands/assign.rb
|
284
|
+
- lib/MrMurano/commands/business.rb
|
283
285
|
- lib/MrMurano/commands/businessList.rb
|
284
286
|
- lib/MrMurano/commands/completion.rb
|
285
287
|
- lib/MrMurano/commands/config.rb
|