MuranoCLI 3.0.8 → 3.1.0.beta.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.
- checksums.yaml +4 -4
- data/lib/MrMurano/Logs.rb +13 -5
- data/lib/MrMurano/ProjectFile.rb +5 -4
- data/lib/MrMurano/SyncUpDown.rb +1 -47
- data/lib/MrMurano/commands/globals.rb +1 -0
- data/lib/MrMurano/commands/logs.rb +601 -206
- data/lib/MrMurano/commands/solution_picker.rb +11 -11
- data/lib/MrMurano/makePretty.rb +55 -28
- data/lib/MrMurano/version.rb +1 -1
- data/spec/fixtures/websocket/README.rst +110 -0
- metadata +5 -4
@@ -15,8 +15,8 @@ MSG_SOLUTIONS_NONE_FOUND = 'No solutions found' unless defined? MSG_SOLUTIONS_NO
|
|
15
15
|
# *** For some commands: let user restrict to specific solution --type.
|
16
16
|
# ---------------------------------------------------------------------
|
17
17
|
|
18
|
-
def cmd_add_solntype_pickers(
|
19
|
-
# 2017-07-26: HA! The --type option can get masked by aliases.
|
18
|
+
def cmd_add_solntype_pickers(cmd, exclude_all: false)
|
19
|
+
# 2017-07-26 (landonb): HA! The --type option can get masked by aliases.
|
20
20
|
# For instance, if the option is required ("--type TYPE"), then
|
21
21
|
# murano domain --type product
|
22
22
|
# fails, because the "domain product" alias steals the --type argument,
|
@@ -31,7 +31,7 @@ def cmd_add_solntype_pickers(c, exclude_all: false)
|
|
31
31
|
allowed_types += [:all] unless exclude_all
|
32
32
|
allowed_types.map!(&:to_s).sort!
|
33
33
|
default = exclude_all && 'application' || 'all'
|
34
|
-
|
34
|
+
cmd.option(
|
35
35
|
'--type [TYPE]',
|
36
36
|
allowed_types,
|
37
37
|
%(Apply to solution(s) of type [#{allowed_types.join('|')}] (default: #{default}))
|
@@ -194,16 +194,16 @@ end
|
|
194
194
|
# *** For murano init: specify --business, --application, and/or --product.
|
195
195
|
# -------------------------------------------------------------------------
|
196
196
|
|
197
|
-
def cmd_option_application_pickers(
|
198
|
-
|
199
|
-
|
200
|
-
|
197
|
+
def cmd_option_application_pickers(cmd)
|
198
|
+
cmd.option('--application-id ID', String, %(ID of Application to use))
|
199
|
+
cmd.option('--application-name NAME', String, %(Name of Application to use))
|
200
|
+
cmd.option('--application APPLICATION', String, %(Name or ID of Application to use))
|
201
201
|
end
|
202
202
|
|
203
|
-
def cmd_option_product_pickers(
|
204
|
-
|
205
|
-
|
206
|
-
|
203
|
+
def cmd_option_product_pickers(cmd)
|
204
|
+
cmd.option('--product-id ID', String, %(ID of Product to use))
|
205
|
+
cmd.option('--product-name NAME', String, %(Name of Product to use))
|
206
|
+
cmd.option('--product PRODUCT', String, %(Name or ID of Product to use))
|
207
207
|
end
|
208
208
|
|
209
209
|
def any_solution_pickers!(options)
|
data/lib/MrMurano/makePretty.rb
CHANGED
@@ -11,14 +11,17 @@ require 'highline'
|
|
11
11
|
|
12
12
|
module MrMurano
|
13
13
|
module Pretties
|
14
|
-
HighLine::Style.new(name: :on_aliceblue, code: "\e[48;5;231m", rgb: [240, 248, 255])
|
15
14
|
PRETTIES_COLORSCHEME = HighLine::ColorScheme.new do |cs|
|
16
|
-
cs[:subject] = %i[red on_aliceblue]
|
17
|
-
cs[:timestamp] = [:blue]
|
18
15
|
cs[:json] = [:magenta]
|
16
|
+
cs[:record_type] = [:magenta]
|
17
|
+
cs[:subject] = [:cyan]
|
18
|
+
cs[:timestamp] = [:blue]
|
19
|
+
cs[:tracking] = [:yellow]
|
19
20
|
end
|
20
21
|
HighLine.color_scheme = PRETTIES_COLORSCHEME
|
21
22
|
|
23
|
+
TERM_WIDTH, _rows = HighLine::SystemExtensions.terminal_size
|
24
|
+
|
22
25
|
# rubocop:disable Style/MethodName: "Use snake_case for method names."
|
23
26
|
def self.makeJsonPretty(data, options, indent: nil, object_nl: nil)
|
24
27
|
if options.pretty
|
@@ -85,7 +88,14 @@ module MrMurano
|
|
85
88
|
out + log_pretty_assemble_body(line, options)
|
86
89
|
end
|
87
90
|
|
88
|
-
def self.fmt_text_padded(text, style, out, raw, min_width: 0)
|
91
|
+
def self.fmt_text_padded(text, style, out, raw, options, min_width: 0)
|
92
|
+
inter_spaces = (min_width == 0) && 0 || options.one_line && 1 || 3
|
93
|
+
min_width = text.length + inter_spaces unless options.align
|
94
|
+
if !options.one_line && options.align && min_width == 0
|
95
|
+
prefix = TERM_WIDTH - raw.length - text.length
|
96
|
+
out += ' ' * prefix
|
97
|
+
raw += ' ' * prefix
|
98
|
+
end
|
89
99
|
padding = min_width - text.length
|
90
100
|
padding = ' ' * (padding > 0 && padding || 0)
|
91
101
|
out += HighLine.color(text, style) + padding
|
@@ -96,30 +106,31 @@ module MrMurano
|
|
96
106
|
def self.log_pretty_assemble_header(line, options)
|
97
107
|
out = ''
|
98
108
|
raw = ''
|
99
|
-
out, raw = log_pretty_header_add_abbreviated_sev(line, out, raw, options)
|
100
|
-
out, raw = log_pretty_header_add_log_record_type(line, out, raw, options)
|
101
109
|
out, raw = log_pretty_header_add_event_timestamp(line, out, raw, options)
|
102
110
|
out, raw = log_pretty_header_add_murano_tracking(line, out, raw, options)
|
103
|
-
out,
|
111
|
+
out, raw = log_pretty_header_add_log_record_type(line, out, raw, options)
|
112
|
+
out, raw = log_pretty_header_add_abbreviated_sev(line, out, raw, options)
|
113
|
+
out, raw = log_pretty_header_add_a_service_event(line, out, raw, options)
|
114
|
+
out, _raw = log_pretty_header_add_message(line, out, raw, options)
|
104
115
|
out + "\n"
|
105
116
|
end
|
106
117
|
|
107
|
-
def self.log_pretty_header_add_abbreviated_sev(line, out, raw,
|
108
|
-
fmt_abbreviated_severity(line[:severity], out, raw)
|
118
|
+
def self.log_pretty_header_add_abbreviated_sev(line, out, raw, options)
|
119
|
+
fmt_abbreviated_severity(line[:severity], out, raw, options)
|
109
120
|
end
|
110
121
|
|
111
|
-
def self.log_pretty_header_add_loquacious_sev(line, out, raw,
|
112
|
-
fmt_loquacious_severity(line[:severity], out, raw)
|
122
|
+
def self.log_pretty_header_add_loquacious_sev(line, out, raw, options)
|
123
|
+
fmt_loquacious_severity(line[:severity], out, raw, options)
|
113
124
|
end
|
114
125
|
|
115
|
-
def self.fmt_abbreviated_severity(severity, out, raw, min_width: 7)
|
126
|
+
def self.fmt_abbreviated_severity(severity, out, raw, options, min_width: 7)
|
116
127
|
abbrev, _loquac, style = styled_severity(severity)
|
117
|
-
fmt_text_padded(abbrev, style, out, raw, min_width: min_width)
|
128
|
+
fmt_text_padded(abbrev, style, out, raw, options, min_width: min_width)
|
118
129
|
end
|
119
130
|
|
120
|
-
def self.fmt_loquacious_severity(severity, min_width: 11)
|
131
|
+
def self.fmt_loquacious_severity(severity, out, raw, options, min_width: 11)
|
121
132
|
_abbrev, loquac, style = styled_severity(severity)
|
122
|
-
fmt_text_padded(loquac, style, out, raw, min_width: min_width)
|
133
|
+
fmt_text_padded(loquac, style, out, raw, options, min_width: min_width)
|
123
134
|
end
|
124
135
|
|
125
136
|
def self.styled_severity(severity)
|
@@ -145,14 +156,16 @@ module MrMurano
|
|
145
156
|
end
|
146
157
|
end
|
147
158
|
|
148
|
-
def self.log_pretty_header_add_log_record_type(line, out, raw,
|
159
|
+
def self.log_pretty_header_add_log_record_type(line, out, raw, options)
|
149
160
|
log_type = line[:type].to_s.empty? && '--' || line[:type]
|
150
|
-
fmt_text_padded(log_type.upcase, :
|
161
|
+
fmt_text_padded(log_type.upcase, :record_type, out, raw, options, min_width: 10)
|
151
162
|
end
|
152
163
|
|
153
164
|
def self.log_pretty_header_add_event_timestamp(line, out, raw, options)
|
154
165
|
curtime = fmt_log_record_timestamp(line, options)
|
155
|
-
|
166
|
+
inter_spaces = options.one_line && 1 || 3
|
167
|
+
min_width = curtime.length + inter_spaces
|
168
|
+
fmt_text_padded(curtime, :timestamp, out, raw, options, min_width: min_width)
|
156
169
|
end
|
157
170
|
|
158
171
|
def self.fmt_log_record_timestamp(line, options)
|
@@ -164,7 +177,9 @@ module MrMurano
|
|
164
177
|
else
|
165
178
|
curtime = time_secs_epoch.gmtime
|
166
179
|
end
|
167
|
-
|
180
|
+
format = options.sprintf
|
181
|
+
format = '%Y-%m-%d %H:%M:%S' if format.to_s.empty?
|
182
|
+
curtime = curtime.strftime(format)
|
168
183
|
else
|
169
184
|
curtime = line[:timestamp]
|
170
185
|
end
|
@@ -177,23 +192,33 @@ module MrMurano
|
|
177
192
|
def self.log_pretty_header_add_murano_tracking(line, out, raw, options)
|
178
193
|
return [out, raw] unless options.tracking
|
179
194
|
tid = line[:tracking_id].to_s.empty? && '--------' || line[:tracking_id].slice(0, 8)
|
180
|
-
fmt_text_padded(tid, :
|
195
|
+
fmt_text_padded(tid, :tracking, out, raw, options, min_width: 11)
|
181
196
|
end
|
182
197
|
|
183
|
-
def self.log_pretty_header_add_a_service_event(line, out, raw,
|
198
|
+
def self.log_pretty_header_add_a_service_event(line, out, raw, options)
|
199
|
+
pad = options.align && ' ' || ''
|
200
|
+
out += pad
|
201
|
+
raw += pad
|
184
202
|
svc_evt = []
|
185
203
|
svc_evt += [line[:service]] unless line[:service].to_s.empty?
|
186
204
|
svc_evt += [line[:event]] unless line[:event].to_s.empty?
|
187
205
|
svc_evt = "[#{svc_evt.join(' ').upcase}]"
|
188
|
-
out
|
189
|
-
|
190
|
-
|
206
|
+
fmt_text_padded(svc_evt, :subject, out, raw, options, min_width: 0)
|
207
|
+
end
|
208
|
+
|
209
|
+
def self.log_pretty_header_add_message(line, out, raw, options)
|
210
|
+
return [out, raw] unless options.one_line
|
211
|
+
return [out, raw] unless line.key?(:message) && !line[:message].to_s.empty?
|
212
|
+
msg = ' ' + line[:message]
|
213
|
+
[out + msg, raw + msg]
|
191
214
|
end
|
192
215
|
|
193
216
|
def self.log_pretty_assemble_body(line, options)
|
194
217
|
out = ''
|
195
|
-
|
218
|
+
return out if options.one_line
|
219
|
+
@body_prefix = options.indent && ' ' || ''
|
196
220
|
out += log_pretty_assemble_message(line, options)
|
221
|
+
return out if options.message_only
|
197
222
|
out += log_pretty_assemble_data(line, options)
|
198
223
|
out += log_pretty_assemble_remainder(line, options)
|
199
224
|
out + log_pretty_assemble_tracking_id(line, options)
|
@@ -219,7 +244,7 @@ module MrMurano
|
|
219
244
|
|
220
245
|
def self.log_pretty_emphasize_entry(entry, hash, options)
|
221
246
|
return '' unless hash.key?(entry) && !hash[entry].empty?
|
222
|
-
out = @body_prefix + "---------\n"
|
247
|
+
out = @body_prefix + "---------\n" if options.separators
|
223
248
|
out += @body_prefix + "#{entry}: "
|
224
249
|
out += log_pretty_json(hash[entry], options)
|
225
250
|
out + "\n"
|
@@ -232,7 +257,7 @@ module MrMurano
|
|
232
257
|
]
|
233
258
|
data = data.reject { |key, _val| known_keys.include?(key) }
|
234
259
|
return '' if data.empty?
|
235
|
-
out = @body_prefix + "---------\n"
|
260
|
+
out = options.separators && (@body_prefix + "---------\n") || ''
|
236
261
|
out + @body_prefix + 'data: ' + log_pretty_json(data, options) + "\n"
|
237
262
|
end
|
238
263
|
|
@@ -253,13 +278,15 @@ module MrMurano
|
|
253
278
|
end
|
254
279
|
|
255
280
|
def self.log_pretty_assemble_tracking_id(line, options)
|
281
|
+
return '' unless options.tracking
|
256
282
|
log_pretty_emphasize_entry(:tracking_id, line, options)
|
257
283
|
end
|
258
284
|
|
259
285
|
def self.log_pretty_json(hash, options)
|
260
286
|
return '' if hash.empty?
|
287
|
+
prefix = @body_prefix.to_s.empty? && ' ' || @body_prefix
|
261
288
|
makeJsonPretty(
|
262
|
-
hash, options, indent:
|
289
|
+
hash, options, indent: prefix, object_nl: "\n" + @body_prefix
|
263
290
|
)
|
264
291
|
end
|
265
292
|
end
|
data/lib/MrMurano/version.rb
CHANGED
@@ -26,7 +26,7 @@ module MrMurano
|
|
26
26
|
# '3.0.0-beta.2' is changed to '3.0.0.pre.beta.2'
|
27
27
|
# which breaks our build (which expects the version to match herein).
|
28
28
|
# So stick to using the '.pre.X' syntax, which ruby/gems knows.
|
29
|
-
VERSION = '3.0.
|
29
|
+
VERSION = '3.1.0.beta.1'
|
30
30
|
EXE_NAME = File.basename($PROGRAM_NAME)
|
31
31
|
SIGN_UP_URL = 'https://exosite.com/signup/'
|
32
32
|
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
############################
|
2
|
+
Murano CLI WebSocket Servers
|
3
|
+
############################
|
4
|
+
|
5
|
+
========
|
6
|
+
Overview
|
7
|
+
========
|
8
|
+
|
9
|
+
There are 2 WebSocket servers under ``spec/fixtures/websocket/``:
|
10
|
+
|
11
|
+
- ``wss-fake-logs.rb``: Run this for developing. It'll spit out a fake log record every second to any client that connect.
|
12
|
+
|
13
|
+
- ``wss-echo.rb``: The spec tests use this to test the new logs command code. Whatever the server receives on stdin it just echos to any client that's connected.
|
14
|
+
|
15
|
+
=====
|
16
|
+
Usage
|
17
|
+
=====
|
18
|
+
|
19
|
+
From one terminal, start the fake logs server:
|
20
|
+
|
21
|
+
.. code-block:: bash
|
22
|
+
|
23
|
+
cd /path/to/exosite-murcli/spec/fixtures/websocket
|
24
|
+
|
25
|
+
./wss-fake-logs.rb
|
26
|
+
|
27
|
+
From another terminal, you can use any WebSocket client.
|
28
|
+
|
29
|
+
\1. Using Murano CLI.:
|
30
|
+
|
31
|
+
.. code-block:: bash
|
32
|
+
|
33
|
+
murano logs -f -c net.host=127.0.0.1:4180 -c net.protocol=http --tracking --trace
|
34
|
+
|
35
|
+
\2. Using ``esphen/wsta``:
|
36
|
+
|
37
|
+
.. code-block:: bash
|
38
|
+
|
39
|
+
# Locally
|
40
|
+
wsta --ping 10 "ws://127.0.0.1:4180/path/does/not/matter?limit=1000"
|
41
|
+
|
42
|
+
# Against BizAPI.
|
43
|
+
wsta --ping 10 "wss://bizapi-dev.hosted.exosite.io/api/v1/solution/m1ti0dv29pb340000/logs?token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&limit=1000"
|
44
|
+
|
45
|
+
\3. Using ``hashrocket/ws``:
|
46
|
+
|
47
|
+
.. code-block:: bash
|
48
|
+
|
49
|
+
ws "wss://bizapi-dev.hosted.exosite.io/api/v1/solution/m1ti0dv29pb340000/logs?token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&limit=1000"
|
50
|
+
|
51
|
+
-----------------
|
52
|
+
Token Shenanigans
|
53
|
+
-----------------
|
54
|
+
|
55
|
+
To run ``murano logs`` locally, against 127.0.0.1, you'll probably
|
56
|
+
need to disable the token mechanism.
|
57
|
+
|
58
|
+
Add this to ``lib/MrMurano/Account.rb``::
|
59
|
+
|
60
|
+
def token_fetch
|
61
|
+
@token = 'XXX'
|
62
|
+
return
|
63
|
+
|
64
|
+
=========================
|
65
|
+
Non-Murano CLI WS Clients
|
66
|
+
=========================
|
67
|
+
|
68
|
+
---------------
|
69
|
+
``esphen/wsta``
|
70
|
+
---------------
|
71
|
+
|
72
|
+
- ``esphen/wsta`` is a WebSocket CLI client written in Rust.
|
73
|
+
|
74
|
+
As of late 2017, it's 1 year old and appears to be the most sophisticated client.
|
75
|
+
|
76
|
+
https://github.com/esphen/wsta
|
77
|
+
|
78
|
+
To install:
|
79
|
+
|
80
|
+
.. code-block:: bash
|
81
|
+
|
82
|
+
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/esphen/xUbuntu_16.04/ /' > /etc/apt/sources.list.d/wsta.list"
|
83
|
+
wget -nv https://download.opensuse.org/repositories/home:esphen/xUbuntu_16.04/Release.key -O Release.key
|
84
|
+
sudo apt-key add - < Release.key
|
85
|
+
rm Release.key
|
86
|
+
sudo apt-get update
|
87
|
+
sudo apt-get install wsta
|
88
|
+
|
89
|
+
-----------------
|
90
|
+
``hashrocket/ws``
|
91
|
+
-----------------
|
92
|
+
|
93
|
+
- ``hashrocket/ws`` is WebSocket CLI client written in Go.
|
94
|
+
|
95
|
+
As of late 2017, it's 1 year old.
|
96
|
+
|
97
|
+
https://github.com/hashrocket/ws
|
98
|
+
|
99
|
+
To install:
|
100
|
+
|
101
|
+
.. code-block:: bash
|
102
|
+
|
103
|
+
go get -u github.com/hashrocket/ws
|
104
|
+
|
105
|
+
---------------------------------------
|
106
|
+
Browser-based "Simple WebSocket Client"
|
107
|
+
---------------------------------------
|
108
|
+
|
109
|
+
https://chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo?hl=en
|
110
|
+
|
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: 3.0.
|
4
|
+
version: 3.1.0.beta.1
|
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:
|
11
|
+
date: 2018-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: certified
|
@@ -627,6 +627,7 @@ files:
|
|
627
627
|
- spec/fixtures/syncable_content/modules/table_util.lua
|
628
628
|
- spec/fixtures/syncable_content/routes/manyRoutes.lua
|
629
629
|
- spec/fixtures/syncable_content/routes/singleRoute.lua
|
630
|
+
- spec/fixtures/websocket/README.rst
|
630
631
|
- spec/fixtures/websocket/logs_blather.rb
|
631
632
|
- spec/fixtures/websocket/logs_faker.rb
|
632
633
|
- spec/fixtures/websocket/simple_connection.rb
|
@@ -659,9 +660,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
659
660
|
version: '2.0'
|
660
661
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
661
662
|
requirements:
|
662
|
-
- - "
|
663
|
+
- - ">"
|
663
664
|
- !ruby/object:Gem::Version
|
664
|
-
version:
|
665
|
+
version: 1.3.1
|
665
666
|
requirements: []
|
666
667
|
rubyforge_project:
|
667
668
|
rubygems_version: 2.4.5.2
|