MuranoCLI 3.0.0 → 3.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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +50 -27
  3. data/.trustme.vim +12 -8
  4. data/bin/murano +23 -8
  5. data/docs/basic_example.rst +1 -1
  6. data/docs/completions/murano_completion-bash +88 -0
  7. data/lib/MrMurano/Account.rb +3 -3
  8. data/lib/MrMurano/Business.rb +6 -6
  9. data/lib/MrMurano/Config-Migrate.rb +1 -3
  10. data/lib/MrMurano/Config.rb +16 -8
  11. data/lib/MrMurano/Content.rb +56 -45
  12. data/lib/MrMurano/Gateway.rb +62 -21
  13. data/lib/MrMurano/Mock.rb +27 -19
  14. data/lib/MrMurano/Passwords.rb +7 -7
  15. data/lib/MrMurano/ReCommander.rb +171 -28
  16. data/lib/MrMurano/Setting.rb +38 -40
  17. data/lib/MrMurano/Solution-ServiceConfig.rb +2 -1
  18. data/lib/MrMurano/Solution-Services.rb +196 -61
  19. data/lib/MrMurano/Solution-Users.rb +7 -7
  20. data/lib/MrMurano/Solution.rb +22 -8
  21. data/lib/MrMurano/SolutionId.rb +10 -4
  22. data/lib/MrMurano/SubCmdGroupContext.rb +14 -5
  23. data/lib/MrMurano/SyncAllowed.rb +42 -0
  24. data/lib/MrMurano/SyncUpDown.rb +122 -65
  25. data/lib/MrMurano/Webservice-Cors.rb +9 -3
  26. data/lib/MrMurano/Webservice-Endpoint.rb +39 -33
  27. data/lib/MrMurano/Webservice-File.rb +35 -24
  28. data/lib/MrMurano/commands/business.rb +18 -18
  29. data/lib/MrMurano/commands/content.rb +3 -2
  30. data/lib/MrMurano/commands/devices.rb +137 -22
  31. data/lib/MrMurano/commands/globals.rb +8 -2
  32. data/lib/MrMurano/commands/keystore.rb +3 -2
  33. data/lib/MrMurano/commands/link.rb +13 -13
  34. data/lib/MrMurano/commands/login.rb +3 -2
  35. data/lib/MrMurano/commands/mock.rb +4 -3
  36. data/lib/MrMurano/commands/password.rb +4 -2
  37. data/lib/MrMurano/commands/postgresql.rb +5 -3
  38. data/lib/MrMurano/commands/settings.rb +78 -62
  39. data/lib/MrMurano/commands/show.rb +79 -74
  40. data/lib/MrMurano/commands/solution.rb +6 -4
  41. data/lib/MrMurano/commands/solution_picker.rb +5 -4
  42. data/lib/MrMurano/commands/status.rb +15 -4
  43. data/lib/MrMurano/commands/timeseries.rb +3 -2
  44. data/lib/MrMurano/commands/tsdb.rb +3 -2
  45. data/lib/MrMurano/hash.rb +6 -6
  46. data/lib/MrMurano/http.rb +66 -67
  47. data/lib/MrMurano/makePretty.rb +18 -12
  48. data/lib/MrMurano/progress.rb +9 -2
  49. data/lib/MrMurano/verbosing.rb +14 -2
  50. data/lib/MrMurano/version.rb +2 -2
  51. data/spec/GatewayDevice_spec.rb +190 -149
  52. data/spec/Mock_spec.rb +3 -3
  53. data/spec/Solution-ServiceEventHandler_spec.rb +170 -137
  54. data/spec/SyncUpDown_spec.rb +205 -191
  55. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5b5bb74dbabc6127f0fe9e054b41b218b64964d
4
- data.tar.gz: c2e188788986effcfd60c676d3950df224ee6935
3
+ metadata.gz: 9e6cce4e91f5060a854bb7994fe2f5692aa6e9a0
4
+ data.tar.gz: 24c9ea0a2c2f8f2889740e60aa79fedfe4f4e7eb
5
5
  SHA512:
