MuranoCLI 2.2.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.agignore +3 -0
- data/.gitignore +18 -1
- data/.rubocop.yml +222 -0
- data/.trustme.sh +185 -0
- data/.trustme.vim +24 -0
- data/Gemfile +23 -4
- data/LICENSE.txt +1 -1
- data/MuranoCLI.gemspec +43 -8
- data/README.markdown +9 -11
- data/Rakefile +187 -143
- data/TODO.taskpaper +2 -2
- data/bin/murano +51 -52
- data/docs/basic_example.rst +436 -0
- data/docs/completions/murano_completion-bash +3484 -0
- data/docs/demo.md +32 -32
- data/docs/develop.rst +391 -0
- data/lib/MrMurano.rb +21 -7
- data/lib/MrMurano/Account.rb +159 -174
- data/lib/MrMurano/Business.rb +381 -0
- data/lib/MrMurano/Config-Migrate.rb +32 -26
- data/lib/MrMurano/Config.rb +407 -128
- data/lib/MrMurano/Content.rb +191 -0
- data/lib/MrMurano/Gateway.rb +489 -0
- data/lib/MrMurano/Keystore.rb +48 -0
- data/lib/MrMurano/Passwords.rb +103 -0
- data/lib/MrMurano/ProjectFile.rb +121 -79
- data/lib/MrMurano/ReCommander.rb +114 -10
- data/lib/MrMurano/Setting.rb +90 -0
- data/lib/MrMurano/Solution-ServiceConfig.rb +89 -45
- data/lib/MrMurano/Solution-Services.rb +461 -166
- data/lib/MrMurano/Solution-Users.rb +70 -31
- data/lib/MrMurano/Solution.rb +372 -13
- data/lib/MrMurano/SolutionId.rb +73 -0
- data/lib/MrMurano/SyncRoot.rb +137 -0
- data/lib/MrMurano/SyncUpDown.rb +594 -284
- data/lib/MrMurano/Webservice-Cors.rb +71 -0
- data/lib/MrMurano/Webservice-Endpoint.rb +234 -0
- data/lib/MrMurano/Webservice-File.rb +193 -0
- data/lib/MrMurano/Webservice.rb +51 -0
- data/lib/MrMurano/commands.rb +18 -15
- data/lib/MrMurano/commands/business.rb +300 -6
- data/lib/MrMurano/commands/completion-bash.erb +166 -0
- data/lib/MrMurano/commands/{zshcomplete.erb → completion-zsh.erb} +0 -0
- data/lib/MrMurano/commands/completion.rb +76 -39
- data/lib/MrMurano/commands/config.rb +108 -44
- data/lib/MrMurano/commands/content.rb +115 -72
- data/lib/MrMurano/commands/cors.rb +29 -14
- data/lib/MrMurano/commands/devices.rb +286 -0
- data/lib/MrMurano/commands/domain.rb +52 -12
- data/lib/MrMurano/commands/gb.rb +24 -9
- data/lib/MrMurano/commands/globals.rb +64 -0
- data/lib/MrMurano/commands/init.rb +377 -155
- data/lib/MrMurano/commands/keystore.rb +92 -82
- data/lib/MrMurano/commands/link.rb +300 -0
- data/lib/MrMurano/commands/login.rb +74 -11
- data/lib/MrMurano/commands/logs.rb +63 -32
- data/lib/MrMurano/commands/mock.rb +57 -29
- data/lib/MrMurano/commands/password.rb +57 -39
- data/lib/MrMurano/commands/postgresql.rb +127 -94
- data/lib/MrMurano/commands/settings.rb +203 -0
- data/lib/MrMurano/commands/show.rb +79 -38
- data/lib/MrMurano/commands/solution.rb +423 -5
- data/lib/MrMurano/commands/solution_picker.rb +547 -0
- data/lib/MrMurano/commands/status.rb +195 -61
- data/lib/MrMurano/commands/sync.rb +78 -39
- data/lib/MrMurano/commands/timeseries.rb +71 -55
- data/lib/MrMurano/commands/tsdb.rb +113 -87
- data/lib/MrMurano/commands/usage.rb +57 -15
- data/lib/MrMurano/hash.rb +100 -10
- data/lib/MrMurano/http.rb +187 -43
- data/lib/MrMurano/makePretty.rb +16 -14
- data/lib/MrMurano/optparse.rb +2178 -0
- data/lib/MrMurano/progress.rb +138 -0
- data/lib/MrMurano/schema/resource-v1.0.0.yaml +32 -0
- data/lib/MrMurano/template/projectFile.murano.erb +16 -13
- data/lib/MrMurano/verbosing.rb +166 -29
- data/lib/MrMurano/version.rb +30 -1
- data/spec/Account-Passwords_spec.rb +21 -4
- data/spec/Account_spec.rb +69 -146
- data/spec/Business_spec.rb +290 -0
- data/spec/ConfigFile_spec.rb +1 -0
- data/spec/ConfigMigrate_spec.rb +12 -8
- data/spec/Config_spec.rb +40 -34
- data/spec/Content_spec.rb +363 -0
- data/spec/GatewayBase_spec.rb +54 -0
- data/spec/GatewayDevice_spec.rb +321 -0
- data/spec/GatewayResource_spec.rb +266 -0
- data/spec/GatewaySettings_spec.rb +120 -0
- data/spec/Http_spec.rb +18 -8
- data/spec/Mock_spec.rb +2 -2
- data/spec/ProjectFile_spec.rb +25 -14
- data/spec/Setting_spec.rb +110 -0
- data/spec/Solution-ServiceConfig_spec.rb +44 -5
- data/spec/Solution-ServiceEventHandler_spec.rb +23 -14
- data/spec/Solution-ServiceModules_spec.rb +47 -37
- data/spec/Solution-UsersRoles_spec.rb +10 -8
- data/spec/Solution_spec.rb +17 -8
- data/spec/SyncRoot_spec.rb +46 -20
- data/spec/SyncUpDown_spec.rb +437 -201
- data/spec/Verbosing_spec.rb +12 -4
- data/spec/{Solution-Cors_spec.rb → Webservice-Cors_spec.rb} +23 -20
- data/spec/{Solution-Endpoint_spec.rb → Webservice-Endpoint_spec.rb} +43 -41
- data/spec/{Solution-File_spec.rb → Webservice-File_spec.rb} +44 -33
- data/spec/Webservice-Setting_spec.rb +89 -0
- data/spec/_workspace.rb +4 -4
- data/spec/cmd_business_spec.rb +9 -4
- data/spec/cmd_common.rb +44 -1
- data/spec/cmd_content_spec.rb +43 -17
- data/spec/cmd_cors_spec.rb +4 -4
- data/spec/cmd_device_spec.rb +61 -16
- data/spec/cmd_domain_spec.rb +29 -6
- data/spec/cmd_init_spec.rb +281 -126
- data/spec/cmd_keystore_spec.rb +3 -3
- data/spec/cmd_link_spec.rb +98 -0
- data/spec/cmd_password_spec.rb +1 -1
- data/spec/cmd_setting_application_spec.rb +260 -0
- data/spec/cmd_setting_product_spec.rb +220 -0
- data/spec/cmd_status_spec.rb +223 -114
- data/spec/cmd_syncdown_spec.rb +115 -35
- data/spec/cmd_syncup_spec.rb +68 -15
- data/spec/cmd_usage_spec.rb +35 -8
- data/spec/fixtures/dumped_config +6 -4
- data/spec/fixtures/gateway_resource_files/resources.notyaml +12 -0
- data/spec/fixtures/gateway_resource_files/resources.yaml +13 -0
- data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +13 -0
- data/spec/fixtures/mrmuranorc_deleted_bob +0 -2
- data/spec/fixtures/product_spec_files/lightbulb.yaml +20 -13
- data/spec/fixtures/{syncable_content → syncable_conflict}/services/devdata.lua +1 -1
- data/spec/fixtures/{syncable_content → syncable_conflict}/services/timers.lua +0 -0
- data/spec/spec_helper.rb +5 -0
- metadata +262 -171
- data/bin/mr +0 -8
- data/lib/MrMurano/Product-1P-Device.rb +0 -145
- data/lib/MrMurano/Product-Resources.rb +0 -205
- data/lib/MrMurano/Product.rb +0 -358
- data/lib/MrMurano/Solution-Cors.rb +0 -47
- data/lib/MrMurano/Solution-Endpoint.rb +0 -191
- data/lib/MrMurano/Solution-File.rb +0 -166
- data/lib/MrMurano/commands/assign.rb +0 -57
- data/lib/MrMurano/commands/businessList.rb +0 -45
- data/lib/MrMurano/commands/product.rb +0 -14
- data/lib/MrMurano/commands/productCreate.rb +0 -39
- data/lib/MrMurano/commands/productDelete.rb +0 -33
- data/lib/MrMurano/commands/productDevice.rb +0 -87
- data/lib/MrMurano/commands/productDeviceIdCmds.rb +0 -89
- data/lib/MrMurano/commands/productList.rb +0 -45
- data/lib/MrMurano/commands/productWrite.rb +0 -27
- data/lib/MrMurano/commands/solutionCreate.rb +0 -41
- data/lib/MrMurano/commands/solutionDelete.rb +0 -34
- data/lib/MrMurano/commands/solutionList.rb +0 -45
- data/spec/ProductBase_spec.rb +0 -113
- data/spec/ProductContent_spec.rb +0 -162
- data/spec/ProductResources_spec.rb +0 -329
- data/spec/Product_1P_Device_spec.rb +0 -202
- data/spec/Product_1P_RPC_spec.rb +0 -175
- data/spec/Product_spec.rb +0 -153
- data/spec/Solution-ServiceDevice_spec.rb +0 -176
- data/spec/cmd_assign_spec.rb +0 -51
@@ -1,20 +1,83 @@
|
|
1
|
+
# Last Modified: 2017.08.16 /coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright © 2016-2017 Exosite LLC.
|
5
|
+
# License: MIT. See LICENSE.txt.
|
6
|
+
# vim:tw=0:ts=2:sw=2:et:ai
|
7
|
+
|
1
8
|
require 'MrMurano/Account'
|
9
|
+
require 'MrMurano/Config'
|
10
|
+
require 'MrMurano/ReCommander'
|
2
11
|
|
3
12
|
command 'login' do |c|
|
4
|
-
c.syntax = %
|
5
|
-
c.summary = %
|
6
|
-
c.description = %
|
13
|
+
c.syntax = %(murano login)
|
14
|
+
c.summary = %(Log into Murano)
|
15
|
+
c.description = %(
|
16
|
+
Log into Murano.
|
7
17
|
|
8
|
-
If you are having trouble logging in, try deleting the saved password first
|
9
|
-
|
10
|
-
|
11
|
-
|
18
|
+
If you are having trouble logging in, try deleting the saved password first:
|
19
|
+
|
20
|
+
murano password delete <username>
|
21
|
+
).strip
|
22
|
+
c.option '--show-token', %(Shows the API token)
|
23
|
+
c.project_not_required = true
|
24
|
+
c.prompt_if_logged_off = true
|
12
25
|
|
13
26
|
c.action do |args, options|
|
14
|
-
|
15
|
-
|
16
|
-
say
|
27
|
+
c.verify_arg_count!(args)
|
28
|
+
tok = MrMurano::Account.instance.token
|
29
|
+
say tok if options.show_token
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
command 'logout' do |c|
|
34
|
+
c.syntax = %(murano logout)
|
35
|
+
c.summary = %(Log out of Murano)
|
36
|
+
c.description = %(
|
37
|
+
Log out of Murano.
|
38
|
+
|
39
|
+
This command will unset the user.name in the user config, and
|
40
|
+
it will remove that user's password from the password file.
|
41
|
+
|
42
|
+
Essentially, this command is the same as:
|
43
|
+
|
44
|
+
murano password delete <username>
|
45
|
+
murano config --unset --user user.name
|
46
|
+
).strip
|
47
|
+
c.project_not_required = true
|
48
|
+
|
49
|
+
c.action do |args, _options|
|
50
|
+
c.verify_arg_count!(args)
|
51
|
+
|
52
|
+
net_host = verify_set('net.host')
|
53
|
+
user_name = verify_set('user.name')
|
54
|
+
if net_host && user_name
|
55
|
+
psd = MrMurano::Passwords.new
|
56
|
+
psd.load
|
57
|
+
psd.remove(net_host, user_name)
|
58
|
+
psd.save
|
59
|
+
end
|
60
|
+
|
61
|
+
user_net_host = $cfg.get('net.host', :user)
|
62
|
+
user_net_host = $cfg.get('net.host', :defaults) if user_net_host.nil?
|
63
|
+
user_user_name = $cfg.get('user.name', :user)
|
64
|
+
if (user_net_host == net_host) && (user_user_name == user_name)
|
65
|
+
# Only clear user name from the user config if the net.host
|
66
|
+
# or user.name did not come from a different config, like the
|
67
|
+
# --project config.
|
68
|
+
$cfg.set('user.name', nil, :user)
|
69
|
+
$cfg.set('business.id', nil, :user)
|
70
|
+
$cfg.set('business.name', nil, :user)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def verify_set(cfg_key)
|
75
|
+
cfg_val = $cfg.get(cfg_key)
|
76
|
+
if cfg_val.to_s.empty?
|
77
|
+
cfg_val = nil
|
78
|
+
MrMurano::Verbose.warning("No config key ‘#{cfg_key}’: no password to delete")
|
79
|
+
end
|
80
|
+
cfg_val
|
17
81
|
end
|
18
82
|
end
|
19
83
|
|
20
|
-
# vim: set ai et sw=2 ts=2 :
|
@@ -1,42 +1,69 @@
|
|
1
|
-
|
1
|
+
# Last Modified: 2017.08.16 /coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright © 2016-2017 Exosite LLC.
|
5
|
+
# License: MIT. See LICENSE.txt.
|
6
|
+
# vim:tw=0:ts=2:sw=2:et:ai
|
7
|
+
|
2
8
|
require 'MrMurano/makePretty'
|
9
|
+
require 'MrMurano/ReCommander'
|
10
|
+
require 'MrMurano/Solution'
|
3
11
|
|
4
12
|
command :logs do |c|
|
5
|
-
c.syntax = %
|
6
|
-
c.
|
7
|
-
c.
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
c
|
13
|
-
c.option '--raw', %{Don't do any formating of the log data}
|
13
|
+
c.syntax = %(murano logs [--options])
|
14
|
+
c.summary = %(Get the logs for a solution)
|
15
|
+
c.description = %(
|
16
|
+
Get the logs for a solution.
|
17
|
+
).strip
|
18
|
+
|
19
|
+
# Add flag: --type [application|product].
|
20
|
+
cmd_add_solntype_pickers(c, exclude_all: true)
|
14
21
|
|
15
|
-
c.
|
16
|
-
|
22
|
+
c.option '-f', '--follow', %(Follow logs from server)
|
23
|
+
c.option '--[no-]pretty', %(Reformat JSON blobs in logs.)
|
24
|
+
c.option '--[no-]localtime', %(Adjust Timestamps to be in local time)
|
25
|
+
c.option '--raw', %(Don't do any formating of the log data)
|
26
|
+
# FIXME/2017-06-23: It'd be nice to allow :all
|
27
|
+
# But then we'd have to interleave output somehow with --follow,
|
28
|
+
# maybe using separate threads?
|
17
29
|
|
18
|
-
|
30
|
+
c.action do |args, options|
|
31
|
+
c.verify_arg_count!(args)
|
32
|
+
options.default(pretty: true, localtime: true, raw: false, type: :application)
|
33
|
+
cmd_defaults_solntype_pickers(options, :application)
|
19
34
|
|
20
|
-
if options.
|
21
|
-
|
35
|
+
if options.type == :application
|
36
|
+
sol = MrMurano::Application.new
|
37
|
+
elsif options.type == :product
|
38
|
+
sol = MrMurano::Product.new
|
39
|
+
else
|
40
|
+
MrMurano::Verbose.error "Unknown --type specified: #{options.type}"
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
|
44
|
+
if options.follow
|
45
|
+
# Open a lasting connection and continually feed makePretty().
|
22
46
|
begin
|
23
47
|
sol.get('/logs?polling=true') do |request, http|
|
24
|
-
request[
|
48
|
+
request['Accept-Encoding'] = 'None'
|
25
49
|
http.request(request) do |response|
|
26
|
-
remainder=''
|
50
|
+
remainder = ''
|
27
51
|
response.read_body do |chunk|
|
28
52
|
chunk = remainder + chunk unless remainder.empty?
|
29
53
|
|
30
|
-
#
|
54
|
+
# For all complete JSON blobs, make them pretty.
|
31
55
|
chunk.gsub!(/\{(?>[^}{]+|\g<0>)*\}/m) do |m|
|
32
|
-
if options.raw
|
56
|
+
if options.raw
|
33
57
|
puts m
|
34
58
|
else
|
35
59
|
begin
|
36
|
-
js = JSON.parse(
|
37
|
-
|
38
|
-
|
39
|
-
|
60
|
+
js = JSON.parse(
|
61
|
+
m,
|
62
|
+
allow_nan: true,
|
63
|
+
symbolize_names: true,
|
64
|
+
create_additions: false,
|
65
|
+
)
|
66
|
+
puts MrMurano::Pretties.makePretty(js, options)
|
40
67
|
rescue
|
41
68
|
sol.error '=== JSON parse error, showing raw instead ==='
|
42
69
|
puts m
|
@@ -45,34 +72,38 @@ command :logs do |c|
|
|
45
72
|
'' #remove (we're kinda abusing gsub here.)
|
46
73
|
end
|
47
74
|
|
48
|
-
#
|
49
|
-
|
50
|
-
remainder =
|
75
|
+
# Is there an incomplete one?
|
76
|
+
chunk.match(/(\{.*$)/m) do |mat|
|
77
|
+
remainder = mat[1]
|
51
78
|
end
|
52
|
-
|
53
79
|
end
|
54
80
|
end
|
55
81
|
end
|
82
|
+
# rubocop:disable Lint/HandleExceptions: Do not suppress exceptions.
|
56
83
|
rescue Interrupt => _
|
57
84
|
end
|
58
85
|
|
59
86
|
else
|
60
87
|
ret = sol.get('/logs')
|
61
88
|
|
62
|
-
if ret.
|
89
|
+
if ret.is_a?(Hash) && ret.key?(:items)
|
63
90
|
ret[:items].reverse.each do |line|
|
64
|
-
if options.raw
|
91
|
+
if options.raw
|
65
92
|
puts line
|
66
93
|
else
|
67
|
-
puts MrMurano::Pretties
|
94
|
+
puts MrMurano::Pretties.makePretty(line, options)
|
68
95
|
end
|
69
96
|
end
|
70
97
|
else
|
71
98
|
sol.error "Couldn't get logs: #{ret}"
|
99
|
+
# 2017-06-23: Shouldn't this be exit? What're we breaking out of?
|
72
100
|
break
|
73
101
|
end
|
74
|
-
|
75
102
|
end
|
76
103
|
end
|
77
104
|
end
|
78
|
-
|
105
|
+
alias_command 'logs application', 'logs', '--type', 'application'
|
106
|
+
alias_command 'logs product', 'logs', '--type', 'product'
|
107
|
+
alias_command 'application logs', 'logs', '--type', 'application'
|
108
|
+
alias_command 'product logs', 'logs', '--type', 'product'
|
109
|
+
|
@@ -1,63 +1,91 @@
|
|
1
|
+
# Last Modified: 2017.08.16 /coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright © 2016-2017 Exosite LLC.
|
5
|
+
# License: MIT. See LICENSE.txt.
|
6
|
+
# vim:tw=0:ts=2:sw=2:et:ai
|
7
|
+
|
1
8
|
require 'MrMurano/Mock'
|
9
|
+
require 'MrMurano/ReCommander'
|
2
10
|
|
3
11
|
command 'mock' do |c|
|
4
|
-
c.syntax = %
|
5
|
-
c.summary = %
|
6
|
-
c.description = %
|
12
|
+
c.syntax = %(murano mock)
|
13
|
+
c.summary = %(Enable or disable testpoint, or show current UUID)
|
14
|
+
c.description = %(
|
15
|
+
The mock command lets you enable testpoints to do local Lua development.
|
16
|
+
).strip
|
17
|
+
c.project_not_required = true
|
7
18
|
|
8
|
-
c.action do |
|
19
|
+
c.action do |_args, _options|
|
9
20
|
::Commander::UI.enable_paging
|
10
21
|
say MrMurano::SubCmdGroupHelp.new(c).get_help
|
11
22
|
end
|
12
23
|
end
|
13
24
|
|
14
25
|
command 'mock enable' do |c|
|
15
|
-
c.syntax = %
|
16
|
-
c.summary = %
|
17
|
-
c.description = %
|
18
|
-
|
19
|
-
|
20
|
-
|
26
|
+
c.syntax = %(murano mock enable)
|
27
|
+
c.summary = %(Create a testpoint file)
|
28
|
+
c.description = %(
|
29
|
+
Create a testpoint file.
|
30
|
+
|
31
|
+
Run syncup after running this to carry the change through to Murano.
|
32
|
+
|
33
|
+
Returns the UUID to be used for authenticating.
|
34
|
+
).strip
|
35
|
+
c.option '--raw', %(print raw uuid)
|
36
|
+
|
21
37
|
c.action do |args, options|
|
38
|
+
c.verify_arg_count!(args)
|
22
39
|
mock = MrMurano::Mock.new
|
23
|
-
uuid = mock.create_testpoint
|
24
|
-
if options.raw
|
40
|
+
uuid = mock.create_testpoint
|
41
|
+
if options.raw
|
25
42
|
say uuid
|
26
43
|
else
|
27
|
-
say %
|
28
|
-
say %
|
44
|
+
say %(Created testpoint file. Run `murano syncup` to activate. The following is the authorization token:)
|
45
|
+
say %($ export AUTHORIZATION="#{uuid}")
|
29
46
|
end
|
30
47
|
end
|
31
48
|
end
|
32
49
|
|
33
50
|
command 'mock disable' do |c|
|
34
|
-
c.syntax = %
|
35
|
-
c.summary = %
|
36
|
-
c.description = %
|
51
|
+
c.syntax = %(murano mock disable)
|
52
|
+
c.summary = %(Remove the testpoint file)
|
53
|
+
c.description = %(
|
54
|
+
Remove the testpoint file.
|
37
55
|
|
38
|
-
|
56
|
+
Run syncup after running this to carry the change through to Murano.
|
57
|
+
).strip
|
58
|
+
|
59
|
+
c.action do |args, _options|
|
60
|
+
c.verify_arg_count!(args)
|
39
61
|
mock = MrMurano::Mock.new
|
40
|
-
removed = mock.remove_testpoint
|
41
|
-
if removed
|
42
|
-
say %
|
62
|
+
removed = mock.remove_testpoint
|
63
|
+
if removed
|
64
|
+
say %(Deleted testpoint file. Run `murano syncup` to remove the testpoint.)
|
43
65
|
else
|
44
|
-
say %
|
66
|
+
say %(No testpoint file to remove.)
|
45
67
|
end
|
46
68
|
end
|
47
69
|
end
|
48
70
|
|
49
71
|
command 'mock show' do |c|
|
50
|
-
c.syntax = %
|
51
|
-
c.summary = %
|
52
|
-
c.description = %
|
72
|
+
c.syntax = %(murano mock disable)
|
73
|
+
c.summary = %(Remove the testpoint file)
|
74
|
+
c.description = %(
|
75
|
+
Remove the testpoint file.
|
53
76
|
|
54
|
-
|
77
|
+
Run syncup after running this to carry the change through to Murano.
|
78
|
+
).strip
|
79
|
+
|
80
|
+
c.action do |args, _options|
|
81
|
+
c.verify_arg_count!(args)
|
55
82
|
mock = MrMurano::Mock.new
|
56
|
-
uuid = mock.show
|
57
|
-
if uuid
|
83
|
+
uuid = mock.show
|
84
|
+
if uuid
|
58
85
|
say uuid
|
59
86
|
else
|
60
|
-
say %
|
87
|
+
say %(Could not find testpoint file or UUID in testpoint file.)
|
61
88
|
end
|
62
89
|
end
|
63
90
|
end
|
91
|
+
|
@@ -1,91 +1,109 @@
|
|
1
|
+
# Last Modified: 2017.08.16 /coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright © 2016-2017 Exosite LLC.
|
5
|
+
# License: MIT. See LICENSE.txt.
|
6
|
+
# vim:tw=0:ts=2:sw=2:et:ai
|
7
|
+
|
8
|
+
require 'MrMurano/ReCommander'
|
1
9
|
|
2
10
|
command :password do |c|
|
3
|
-
c.syntax = %
|
4
|
-
c.summary = %
|
5
|
-
c.description = %
|
6
|
-
|
11
|
+
c.syntax = %(murano password)
|
12
|
+
c.summary = %(About password commands)
|
13
|
+
c.description = %(
|
14
|
+
Commands for working with usernames and passwords.
|
15
|
+
).strip
|
16
|
+
c.project_not_required = true
|
17
|
+
c.action do |_args, _options|
|
7
18
|
::Commander::UI.enable_paging
|
8
19
|
say MrMurano::SubCmdGroupHelp.new(c).get_help
|
9
20
|
end
|
10
21
|
end
|
11
|
-
|
12
22
|
alias_command 'password current', :config, 'user.name'
|
13
23
|
|
14
24
|
command 'password list' do |c|
|
15
|
-
c.syntax = %
|
16
|
-
c.summary = %
|
17
|
-
c.description = %
|
18
|
-
|
25
|
+
c.syntax = %(murano password list)
|
26
|
+
c.summary = %(List the usernames with saved passwords)
|
27
|
+
c.description = %(
|
28
|
+
List the usernames and hosts that have been saved.
|
29
|
+
).strip
|
30
|
+
c.project_not_required = true
|
31
|
+
|
32
|
+
c.action do |args, _options|
|
33
|
+
c.verify_arg_count!(args)
|
34
|
+
|
19
35
|
psd = MrMurano::Passwords.new
|
20
36
|
psd.load
|
21
37
|
|
22
38
|
ret = psd.list
|
23
39
|
psd.outf(ret) do |dd, ios|
|
24
|
-
rows=[]
|
40
|
+
rows = []
|
25
41
|
dd.each_pair do |key, value|
|
26
|
-
value.each{|v| rows << [key, v] }
|
42
|
+
value.each { |v| rows << [key, v] }
|
27
43
|
end
|
28
|
-
psd.tabularize(
|
29
|
-
:rows
|
30
|
-
|
44
|
+
psd.tabularize(
|
45
|
+
{ rows: rows, headers: %i[Host Username] },
|
46
|
+
ios
|
47
|
+
)
|
31
48
|
end
|
32
49
|
end
|
33
50
|
end
|
51
|
+
alias_command 'passwords list', 'password list'
|
34
52
|
|
35
53
|
command 'password set' do |c|
|
36
|
-
c.syntax = %
|
37
|
-
c.summary = %
|
38
|
-
|
39
|
-
|
40
|
-
|
54
|
+
c.syntax = %(murano password set <username> [<host>])
|
55
|
+
c.summary = %(Set password for username)
|
56
|
+
c.description = %(
|
57
|
+
Set password for username.
|
58
|
+
).strip
|
59
|
+
c.option '--password PASSWORD', String, %(The password to use)
|
60
|
+
c.option '--from_env', %(Use password in MURANO_PASSWORD)
|
61
|
+
c.project_not_required = true
|
41
62
|
|
42
63
|
c.action do |args, options|
|
43
|
-
|
44
|
-
psd.load
|
45
|
-
|
46
|
-
if args.count < 1 then
|
47
|
-
psd.error "Missing username"
|
48
|
-
exit 1
|
49
|
-
end
|
64
|
+
c.verify_arg_count!(args, 2, ['Missing username'])
|
50
65
|
|
51
66
|
username = args.shift
|
52
67
|
host = args.shift
|
53
68
|
host = $cfg['net.host'] if host.nil?
|
54
69
|
|
55
|
-
|
70
|
+
psd = MrMurano::Passwords.new
|
71
|
+
psd.load
|
72
|
+
if options.password
|
56
73
|
pws = options.password
|
57
|
-
elsif options.from_env
|
74
|
+
elsif options.from_env
|
58
75
|
pws = ENV['MURANO_PASSWORD']
|
59
76
|
else
|
60
|
-
pws = ask(
|
77
|
+
pws = ask('Password: ') { |q| q.echo = '*' }
|
61
78
|
end
|
62
|
-
|
63
79
|
psd.set(host, username, pws)
|
64
80
|
psd.save
|
65
|
-
|
66
81
|
end
|
67
82
|
end
|
68
83
|
|
69
84
|
command 'password delete' do |c|
|
70
|
-
c.syntax = %
|
71
|
-
c.summary = %
|
85
|
+
c.syntax = %(murano password delete <username> [<host>])
|
86
|
+
c.summary = %(Delete password for username)
|
87
|
+
c.description = %(
|
88
|
+
Delete password for username.
|
89
|
+
).strip
|
90
|
+
c.project_not_required = true
|
91
|
+
|
92
|
+
c.option('-y', '--[no-]yes', %(Answer "yes" to all prompts and run non-interactively))
|
72
93
|
|
73
94
|
c.action do |args, options|
|
95
|
+
c.verify_arg_count!(args, 2, ['Missing username'])
|
96
|
+
|
74
97
|
psd = MrMurano::Passwords.new
|
75
98
|
psd.load
|
76
99
|
|
77
|
-
if args.count < 1 then
|
78
|
-
psd.error "Missing username"
|
79
|
-
exit 1
|
80
|
-
end
|
81
|
-
|
82
100
|
username = args.shift
|
83
101
|
host = args.shift
|
84
102
|
host = $cfg['net.host'] if host.nil?
|
85
103
|
|
104
|
+
psd.cmd_confirm_delete!(username, options.yes, 'abort!')
|
86
105
|
psd.remove(host, username)
|
87
106
|
psd.save
|
88
107
|
end
|
89
108
|
end
|
90
109
|
|
91
|
-
# vim: set ai et sw=2 ts=2 :
|