MuranoCLI 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.agignore +1 -0
- data/.rubocop.yml +67 -5
- data/Gemfile +6 -3
- data/MuranoCLI.gemspec +14 -10
- data/README.markdown +299 -126
- data/Rakefile +6 -1
- data/bin/murano +2 -2
- data/docs/completions/murano_completion-bash +93 -0
- data/lib/MrMurano.rb +19 -2
- data/lib/MrMurano/Business.rb +22 -19
- data/lib/MrMurano/Config.rb +19 -9
- data/lib/MrMurano/Content.rb +4 -4
- data/lib/MrMurano/Exchange-Element.rb +99 -0
- data/lib/MrMurano/Exchange.rb +137 -0
- data/lib/MrMurano/Gateway.rb +9 -9
- data/lib/MrMurano/Keystore.rb +4 -2
- data/lib/MrMurano/ReCommander.rb +3 -5
- data/lib/MrMurano/Solution-ServiceConfig.rb +12 -12
- data/lib/MrMurano/Solution-Services.rb +15 -14
- data/lib/MrMurano/Solution-Users.rb +2 -2
- data/lib/MrMurano/Solution.rb +43 -49
- data/lib/MrMurano/SolutionId.rb +28 -28
- data/lib/MrMurano/SyncUpDown.rb +32 -22
- data/lib/MrMurano/Webservice-Endpoint.rb +2 -1
- data/lib/MrMurano/Webservice.rb +5 -5
- data/lib/MrMurano/commands.rb +2 -1
- data/lib/MrMurano/commands/business.rb +21 -19
- data/lib/MrMurano/commands/domain.rb +16 -2
- data/lib/MrMurano/commands/exchange.rb +272 -0
- data/lib/MrMurano/commands/globals.rb +17 -1
- data/lib/MrMurano/commands/init.rb +3 -3
- data/lib/MrMurano/commands/link.rb +16 -16
- data/lib/MrMurano/commands/postgresql.rb +2 -2
- data/lib/MrMurano/commands/show.rb +13 -7
- data/lib/MrMurano/commands/solution.rb +23 -17
- data/lib/MrMurano/commands/solution_picker.rb +49 -44
- data/lib/MrMurano/commands/sync.rb +2 -1
- data/lib/MrMurano/commands/timeseries.rb +2 -2
- data/lib/MrMurano/commands/tsdb.rb +2 -2
- data/lib/MrMurano/hash.rb +19 -7
- data/lib/MrMurano/http.rb +12 -2
- data/lib/MrMurano/orderedhash.rb +200 -0
- data/lib/MrMurano/spec_commander.rb +98 -0
- data/lib/MrMurano/verbosing.rb +2 -2
- data/lib/MrMurano/version.rb +2 -2
- data/spec/Business_spec.rb +8 -6
- data/spec/Solution-ServiceConfig_spec.rb +1 -1
- data/spec/SyncUpDown_spec.rb +6 -6
- data/spec/_workspace.rb +9 -4
- data/spec/cmd_business_spec.rb +8 -2
- data/spec/cmd_common.rb +266 -25
- data/spec/cmd_exchange_spec.rb +118 -0
- data/spec/cmd_help_spec.rb +54 -13
- data/spec/cmd_init_spec.rb +1 -12
- data/spec/cmd_link_spec.rb +94 -72
- data/spec/spec_helper.rb +11 -16
- metadata +23 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ea22792f25e5418a7687bbffaad2bf0b14f2c28
|
4
|
+
data.tar.gz: cbb94dd03d104a310c3f34c85381f1ce2dd455ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 728ee381c09f8e361d368a2971f8a031e17900186f114ddda941085eafa5ed7f921be17d57347a1051eab0348c0a9e8965858bcf1e8aefee2d8796c6b988f103
|
7
|
+
data.tar.gz: c81a425d2122475db3ecccee78389df533ed4f0dd050d086cea6418e65361c2b804f363d3143e6f074176916cbd78b66bcbc99c1fe6a85e7a6f494d47aef5d99
|
data/.agignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Last Modified: 2017.08.
|
1
|
+
# Last Modified: 2017.08.31 /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
|
@@ -28,6 +28,8 @@ Layout/TrailingBlankLines:
|
|
28
28
|
Lint/ScriptPermission:
|
29
29
|
Exclude:
|
30
30
|
- 'bin/murano'
|
31
|
+
# Also the rspec shim-link:
|
32
|
+
- 'lib/MrMurano/spec_commander.rb'
|
31
33
|
|
32
34
|
# "Assignment Branch Condition size for XXX is too high."
|
33
35
|
# http://wiki.c2.com/?AbcMetric
|
@@ -122,6 +124,8 @@ Style/FileName:
|
|
122
124
|
- 'lib/MrMurano/Config-Migrate.rb'
|
123
125
|
- 'lib/MrMurano/Config.rb'
|
124
126
|
- 'lib/MrMurano/Content.rb'
|
127
|
+
- 'lib/MrMurano/Exchange.rb'
|
128
|
+
- 'lib/MrMurano/Exchange-Element.rb'
|
125
129
|
- 'lib/MrMurano/Gateway.rb'
|
126
130
|
- 'lib/MrMurano/Keystore.rb'
|
127
131
|
- 'lib/MrMurano/Mock.rb'
|
@@ -232,14 +236,72 @@ AllCops:
|
|
232
236
|
# HINT: You can use regexp in this list.
|
233
237
|
#- !ruby/regexp /old_and_unused\.rb$/
|
234
238
|
#
|
235
|
-
# 2017-07-25: It's probably not worth our time to lint the spec tests.
|
236
|
-
# 2017-07-31: 7735 offenses in the Spec tests -- not worth it to fix!!
|
237
|
-
- 'spec/**/*'
|
238
|
-
#
|
239
239
|
# Not sure if the templates are included by default or not, but ignore.
|
240
240
|
- 'lib/MrMurano/commands/completion-bash.erb'
|
241
241
|
- 'lib/MrMurano/commands/completion-zsh.erb'
|
242
242
|
#
|
243
243
|
# 2017-08-16: Ug.
|
244
244
|
- 'lib/MrMurano/optparse.rb'
|
245
|
+
#
|
246
|
+
# 2017-08-29: A hack for rspec.
|
247
|
+
#- 'lib/Murano/spec_commander.rb'
|
248
|
+
#
|
249
|
+
# 2017-08-30: Ug. Loading orderedhash spits out warning gobbled by rspec fails test.
|
250
|
+
- 'lib/MrMurano/orderedhash.rb'
|
251
|
+
#
|
252
|
+
# The spec_helper is a generated file; don't care.
|
253
|
+
- 'spec/spec_helper.rb'
|
254
|
+
#
|
255
|
+
# 2017-07-25: It's probably not worth our time to lint the spec tests.
|
256
|
+
# 2017-07-31: 7735 offenses in the Spec tests -- not worth it to fix!!
|
257
|
+
#- 'spec/**/*'
|
258
|
+
- 'spec/Account-Passwords_spec.rb'
|
259
|
+
- 'spec/Account_spec.rb'
|
260
|
+
- 'spec/Business_spec.rb'
|
261
|
+
- 'spec/ConfigFile_spec.rb'
|
262
|
+
- 'spec/ConfigMigrate_spec.rb'
|
263
|
+
- 'spec/Config_spec.rb'
|
264
|
+
- 'spec/Content_spec.rb'
|
265
|
+
- 'spec/GatewayBase_spec.rb'
|
266
|
+
- 'spec/GatewayDevice_spec.rb'
|
267
|
+
- 'spec/GatewayResource_spec.rb'
|
268
|
+
- 'spec/GatewaySettings_spec.rb'
|
269
|
+
- 'spec/Http_spec.rb'
|
270
|
+
- 'spec/MakePretties_spec.rb'
|
271
|
+
- 'spec/Mock_spec.rb'
|
272
|
+
- 'spec/ProjectFile_spec.rb'
|
273
|
+
- 'spec/Setting_spec.rb'
|
274
|
+
- 'spec/Solution-ServiceConfig_spec.rb'
|
275
|
+
- 'spec/Solution-ServiceEventHandler_spec.rb'
|
276
|
+
- 'spec/Solution-ServiceModules_spec.rb'
|
277
|
+
- 'spec/Solution-UsersRoles_spec.rb'
|
278
|
+
- 'spec/Solution_spec.rb'
|
279
|
+
- 'spec/SyncRoot_spec.rb'
|
280
|
+
- 'spec/SyncUpDown_spec.rb'
|
281
|
+
- 'spec/Verbosing_spec.rb'
|
282
|
+
- 'spec/Webservice-Cors_spec.rb'
|
283
|
+
- 'spec/Webservice-Endpoint_spec.rb'
|
284
|
+
- 'spec/Webservice-File_spec.rb'
|
285
|
+
- 'spec/Webservice-Setting_spec.rb'
|
286
|
+
#- 'spec/_workspace.rb'
|
287
|
+
- 'spec/cmd_business_spec.rb'
|
288
|
+
#- 'spec/cmd_common.rb'
|
289
|
+
- 'spec/cmd_config_spec.rb'
|
290
|
+
- 'spec/cmd_content_spec.rb'
|
291
|
+
- 'spec/cmd_cors_spec.rb'
|
292
|
+
- 'spec/cmd_device_spec.rb'
|
293
|
+
- 'spec/cmd_domain_spec.rb'
|
294
|
+
#- 'spec/cmd_exchange_spec.rb'
|
295
|
+
#- 'spec/cmd_help_spec.rb'
|
296
|
+
- 'spec/cmd_init_spec.rb'
|
297
|
+
- 'spec/cmd_keystore_spec.rb'
|
298
|
+
- 'spec/cmd_link_spec.rb'
|
299
|
+
- 'spec/cmd_password_spec.rb'
|
300
|
+
- 'spec/cmd_setting_application_spec.rb'
|
301
|
+
- 'spec/cmd_setting_product_spec.rb'
|
302
|
+
- 'spec/cmd_status_spec.rb'
|
303
|
+
- 'spec/cmd_syncdown_spec.rb'
|
304
|
+
- 'spec/cmd_syncup_spec.rb'
|
305
|
+
- 'spec/cmd_usage_spec.rb'
|
306
|
+
#- 'spec/cmd_version_spec.rb'
|
245
307
|
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Last Modified: 2017.08.
|
1
|
+
# Last Modified: 2017.08.30 /coding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
# Copyright © 2016-2017 Exosite LLC.
|
@@ -21,10 +21,13 @@ gem 'json', '~> 2.1.0'
|
|
21
21
|
gem 'json-schema', '~> 2.7.0'
|
22
22
|
gem 'mime-types', '~> 3.1'
|
23
23
|
gem 'mime-types-data', '~> 3.2016.0521'
|
24
|
-
gem 'orderedhash', '~> 0.0.6'
|
24
|
+
#gem 'orderedhash', '~> 0.0.6'
|
25
25
|
gem 'paint', '~> 2.0.0'
|
26
|
+
# 2017-08-04: public_suffix 3.0.0 is for Ruby >= 2.1.
|
27
|
+
# It's included by json, so make sure it's the old one.
|
28
|
+
gem 'public_suffix', '~> 2.0.5'
|
26
29
|
gem 'rainbow', '~> 2.2.2'
|
27
|
-
gem 'terminal-table', '~> 1.
|
30
|
+
gem 'terminal-table', '~> 1.8.0'
|
28
31
|
gem 'vine', '~> 0.4'
|
29
32
|
gem 'whirly', '~> 0.2.4'
|
30
33
|
|
data/MuranoCLI.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Last Modified: 2017.08.
|
1
|
+
# Last Modified: 2017.08.30 /coding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
# Copyright © 2016-2017 Exosite LLC.
|
@@ -16,16 +16,17 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.license = 'MIT'
|
17
17
|
s.homepage = 'https://github.com/exosite/MuranoCLI'
|
18
18
|
s.summary = 'Do more from the command line with Murano'
|
19
|
-
s.description = %(
|
19
|
+
s.description = %(
|
20
|
+
Do more from the command line with Murano.
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
Push and pull data from Murano.
|
23
|
+
Get status on what things have changed.
|
24
|
+
See a diff of the changes before you push.
|
24
25
|
|
25
|
-
|
26
|
+
And so much more.
|
26
27
|
|
27
|
-
|
28
|
-
)
|
28
|
+
(This gem was formerly known as MrMurano.)
|
29
|
+
).strip
|
29
30
|
s.required_ruby_version = '~> 2.0'
|
30
31
|
|
31
32
|
# FIXME: 2017-05-25: Remove this message eventually.
|
@@ -61,10 +62,13 @@ explicitly specifying the version. For instance,
|
|
61
62
|
s.add_runtime_dependency('json-schema', '~> 2.7.0')
|
62
63
|
s.add_runtime_dependency('mime-types', '~> 3.1')
|
63
64
|
s.add_runtime_dependency('mime-types-data', '~> 3.2016.0521')
|
64
|
-
s.add_runtime_dependency('orderedhash', '~> 0.0.6')
|
65
|
+
#s.add_runtime_dependency('orderedhash', '~> 0.0.6')
|
65
66
|
s.add_runtime_dependency('paint', '~> 2.0.0')
|
67
|
+
# 2017-08-04: public_suffix 3.0.0 is for Ruby >= 2.1.
|
68
|
+
# It's included by json, so make sure it's the old one.
|
69
|
+
s.add_runtime_dependency('public_suffix', '~> 2.0.5')
|
66
70
|
s.add_runtime_dependency('rainbow', '~> 2.2.2')
|
67
|
-
s.add_runtime_dependency('terminal-table', '~> 1.
|
71
|
+
s.add_runtime_dependency('terminal-table', '~> 1.8.0')
|
68
72
|
s.add_runtime_dependency('vine', '~> 0.4')
|
69
73
|
s.add_runtime_dependency('whirly', '~> 0.2.4')
|
70
74
|
|
data/README.markdown
CHANGED
@@ -7,163 +7,308 @@ Version](https://badge.fury.io/rb/MuranoCLI.svg)](https://badge.fury.io/rb/Muran
|
|
7
7
|
|
8
8
|
Do more from the command line with [Murano](https://exosite.com/platform/).
|
9
9
|
|
10
|
-
MuranoCLI
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
MuranoCLI interacts with Murano and makes different tasks easier.
|
11
|
+
|
12
|
+
MuranoCLI makes it easy to deploy code to a project, import
|
13
|
+
product definitions, set up endpoints and APIs, and more.
|
14
|
+
|
15
|
+
MuranoCLI works around the idea of syncing, much like [`rsync`](https://rsync.samba.org/).
|
16
|
+
Your project files are synced up (or down) from Murano.
|
17
|
+
|
18
|
+
## Contents
|
19
|
+
|
20
|
+
* [Contents](#contents)
|
21
|
+
* [Usage](#usage)
|
22
|
+
* [Start a new project easily with init](#start-a-new-project-easily-with-init)
|
23
|
+
* [Start a new project manually, step-by-step](#start-a-new-project-manually-step-by-step)
|
24
|
+
* [Install](#install)
|
25
|
+
* [Gem Install (Linux and macOS)](#gem-install-linux-and-macos)
|
26
|
+
* [Working With Different Versions of MuranoCLI](#working-with-different-versions-of-muranocli)
|
27
|
+
* [Windows Install](#windows-install)
|
28
|
+
* [Features](#features)
|
29
|
+
* [Logs](#logs)
|
30
|
+
* [CORS](#cors)
|
31
|
+
* [Writing Routes (a.k.a. Endpoints)](#writing-routes-aka-endpoints)
|
32
|
+
* [Writing Service Event Handlers](#writing-service-event-handlers)
|
33
|
+
* [MURANO_CONFIGFILE Environment Variable and Dotenv](#murano_configfile-environment-variable-and-dotenv)
|
34
|
+
* [Direct Service Access](#direct-service-access)
|
35
|
+
* [Output Format](#output-format)
|
36
|
+
* [Product Content Area](#product-content-area)
|
37
|
+
* [Developing](#developing)
|
38
|
+
* [Testing](#testing)
|
17
39
|
|
18
40
|
## Usage
|
19
41
|
|
42
|
+
### Start a new project easily with `init`
|
43
|
+
|
20
44
|
```
|
21
45
|
mkdir myproject
|
22
46
|
cd myproject
|
23
47
|
murano init
|
24
48
|
```
|
25
49
|
|
26
|
-
|
50
|
+
If you want to add information about your project, edit `myproject.murano`.
|
51
|
+
You can add a description, the list of authors, a version number, and more.
|
52
|
+
|
53
|
+
If you are connecting to an existing project
|
54
|
+
created with the [web interface](https://www.exosite.io/business/),
|
55
|
+
you may need to run `murano link set` to connect the product and the application.
|
56
|
+
But if you create a new product and application using MuranoCLI, they will
|
57
|
+
automatically be connected.
|
58
|
+
|
59
|
+
If you are connecting to an existing project, you may want to run
|
60
|
+
`murano syncdown` to pull down your project files from Murano.
|
61
|
+
|
62
|
+
Now do stuff, like add and edit files.
|
63
|
+
|
64
|
+
To see what files have changed, run `murano status`.
|
65
|
+
|
66
|
+
To see exactly what changed, try `murano diff`.
|
67
|
+
|
68
|
+
When you are ready to deploy, run `murano syncup`.
|
69
|
+
|
70
|
+
### Start a new project manually, step-by-step
|
71
|
+
|
72
|
+
If you would like to setup a project without using `murano init`,
|
73
|
+
follow these steps.
|
74
|
+
|
75
|
+
- Find your business ID. Run the command
|
76
|
+
|
77
|
+
`murano business list`
|
78
|
+
|
79
|
+
and copy its ID from the list.
|
80
|
+
|
81
|
+
- If this is the first time you've run `murano`, you will
|
82
|
+
need to enter your Murano username and password.
|
83
|
+
|
84
|
+
(To sign up for a free account, visit [exosite.com](https://exosite.com/signup/).)
|
85
|
+
|
86
|
+
- If you need to change change accounts, try
|
87
|
+
|
88
|
+
`murano logout`
|
89
|
+
|
90
|
+
`murano login`.
|
91
|
+
|
92
|
+
- To manually change you username and password, run
|
93
|
+
|
94
|
+
`murano config user.name <USERNAME>`
|
95
|
+
|
96
|
+
`murano password set <USERNAME>`.
|
97
|
+
|
98
|
+
- Add the copied Business ID to your project config.
|
99
|
+
|
100
|
+
`murano config business.id <BUSINESS-ID>`
|
27
101
|
|
28
|
-
|
29
|
-
the product and solution.
|
102
|
+
- Create a new Application and save its ID to the project config.
|
30
103
|
|
31
|
-
|
32
|
-
running `murano init`.
|
104
|
+
`murano application create myawesomeapplication --save`
|
33
105
|
|
34
|
-
|
35
|
-
Then deploy with `murano syncup`
|
106
|
+
- Alternatively, choose an existing Application.
|
36
107
|
|
37
|
-
|
38
|
-
There are a few steps and pieces to getting a solution with a product up and
|
39
|
-
running in Murano. Here is the list.
|
108
|
+
`murano config application.id <APPLICATION-ID>`
|
40
109
|
|
41
|
-
-
|
42
|
-
If this is the first time you've run `murano` it will ask for your Murano username
|
43
|
-
and password.
|
44
|
-
- Set it: `murano config business.id ZZZZZZZZZ`
|
45
|
-
- Create a product: `murano product create myawesomeproduct --save`
|
46
|
-
- Add resource aliases to specs/resources.yaml
|
47
|
-
- Sync the product definition up: `murano syncup -V --specs`
|
48
|
-
- Create a solution: `murano solution create myawesomesolution --save`
|
49
|
-
- Sync solution code up: `murano syncup -V`
|
50
|
-
- Assign the product to the solution: `murano assign set`
|
110
|
+
- Create a new Product and save its ID to the project config.
|
51
111
|
|
52
|
-
|
53
|
-
|
112
|
+
`murano product create myawesomeproduct --save`
|
113
|
+
|
114
|
+
- Alternatively, choose an existing Product.
|
115
|
+
|
116
|
+
`murano config product.id <PRODUCT-ID>`
|
117
|
+
|
118
|
+
- Link the Product to the Application.
|
119
|
+
|
120
|
+
`murano link set`
|
121
|
+
|
122
|
+
- Build your project.
|
123
|
+
|
124
|
+
- Edit and create event handlers under `services/`.
|
125
|
+
|
126
|
+
- Create API endpoints under `routes/`.
|
127
|
+
|
128
|
+
- Add Lua modules under `modules/`.
|
129
|
+
|
130
|
+
- Add static files under `files/`.
|
131
|
+
|
132
|
+
- Add resource aliases to the file, `specs/resources.yaml`.
|
133
|
+
|
134
|
+
- See what changed.
|
135
|
+
|
136
|
+
`murano status`
|
137
|
+
|
138
|
+
or
|
139
|
+
|
140
|
+
`murano diff`
|
141
|
+
|
142
|
+
- Deploy your project. Sync up resources, code and files.
|
143
|
+
|
144
|
+
`murano syncup`
|
54
145
|
|
55
146
|
## Install
|
56
147
|
|
57
|
-
### Gem Install (Linux and
|
148
|
+
### Gem Install (Linux and macOS)
|
149
|
+
|
150
|
+
The easiest way to install MuranoCLI is using the Gem installer.
|
58
151
|
|
59
|
-
When upgrading from a 1.\* version to a 2.0, you should uninstall the old versions
|
60
|
-
first.
|
61
152
|
```sh
|
62
|
-
|
153
|
+
gem install MuranoCLI
|
63
154
|
```
|
64
155
|
|
65
|
-
|
156
|
+
- If you are upgrading from a `1.*` version, uninstall the old versions first.
|
66
157
|
|
67
158
|
```sh
|
68
|
-
|
159
|
+
gem uninstall MuranoCLI MrMurano
|
69
160
|
```
|
70
|
-
|
161
|
+
|
162
|
+
- If you would like to install a specific version, such as the older,
|
163
|
+
pre-Murano CLI tool, you can specify the version to install.
|
164
|
+
|
165
|
+
```sh
|
166
|
+
gem install MuranoCLI -v 2.2.4
|
167
|
+
```
|
168
|
+
|
169
|
+
- To update to the latest gem (rather than installing a new gem side by
|
170
|
+
side with an older version of the same gem), update it.
|
171
|
+
|
71
172
|
```sh
|
72
|
-
|
173
|
+
gem update MuranoCLI
|
73
174
|
```
|
74
175
|
|
75
|
-
You will likely need to be root for the above commands.
|
76
|
-
install as root, you can install gems in the user directory.
|
176
|
+
You will likely need to be root for the above commands. If you would rather
|
177
|
+
not install as root, you can install gems in the user directory.
|
77
178
|
|
78
179
|
```sh
|
79
|
-
|
180
|
+
gem install MuranoCLI --user-install
|
80
181
|
```
|
81
182
|
|
82
|
-
Your `PATH` may need to be updated to find the installed `murano` command.
|
83
|
-
[Ruby Gem FAQ](http://guides.rubygems.org/faqs/#user-install).
|
84
|
-
|
183
|
+
Your `PATH` may need to be updated to find the installed `murano` command.
|
184
|
+
See the [Ruby Gem FAQ](http://guides.rubygems.org/faqs/#user-install).
|
185
|
+
|
186
|
+
- In short, you need to add the output of
|
187
|
+
`ruby -rubygems -e 'puts Gem.user_dir'` to your `PATH`.
|
188
|
+
|
189
|
+
E.g., you may want to add this to your `~/.bashrc` file:
|
190
|
+
|
191
|
+
`export PATH=$PATH:$(ruby -rubygems -e 'puts Gem.user_dir')`
|
192
|
+
|
193
|
+
#### Working With Different Versions of MuranoCLI
|
194
|
+
|
195
|
+
The `murano` command line tool is a Ruby gem and, as such, you can install
|
196
|
+
different versions of MuranoCLI and choose which one to execute.
|
197
|
+
|
198
|
+
The following example shows how you can reference a specific version of the
|
199
|
+
`murano` gem:
|
200
|
+
|
201
|
+
```sh
|
202
|
+
$ gem list MuranoCLI --local
|
203
|
+
|
204
|
+
*** LOCAL GEMS ***
|
205
|
+
|
206
|
+
MuranoCLI (3.0.1, 2.2.4)
|
207
|
+
|
208
|
+
$ murano --version
|
209
|
+
murano 3.0.1
|
210
|
+
|
211
|
+
$ murano _2.2.4_ --version
|
212
|
+
murano 2.2.4
|
213
|
+
```
|
214
|
+
|
215
|
+
Note: Not all OSes support multiple versions and will only execute the
|
216
|
+
latest Gem installed. In this case, you will need to uninstall newer
|
217
|
+
versions of MuranoCLI in order to use older versions.
|
85
218
|
|
86
219
|
### Windows Install
|
87
220
|
|
88
|
-
The MuranoCLI gem will install on Windows.
|
89
|
-
|
221
|
+
The MuranoCLI gem will install on Windows.
|
222
|
+
|
223
|
+
There is also a single Windows binary Setup installer available in
|
224
|
+
[releases](https://github.com/exosite/MuranoCLI/releases).
|
90
225
|
|
91
226
|
If you do not already use Ruby on Windows, then you should use the binary
|
92
227
|
installer.
|
93
228
|
|
94
|
-
When upgrading, it is best to run the uninstaller for the old version
|
95
|
-
installing the new version.
|
96
|
-
|
229
|
+
When upgrading, it is best to run the uninstaller for the old version
|
230
|
+
before installing the new version.
|
97
231
|
|
98
232
|
## Features
|
99
233
|
|
100
|
-
### Project File
|
101
|
-
|
102
234
|
### Logs
|
103
235
|
|
104
|
-
You can monitor the log messages from your
|
105
|
-
|
236
|
+
You can monitor the log messages from your Application by running
|
237
|
+
`murano logs application --follow`.
|
238
|
+
|
239
|
+
Or quickly get the last few logs with simply `murano logs application`.
|
106
240
|
|
107
|
-
MuranoCLI does a few things to make
|
108
|
-
- Adds color to easily see where each log message starts.
|
109
|
-
- Reformats the timestamps to be in local time.
|
110
|
-
- Finds JSON blobs and pretty prints them.
|
241
|
+
MuranoCLI does a few things to make the log output easier to follow.
|
111
242
|
|
112
|
-
|
243
|
+
- It adds color to easily see where each log message starts.
|
244
|
+
|
245
|
+
- It reformats the timestamps to be in local time.
|
246
|
+
|
247
|
+
- It finds JSON blobs and pretty prints them.
|
248
|
+
|
249
|
+
Each of these options can be disabled with command line options.
|
113
250
|
|
114
251
|
### CORS
|
115
252
|
|
116
|
-
If you are developing
|
253
|
+
If you are developing a UI on separate services and need cross-origin
|
117
254
|
resource sharing, you will need to set the
|
118
255
|
[CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) options.
|
119
256
|
|
120
|
-
The current CORS options can be fetched with `murano cors
|
257
|
+
The current CORS options can be fetched with `murano cors`.
|
121
258
|
|
122
|
-
There are three
|
123
|
-
options into a file named `cors.yaml`.
|
259
|
+
There are three different ways to configure CORS.
|
124
260
|
|
125
|
-
|
126
|
-
|
127
|
-
CORS options inline.
|
261
|
+
The first and preferred way is to add your CORS options to a file named
|
262
|
+
`cors.yaml`.
|
128
263
|
|
129
|
-
|
130
|
-
routes:
|
131
|
-
cors: my_cors_file.json
|
132
|
-
```
|
133
|
-
OR:
|
134
|
-
```yaml
|
135
|
-
routes:
|
136
|
-
cors: {"origin": true}
|
137
|
-
```
|
264
|
+
The second and third options are to put the CORS options in your project file.
|
138
265
|
|
139
|
-
|
266
|
+
- In the `routes` section, add a `cors` sub-section with either the name of
|
267
|
+
the file to read, or the CORS options inline.
|
140
268
|
|
141
|
-
|
269
|
+
```yaml
|
270
|
+
routes:
|
271
|
+
cors: my_cors_file.json
|
272
|
+
```
|
142
273
|
|
143
|
-
|
144
|
-
|
274
|
+
OR:
|
275
|
+
|
276
|
+
```yaml
|
277
|
+
routes:
|
278
|
+
cors: {"origin": true}
|
279
|
+
```
|
280
|
+
|
281
|
+
Then use `murano cors set` to push these options up to your application.
|
282
|
+
|
283
|
+
### Writing Routes (a.k.a. Endpoints)
|
284
|
+
|
285
|
+
All of the routes that you create in your application are identified
|
286
|
+
by their method and path. You set this with the following line:
|
145
287
|
|
146
288
|
```lua
|
147
289
|
--#ENDPOINT METHOD PATH
|
148
290
|
```
|
149
291
|
|
150
|
-
Optionally, you can set what the expected content type is too.
|
151
|
-
this,
|
292
|
+
Optionally, you can set what the expected content type is, too.
|
293
|
+
(If you don't set this, it defaults to `application/json`.)
|
152
294
|
|
153
295
|
```lua
|
154
296
|
--#ENDPOINT METHOD PATH CONTENT_TYPE
|
155
297
|
```
|
156
298
|
|
157
|
-
|
299
|
+
Here is an example of a route that puts CSV data:
|
300
|
+
|
158
301
|
```lua
|
159
302
|
--#ENDPOINT PUT /api/upload text/csv
|
160
303
|
```
|
161
304
|
|
162
|
-
After
|
163
|
-
|
164
|
-
|
305
|
+
After the magic header, add the script to handle the route.
|
306
|
+
|
307
|
+
Since many routes end up being a couple of lines or less,
|
308
|
+
you can put multiple routes into a single file.
|
309
|
+
|
310
|
+
A routes file might look like this:
|
165
311
|
|
166
|
-
Which looks like this:
|
167
312
|
```lua
|
168
313
|
--#ENDPOINT GET /api/somedata
|
169
314
|
return Tsdb.query(…)
|
@@ -177,18 +322,24 @@ return Tsdb.deleteAll()
|
|
177
322
|
|
178
323
|
### Writing Service Event Handlers
|
179
324
|
|
180
|
-
|
181
|
-
|
325
|
+
Each event handler in your project is identified by which service
|
326
|
+
it watches and which event in that service triggers the script.
|
327
|
+
|
328
|
+
This is set with the following magic header line:
|
182
329
|
|
183
|
-
This is set with the following line:
|
184
330
|
```lua
|
185
331
|
--#EVENT SERVICE EVENT
|
186
332
|
```
|
187
333
|
|
188
|
-
|
189
|
-
|
334
|
+
To make working with the Product ID easier, you can use the magic
|
335
|
+
variable `{product.id}` instead of the actual Product ID.
|
336
|
+
You can use this variable in both the filename and the magic header.
|
337
|
+
|
338
|
+
For example, the event handler that processes all data coming from your
|
339
|
+
devices might look like:
|
340
|
+
|
190
341
|
```lua
|
191
|
-
--#EVENT
|
342
|
+
--#EVENT {product.id} event
|
192
343
|
local stamped = nil
|
193
344
|
if data.api == "record" then
|
194
345
|
stamped = tostring(data.value[1]) .. 's'
|
@@ -200,31 +351,40 @@ Tsdb.write{
|
|
200
351
|
}
|
201
352
|
```
|
202
353
|
|
203
|
-
### MURANO_CONFIGFILE
|
354
|
+
### MURANO_CONFIGFILE Environment Variable and Dotenv
|
355
|
+
|
356
|
+
The environment variable `MURANO_CONFIGFILE` is checked for an additional config
|
357
|
+
to load. This, in conjunction with [dotenv](https://github.com/bkeepers/dotenv)
|
358
|
+
support, allows you to easily switch between development, staging, and production
|
359
|
+
setups.
|
204
360
|
|
205
|
-
|
206
|
-
|
207
|
-
allows for easily switching between development, staging, and production setups.
|
361
|
+
To use this, write the three Application IDs and three Product IDs for your three
|
362
|
+
deployments into the three files, `.murano.dev`, `.murano.stg`, and `.murano.prod`.
|
208
363
|
|
209
|
-
|
210
|
-
and `.murano.prod`. Then write the `.env` file to point at the system you're
|
211
|
-
currently working on.
|
364
|
+
Then, write the `.env` file to point at the system you're currently working on.
|
212
365
|
|
213
366
|
The files for this are then:
|
367
|
+
|
214
368
|
```sh
|
215
369
|
cat >> .murano.dev <<EOF
|
216
|
-
[
|
370
|
+
[application]
|
217
371
|
id=AAAAAAAA
|
372
|
+
[product]
|
373
|
+
id=BBBBBBBB
|
218
374
|
EOF
|
219
375
|
|
220
376
|
cat >> .murano.stg <<EOF
|
221
|
-
[
|
222
|
-
id=
|
377
|
+
[application]
|
378
|
+
id=LLLLLLLL
|
379
|
+
[product]
|
380
|
+
id=MMMMMMMM
|
223
381
|
EOF
|
224
382
|
|
225
383
|
cat >> .murano.prod <<EOF
|
226
|
-
[
|
227
|
-
id=
|
384
|
+
[application]
|
385
|
+
id=XXXXXXXX
|
386
|
+
[product]
|
387
|
+
id=YYYYYYYY
|
228
388
|
EOF
|
229
389
|
|
230
390
|
cat > .env <<EOF
|
@@ -232,23 +392,25 @@ MURANO_CONFIGFILE=.murano.dev
|
|
232
392
|
EOF
|
233
393
|
```
|
234
394
|
|
235
|
-
This also allows for keeping private things in a separate config file and
|
236
|
-
the shared things checked into source control.
|
395
|
+
This also allows for keeping private things in a separate config file and
|
396
|
+
having the shared things checked into source control.
|
237
397
|
|
238
398
|
### Direct Service Access
|
239
399
|
|
240
|
-
To aid with debugging, MuranoCLI has direct access to some of the services
|
241
|
-
|
400
|
+
To aid with debugging, MuranoCLI has direct access to some of the services
|
401
|
+
in an application.
|
242
402
|
|
243
403
|
Currently these are:
|
404
|
+
|
244
405
|
- Keystore: `murano keystore`
|
406
|
+
|
245
407
|
- TSDB: `murano tsdb`
|
246
408
|
|
247
409
|
### Output Format
|
248
410
|
|
249
|
-
Many sub-commands respect the `outformat` setting.
|
250
|
-
between YAML, JSON, Ruby, CSV, and pretty tables.
|
251
|
-
commands.
|
411
|
+
Many sub-commands respect the `outformat` setting. This lets you switch the
|
412
|
+
output between YAML, JSON, Ruby, CSV, and pretty tables. (Not all formats
|
413
|
+
work with all commands, however.)
|
252
414
|
|
253
415
|
```
|
254
416
|
> murano tsdb product list
|
@@ -260,13 +422,14 @@ commands.
|
|
260
422
|
|
261
423
|
### Product Content Area
|
262
424
|
|
263
|
-
MuranoCLI can manage the content area for a product.
|
264
|
-
files for use by devices.
|
265
|
-
|
266
|
-
can be stored here.
|
425
|
+
MuranoCLI can manage the content area for a product. This area is a place to
|
426
|
+
store files for use by devices. Storing firmware images for over-the-air
|
427
|
+
updates is one typical use, although any kind of fleet-wide data that devices
|
428
|
+
may need to download can be stored here.
|
429
|
+
|
430
|
+
Once the `product.id` is set, the content for that product can be accessed
|
431
|
+
with the following commands:
|
267
432
|
|
268
|
-
Once the `product.id` is set, the content for that product can be accessed with the
|
269
|
-
following commands:
|
270
433
|
```
|
271
434
|
> murano content list
|
272
435
|
> murano content upload
|
@@ -275,7 +438,7 @@ following commands:
|
|
275
438
|
> murano content download
|
276
439
|
```
|
277
440
|
|
278
|
-
Call
|
441
|
+
Call `murano` with `--help` for more details.
|
279
442
|
|
280
443
|
## Developing
|
281
444
|
|
@@ -284,20 +447,30 @@ MuranoCLI uses [git flow](https://github.com/nvie/gitflow#getting-started) for
|
|
284
447
|
|
285
448
|
MuranoCLI also uses [bundler](http://bundler.io).
|
286
449
|
|
287
|
-
When submitting pull requests, please do them against the develop branch.
|
450
|
+
When submitting pull requests, please do them against the `develop` branch.
|
451
|
+
|
452
|
+
### Testing
|
288
453
|
|
289
|
-
### Tests
|
290
454
|
All test for MuranoCLI are done with rspec.
|
291
455
|
|
292
|
-
The tests are internal (`--tag ~cmd`) or command (`--tag cmd`).
|
293
|
-
|
294
|
-
|
295
|
-
|
456
|
+
The tests are internal (`--tag ~cmd`) or command (`--tag cmd`).
|
457
|
+
|
458
|
+
- The internal tests are for the objects that build up the internals.
|
459
|
+
|
460
|
+
- The command tests run `murano` from the shell and are for testing
|
461
|
+
the user facing components.
|
462
|
+
|
463
|
+
A subset of the command tests work with the live Murano servers
|
464
|
+
(`--tag needs_password`).
|
296
465
|
|
297
466
|
To use the live tests, the following environment variables need to be set:
|
298
|
-
- `MURANO_CONFIGFILE` : A Config with the user.name, business.id, and net.host for
|
299
|
-
the integration tests.
|
300
|
-
- `MURANO_PASSWORD` : Password for the user.name above.
|
301
467
|
|
302
|
-
|
468
|
+
- `MURANO_CONFIGFILE`:
|
469
|
+
A Config with the user.name, business.id, and net.host for the integration tests.
|
470
|
+
|
471
|
+
- `MURANO_PASSWORD`:
|
472
|
+
Password for the user.name above.
|
473
|
+
|
474
|
+
A free account on [Murano](https://exosite.com/signup/) is sufficient for
|
475
|
+
these tests.
|
303
476
|
|