6
- metadata.gz: e309c8cb7301754d9e58b8ad007a1d3bef23167dbf9370002a9d76874539da9028199ac004f80b84afa2ccb61026836bdc3368579d4e0a2f1d411fe20a7ab087
7
- data.tar.gz: 059dcf12cc97380afa732316ba860dc96f2c814cb85fd30533ecf3d31c781d05cfce8a80b7b6324ffa65272721b0fe0fa01c683aa4771c9d690526054923cb06
6
+ metadata.gz: 5ef371516ac2ae1a8b308a08b81b0d64f3458d4bb7f2b74ef36b3c4628eba2ba04aa9a3273cbf7ed43e30a77e384c24bb3c1451724576f30c1f6408095c1fb61
7
+ data.tar.gz: 97c8dfafc76608f74ea8e87ff35f4a5208e74d27766316119c78bb0e4ad5cda0bead9fb23a0155d6b1a725760188aa74d0b258a39da817de5c7a51c694f12baf
@@ -1,4 +1,4 @@
1
- # Last Modified: 2017.08.17 /coding: utf-8
1
+ # Last Modified: 2017.08.22 /coding: utf-8
2
2
  # Copyright © 2016-2017 Exosite LLC.
3
3
  # License: MIT. See LICENSE.txt.
4
4
  # vim:tw=0:ts=2:sw=2:et:ai
@@ -71,6 +71,14 @@ Metrics/PerceivedComplexity:
71
71
  Metrics/LineLength:
72
72
  Enabled: false
73
73
 
74
+ # "Security/YAMLLoad: Prefer using YAML.safe_load over YAML.load."
75
+ # Rubocop suggests using safe_load.
76
+ # https://ruby-doc.org/stdlib-2.1.0/libdoc/psych/rdoc/Psych.html#method-c-load
77
+ # https://ruby-doc.org/stdlib-2.1.0/libdoc/psych/rdoc/Psych.html#method-c-safe_load
78
+ # I think Psych.safe_load was added in Ruby 2.1, so we shouldn't use it. [lb]
79
+ Security/YAMLLoad:
80
+ Enabled: false
81
+
74
82
  # "Use only ascii symbols in comments."
75
83
  Style/AsciiComments:
76
84
  Enabled: false
@@ -84,6 +92,12 @@ Style/Documentation:
84
92
  Style/ConditionalAssignment:
85
93
  EnforcedStyle: assign_inside_condition
86
94
 
95
+ # "Use each_with_object instead of inject."
96
+ Style/EachWithObject:
97
+ Exclude:
98
+ # Methods copy-pasted from a blog.
99
+ - 'lib/MrMurano/hash.rb'
100
+
87
101
  # "Put empty method definitions on a single line."
88
102
  # You can do, e.g.,
89
103
  # def my_method(some_var) end
@@ -102,6 +116,7 @@ Style/FileName:
102
116
  - 'MuranoCLI.gemspec'
103
117
  - 'Rakefile'
104
118
  - 'lib/MrMurano.rb'
119
+ - 'lib/MrMurano/makePretty.rb'
105
120
  - 'lib/MrMurano/Account.rb'
106
121
  - 'lib/MrMurano/Business.rb'
107
122
  - 'lib/MrMurano/Config-Migrate.rb'
@@ -120,6 +135,7 @@ Style/FileName:
120
135
  - 'lib/MrMurano/Solution.rb'
121
136
  - 'lib/MrMurano/SolutionId.rb'
122
137
  - 'lib/MrMurano/SubCmdGroupContext.rb'
138
+ - 'lib/MrMurano/SyncAllowed.rb'
123
139
  - 'lib/MrMurano/SyncRoot.rb'
124
140
  - 'lib/MrMurano/SyncUpDown.rb'
125
141
  - 'lib/MrMurano/Webservice-Cors.rb'
@@ -137,6 +153,23 @@ Style/GlobalVars:
137
153
  Style/NumericPredicate:
138
154
  Enabled: false
139
155
 
156
+ # "Don't use parentheses around the condition of an elsif."
157
+ # This is a matter of taste. Rubocop would have you do, e.g.,
158
+ # if something
159
+ # ...
160
+ # elsif another_thing ||
161
+ # something_else
162
+ # ...
163
+ # But if you don't like lining up the condition like that, you
164
+ # might want to try, e.g.,
165
+ # elsif (
166
+ # another_thing ||
167
+ # something_else
168
+ # )
169
+ # ...
170
+ Style/ParenthesesAroundCondition:
171
+ Enabled: false
172
+
140
173
  # "Provide an exception class and message as arguments to raise."
141
174
  Style/RaiseArgs:
142
175
  EnforcedStyle: compact
@@ -159,6 +192,22 @@ Style/RedundantParentheses:
159
192
  # #EnforcedStyle: percent_r
160
193
  # EnforcedStyle: slashes
161
194
 
195
+ # "Use safe navigation (&.) instead of checking if an object exists before
196
+ # calling the method."
197
+ #
198
+ # - "The Safe Navigation Operator (&.) in Ruby"
199
+ # http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/
200
+ #
201
+ # The safe nav op was only added in Ruby 2.3.0, and we support 2.0.
202
+ Style/SafeNavigation:
203
+ Enabled: false
204
+
205
+ # "Do not use semicolons to terminate expressions."
206
+ Style/Semicolon:
207
+ Exclude:
208
+ # Methods copy-pasted from a blog.
209
+ - 'lib/MrMurano/hash.rb'
210
+
162
211
  # "Avoid comma after the last parameter of a method call."
163
212
  # FIXME/2017-06-30: Is this okay?
164
213
  Style/TrailingCommaInArguments:
@@ -170,16 +219,6 @@ Style/TrailingCommaInLiteral:
170
219
  # still tell you not to use trailing comma in single-line list.
171
220
  EnforcedStyleForMultiline: "consistent_comma"
172
221
 
173
- # "Use safe navigation (&.) instead of checking if an object exists before
174
- # calling the method."
175
- #
176
- # - "The Safe Navigation Operator (&.) in Ruby"
177
- # http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/
178
- #
179
- # The safe nav op was only added in Ruby 2.3.0, and we support 2.0.
180
- Style/SafeNavigation:
181
- Enabled: false
182
-
183
222
  AllCops:
184
223
  Include:
185
224
  - 'bin/murano'
@@ -203,20 +242,4 @@ AllCops:
203
242
  #
204
243
  # 2017-08-16: Ug.
205
244
  - 'lib/MrMurano/optparse.rb'
206
- #
207
- # FIXME/2017-07-25: Finish linting these files, and delete from this list.
208
- # ✗ 2017-07-31: 943 offenses herein these 26 files.
209
- # ✓ 2017-08-16: 420 offenses herein these 15 files.
210
- - 'lib/MrMurano/Content.rb'
211
- - 'lib/MrMurano/Mock.rb'
212
- - 'lib/MrMurano/Setting.rb'
213
- - 'lib/MrMurano/SubCmdGroupContext.rb'
214
- - 'lib/MrMurano/Webservice-Endpoint.rb'
215
- - 'lib/MrMurano/Webservice-File.rb'
216
- - 'lib/MrMurano/hash.rb'
217
- - 'lib/MrMurano/http.rb'
218
- - 'lib/MrMurano/makePretty.rb'
219
- - 'lib/MrMurano/commands/business.rb'
220
- - 'lib/MrMurano/commands/cors.rb'
221
- - 'lib/MrMurano/commands/settings.rb'
222
245
 
@@ -13,12 +13,16 @@
13
13
  " since every time we call autocmd, the command is appended,
14
14
  " and this file gets sourced every switch to a corresponding
15
15
  " project buffer.
16
- augroup trustme
17
- " Remove! all trustme autocommands.
18
- autocmd! trustme
19
- "autocmd BufWrite *.rb silent !touch TOUCH
20
- "autocmd BufWrite <buffer> echom "trustme is hooked!"
21
- " MEH/2017-08-02: This won't hook bin/murano.
22
- autocmd BufWrite <buffer> silent !./.trustme.sh &
23
- augroup END
16
+ "augroup trustme
17
+ " " Remove! all trustme autocommands.
18
+ " autocmd! trustme
19
+ " "autocmd BufWrite *.rb silent !touch TOUCH
20
+ " "autocmd BufWrite <buffer> echom "trustme is hooked!"
21
+ " " MEH/2017-08-02: This won't hook bin/murano.
22
+ "" autocmd BufWrite <buffer> silent !./.trustme.sh &
23
+ " autocmd BufWritePost <buffer> silent !./.trustme.sh &
24
+ "augroup END
25
+
26
+ "echomsg 'Calling trustme.sh'
27
+ silent !./.trustme.sh &
24
28
 
data/bin/murano CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # Last Modified: 2017.08.16 /coding: utf-8
2
+ # Last Modified: 2017.08.23 /coding: utf-8
3
3
  # frozen_string_literal: true
4
4
 
5
5
  # Copyright © 2016-2017 Exosite LLC.
@@ -8,6 +8,7 @@
8
8
 
9
9
  require 'commander/import'
10
10
  require 'dotenv'
11
+ require 'English'
11
12
  require 'highline'
12
13
  require 'pathname'
13
14
  #require 'pp'
@@ -36,13 +37,13 @@ program :description, %(
36
37
  Manage Applications and Products in Exosite's Murano
37
38
  ).strip
38
39
 
39
- # The Commander defaults to paged help.
40
- # The user can disable with --no-page, e.g.,
41
- # alias murano='murano --no-page'
42
- if ARGV.include?('--no-page')
43
- program :help_paging, false
44
- ARGV.delete('--no-page')
45
- end
40
+ # If being piped, e.g.,
41
+ # murano command ... | ...
42
+ # or
43
+ # VAR=$(murano command ...)
44
+ # etc., then do not do progress.
45
+ # TEST/2017-08-23: Does this work on Windows?
46
+ ARGV.push('--no-progress') unless $stdout.tty?
46
47
 
47
48
  default_command :help
48
49
 
@@ -81,3 +82,17 @@ $cfg.validate_cmd
81
82
  $project = MrMurano::ProjectFile.new
82
83
  $project.load
83
84
 
85
+ # The Commander defaults to paged help.
86
+ # The user can disable with --no-page, e.g.,
87
+ # alias murano='murano --no-page'
88
+ # We define this here and not in globals.rb because
89
+ # `murano --help` does not cause globals.rb to be sourced.
90
+ paging = nil
91
+ paging = true if ARGV.include?('--page')
92
+ paging = false if ARGV.include?('--no-page')
93
+ unless paging.nil?
94
+ program :help_paging, paging
95
+ $cfg['tool.no-page'] = !paging
96
+ end
97
+ # else, commander defaults to paging.
98
+
@@ -247,7 +247,7 @@ just grab a random UUID.
247
247
 
248
248
  $ SOME_ID=$(uuidgen)
249
249
 
250
- $ murano device enable ${SOME_ID}
250
+ $ murano device enable ${SOME_ID} --expire 1
251
251
 
252
252
  $ murano device list
253
253
 
@@ -14,6 +14,7 @@ __app_switches=(
14
14
  --no-page
15
15
  --no-plugins
16
16
  --no-progress
17
+ --no-ascii
17
18
  --verbose
18
19
  --help
19
20
  --version
@@ -78,6 +79,7 @@ function _murano () {
78
79
  diff
79
80
  domain
80
81
  find
82
+ gwe
81
83
  help
82
84
  init
83
85
  keystore
@@ -164,6 +166,9 @@ function _murano () {
164
166
  (find)
165
167
  __murano-find "$cmd1" "$cmd2" "${used_switches[@]}"
166
168
  ;;
169
+ (gwe)
170
+ __murano-gwe "$cmd1" "$cmd2" "${used_switches[@]}"
171
+ ;;
167
172
  (help)
168
173
  __murano-help "$cmd1" "$cmd2" "${used_switches[@]}"
169
174
  ;;
@@ -795,6 +800,7 @@ function __murano-content () {
795
800
  case $subcmd1 in
796
801
  (delete)
797
802
  more_switches=(
803
+ {--trace}
798
804
  )
799
805
  ;;
800
806
  (download)
@@ -1091,7 +1097,10 @@ function __murano-device () {
1091
1097
  enable
1092
1098
  httpurl
1093
1099
  list
1100
+ lock
1094
1101
  read
1102
+ revoke
1103
+ unlock
1095
1104
  write
1096
1105
  )
1097
1106
  else
@@ -1118,11 +1127,23 @@ function __murano-device () {
1118
1127
  {--trace}
1119
1128
  )
1120
1129
  ;;
1130
+ (lock)
1131
+ more_switches=(
1132
+ )
1133
+ ;;
1121
1134
  (read)
1122
1135
  more_switches=(
1123
1136
  {--trace}
1124
1137
  )
1125
1138
  ;;
1139
+ (revoke)
1140
+ more_switches=(
1141
+ )
1142
+ ;;
1143
+ (unlock)
1144
+ more_switches=(
1145
+ )
1146
+ ;;
1126
1147
  (write)
1127
1148
  more_switches=(
1128
1149
  )
@@ -1450,6 +1471,72 @@ function __murano-find () {
1450
1471
  COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1451
1472
  }
1452
1473
 
1474
+ # Completion for subcommand: "gwe".
1475
+ function __murano-gwe () {
1476
+ local subcmd1="$1"
1477
+ local subcmd2="$2"
1478
+ #local subcmdn="$3"
1479
+ local used_switches="${@:3}"
1480
+ local last="${COMP_WORDS[COMP_CWORD]}"
1481
+ local len=$(($COMP_CWORD - 1))
1482
+
1483
+ local -a more_switches
1484
+
1485
+ local -a comp_list
1486
+
1487
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1488
+ #>&2 echo "used_switches=$used_switches"
1489
+ #>&2 echo "more_switches=$more_switches"
1490
+
1491
+ # NOTE: Not doing anything special for ${subcmd2}.
1492
+ # Are there sub-sub-commands we shoud list?
1493
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
1494
+ comp_list=(
1495
+ app
1496
+ )
1497
+ else
1498
+ case $subcmd1 in
1499
+ (app)
1500
+ more_switches=(
1501
+ )
1502
+ ;;
1503
+ esac
1504
+ fi
1505
+
1506
+ # Add unused application-wide flags.
1507
+ local idx
1508
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1509
+ local switch=${__app_switches[$idx]}
1510
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1511
+ comp_list+=("$switch")
1512
+ fi
1513
+ done
1514
+ # Add unused subcommand flags.
1515
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1516
+ local switch=${more_switches[$idx]}
1517
+ comp_list+=("$switch")
1518
+ done
1519
+
1520
+ # If there are only --flags, <TAB> will put the common prefix,
1521
+ # "--", but maybe the user doesn't want to add a flag after all.
1522
+ if [[ -z ${last} ]]; then
1523
+ local flags_only=true
1524
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1525
+ local switch=${comp_list[$idx]}
1526
+ if [[ ${switch} != --* ]]; then
1527
+ flags_only=false
1528
+ break
1529
+ fi
1530
+ done
1531
+ if ${flags_only}; then
1532
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1533
+ comp_list+=("  ")
1534
+ fi
1535
+ fi
1536
+
1537
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1538
+ }
1539
+
1453
1540
  # Completion for subcommand: "help".
1454
1541
  function __murano-help () {
1455
1542
  local subcmd1="$1"
@@ -2274,6 +2361,7 @@ function __murano-password () {
2274
2361
  ;;
2275
2362
  (delete)
2276
2363
  more_switches=(
2364
+ {--trace}
2277
2365
  )
2278
2366
  ;;
2279
2367
  (list)
@@ -1,4 +1,4 @@
1
- # Last Modified: 2017.08.17 /coding: utf-8
1
+ # Last Modified: 2017.08.22 /coding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # Copyright © 2016-2017 Exosite LLC.
@@ -129,7 +129,7 @@ Or set your password with `murano password set <username>`.
129
129
  error 'Check to see if username and password are correct.'
130
130
  unless ENV['MURANO_PASSWORD'].to_s.empty?
131
131
  pwd_path = $cfg.file_at('passwords', :user)
132
- warning "BEWARE: The password used was from MURANO_PASSWORD, not from #{pwd_path}"
132
+ warning "NOTE: MURANO_PASSWORD specifies the password; it was not read from #{pwd_path}"
133
133
  end
134
134
  @token = nil
135
135
  end
@@ -158,7 +158,7 @@ Or set your password with `murano password set <username>`.
158
158
  (
159
159
  match_bid.include?(biz[:bizid]) ||
160
160
  match_name.include?(biz[:name]) ||
161
- match_termy.any? do |term|
161
+ match_fuzzy.any? do |term|
162
162
  biz[:name] =~ /#{Regexp.escape(term)}/i || biz[:bizid] =~ /#{Regexp.escape(term)}/i
163
163
  end
164
164
  )
@@ -1,4 +1,4 @@
1
- # Last Modified: 2017.08.16 /coding: utf-8
1
+ # Last Modified: 2017.08.23 /coding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # Copyright © 2016-2017 Exosite LLC.
@@ -119,7 +119,7 @@ or set it interactively using \`#{MrMurano::EXE_NAME} init\`
119
119
  end
120
120
 
121
121
  def pretty_name_and_id
122
- "‘#{Rainbow(name).underline} <#{bid}>"
122
+ "#{fancy_ticks(Rainbow(name).underline)} <#{bid}>"
123
123
  end
124
124
 
125
125
  # ---------------------------------------------------------------------
@@ -247,7 +247,7 @@ or set it interactively using \`#{MrMurano::EXE_NAME} init\`
247
247
  elsif type == :product
248
248
  sol = MrMurano::Product.new(sid)
249
249
  else
250
- #raise "Unexpected path: Unrecognized type ‘#{type}"
250
+ #raise "Unexpected path: Unrecognized type #{fancy_ticks(type)}"
251
251
  sol = MrMurano::Solution.new(sid)
252
252
  end
253
253
  sol.biz = self
@@ -275,7 +275,7 @@ or set it interactively using \`#{MrMurano::EXE_NAME} init\`
275
275
  workit_response(response)
276
276
  else
277
277
  MrMurano::Verbose.error(
278
- "Unable to create #{sol.type_name}: ‘#{sol.name}"
278
+ "Unable to create #{sol.type_name}: #{fancy_ticks(sol.name)}"
279
279
  )
280
280
  ok = false
281
281
  if response.is_a?(Net::HTTPConflict)
@@ -329,12 +329,12 @@ or set it interactively using \`#{MrMurano::EXE_NAME} init\`
329
329
  # if ret.count > 1
330
330
  # warning("Found more than 1 matching solution: #{ret}")
331
331
  # elsif ret.count.zero?
332
- # error("Unable to verify solution created for ‘#{sol.name}’: #{ret}")
332
+ # error("Unable to verify solution created for #{fancy_ticks(sol.name)}: #{ret}")
333
333
  # exit 3
334
334
  # end
335
335
  # sol.meta = ret.first
336
336
  # if sol.sid.to_s.empty? then
337
- # error("New solution created for ‘#{sol.name} missing ID?: #{ret}")
337
+ # error("New solution created for #{fancy_ticks(sol.name)} missing ID?: #{ret}")
338
338
  # exit 3
339
339
  # end
340
340
  # sol.sid = sid