escli 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/escli.gemspec +1 -1
- data/lib/canzea/cli/escli.rb +1 -1
- data/lib/canzea/config.rb +1 -1
- data/lib/canzea/environment.rb +1 -1
- data/lib/canzea/registry.rb +1 -1
- data/lib/canzea/version.rb +1 -1
- metadata +1 -4
- data/bin/setup +0 -8
- data/lib/canzea/cli/canzea.rb +0 -323
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88e2a0eb4f62a8ae00cd17d3f9ac295b4be87e34
|
4
|
+
data.tar.gz: 0e78c353fe54ccf9e7ca11d79a38d36c18317105
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83bd4917b4b5b815b201bf98c58168988434c25babf1e3d313a6a73e0d96a55561af81610762e18bfc4aa947e8b8c2d57fe09562b6ef42ec15f29f3a0caf23a0
|
7
|
+
data.tar.gz: 299fad1ce4926ce764c90b44e1773219e12262b8868b0574b8213672d03fe06997f072b778ed8f99015b6093b1583f806f7abf0b1d32cd814f462aef0516e9f3
|
data/Gemfile
CHANGED
data/escli.gemspec
CHANGED
data/lib/canzea/cli/escli.rb
CHANGED
data/lib/canzea/config.rb
CHANGED
data/lib/canzea/environment.rb
CHANGED
data/lib/canzea/registry.rb
CHANGED
data/lib/canzea/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: escli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Canzea Technologies
|
@@ -127,7 +127,6 @@ email:
|
|
127
127
|
- ikethecoder@canzea.com
|
128
128
|
executables:
|
129
129
|
- escli
|
130
|
-
- setup
|
131
130
|
extensions: []
|
132
131
|
extra_rdoc_files: []
|
133
132
|
files:
|
@@ -143,9 +142,7 @@ files:
|
|
143
142
|
- README.md
|
144
143
|
- Rakefile
|
145
144
|
- bin/escli
|
146
|
-
- bin/setup
|
147
145
|
- escli.gemspec
|
148
|
-
- lib/canzea/cli/canzea.rb
|
149
146
|
- lib/canzea/cli/escli.rb
|
150
147
|
- lib/canzea/commands/add-env.rb
|
151
148
|
- lib/canzea/commands/apply-config.rb
|
data/bin/setup
DELETED
data/lib/canzea/cli/canzea.rb
DELETED
@@ -1,323 +0,0 @@
|
|
1
|
-
require 'cri'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'pathname'
|
4
|
-
require 'git'
|
5
|
-
require "canzea/config"
|
6
|
-
require "canzea/version"
|
7
|
-
require "canzea/environment"
|
8
|
-
require "canzea/helper-run-class"
|
9
|
-
require "canzea/plan-step-class"
|
10
|
-
require "canzea/core/trace-component"
|
11
|
-
require "canzea/core/ssh-base-cmd-class"
|
12
|
-
require "canzea/core/template-runner"
|
13
|
-
require "canzea/commands/config-git-commit"
|
14
|
-
require "canzea/commands/get-catalog"
|
15
|
-
require "canzea/commands/remote-run"
|
16
|
-
require "canzea/commands/remote-bootstrap"
|
17
|
-
require "canzea/commands/gen-user"
|
18
|
-
require "canzea/commands/update-config"
|
19
|
-
require "canzea/commands/apply-config"
|
20
|
-
require "canzea/commands/add-env"
|
21
|
-
require "canzea/commands/prepare-plan"
|
22
|
-
require "canzea/commands/register-metadata"
|
23
|
-
require "canzea/commands/push-config"
|
24
|
-
|
25
|
-
module Canzea
|
26
|
-
command = Cri::Command.define do
|
27
|
-
name 'canzea'
|
28
|
-
usage 'canzea [options]'
|
29
|
-
aliases :ds, :stuff
|
30
|
-
summary 'canzea cli'
|
31
|
-
description 'Canzea command line interface.'
|
32
|
-
|
33
|
-
flag :h, :help, 'show help for this command' do |value, cmd|
|
34
|
-
puts cmd.help
|
35
|
-
exit 0
|
36
|
-
end
|
37
|
-
|
38
|
-
flag :v, :version, 'Version' do |value, cmd|
|
39
|
-
puts "Canzea CLI: v#{Canzea::VERSION}"
|
40
|
-
end
|
41
|
-
|
42
|
-
flag nil, :pwd, 'PWD'
|
43
|
-
|
44
|
-
flag nil, :verbose, 'Verbose'
|
45
|
-
|
46
|
-
# flag nil, :run, 'Run a step'
|
47
|
-
# flag nil, :helper, 'Execute a helper'
|
48
|
-
flag nil, :remote, 'Remote execution'
|
49
|
-
flag nil, :remote_configure, 'Remote configuration'
|
50
|
-
flag nil, :remote_wire, 'Remote execution of a helper'
|
51
|
-
flag nil, :get, 'Get a file from the remote server'
|
52
|
-
flag nil, :put, 'Put a file onto the remote server'
|
53
|
-
flag nil, :encrypt, 'Encrypt'
|
54
|
-
flag nil, :decrypt, 'Encrypt'
|
55
|
-
flag nil, :raw, 'Result will be sent back in stdout'
|
56
|
-
flag nil, :init, 'Remote init execution'
|
57
|
-
# flag nil, :enable, 'Enable the service'
|
58
|
-
flag nil, :test, 'Run as a test'
|
59
|
-
flag nil, :reset, 'Refresh catalog to latest'
|
60
|
-
flag nil, :fv, 'Show version and the catalog version'
|
61
|
-
flag nil, :config_git_commit, 'Manage configuration files in git'
|
62
|
-
|
63
|
-
option nil, :config, 'Config', argument: :required
|
64
|
-
|
65
|
-
option nil, :lifecycle, 'Lifecycle action [install, configure, upgrade, uninstall]', argument: :required
|
66
|
-
|
67
|
-
option nil, :util, "Utility action [gen-user, gen-cert, add-env, add-env-secret, prepare-plan, apply-config]", argument: :required
|
68
|
-
option nil, :catalogTag, 'Specific tag of the catalog', argument: :required
|
69
|
-
option nil, :gitRoot, 'Git root', argument: :required
|
70
|
-
option nil, :gitUri, 'Git URI', argument: :required
|
71
|
-
|
72
|
-
option nil, :commit, 'Commit', argument: :required
|
73
|
-
option nil, :role, 'Role', argument: :required
|
74
|
-
option nil, :solution, 'Solution', argument: :required
|
75
|
-
option nil, :task, 'Task', argument: :required
|
76
|
-
option nil, :step, 'Step', argument: :required
|
77
|
-
option nil, :blueprint, 'Blueprint', argument: :required
|
78
|
-
option nil, :segment, 'Segment', argument: :required
|
79
|
-
option nil, :status, 'Result will be put into the status message', argument: :required
|
80
|
-
option nil, :serverBase, 'Server Base', argument: :required
|
81
|
-
option nil, :serverNumber, 'Server Number', argument: :required
|
82
|
-
option nil, :privateKey, 'Task', argument: :required
|
83
|
-
option nil, :publicKey, 'Task', argument: :required
|
84
|
-
option nil, :template, 'Template', argument: :required
|
85
|
-
|
86
|
-
option nil, :action, 'Helper Action', argument: :required
|
87
|
-
option nil, :args, 'Arguments (JSON format)', argument: :required
|
88
|
-
|
89
|
-
run do |opts, args, cmd|
|
90
|
-
|
91
|
-
test = opts.fetch(:test, false)
|
92
|
-
|
93
|
-
if opts[:config]
|
94
|
-
file = File.read(opts[:config])
|
95
|
-
Canzea::configure JSON.parse(file)
|
96
|
-
end
|
97
|
-
|
98
|
-
extraConfig = Canzea::config[:config_location] + "/config.json"
|
99
|
-
if File.exists?(extraConfig)
|
100
|
-
if (opts[:verbose])
|
101
|
-
puts "-- Reading #{extraConfig}"
|
102
|
-
end
|
103
|
-
file = File.read(extraConfig)
|
104
|
-
Canzea::configure JSON.parse(file)
|
105
|
-
end
|
106
|
-
|
107
|
-
if opts[:pwd]
|
108
|
-
puts Dir.pwd
|
109
|
-
end
|
110
|
-
|
111
|
-
if File.exists?(Canzea::config[:catalog_location]) == false
|
112
|
-
GetCatalog.new.do(opts.fetch(:catalogTag, nil));
|
113
|
-
end
|
114
|
-
|
115
|
-
if (opts[:reset])
|
116
|
-
GetCatalog.new.do(opts.fetch(:catalogTag, nil));
|
117
|
-
end
|
118
|
-
|
119
|
-
GetCatalog.new.state
|
120
|
-
|
121
|
-
if (opts[:fv])
|
122
|
-
puts "Canzea CLI: v#{Canzea::VERSION}"
|
123
|
-
|
124
|
-
puts "Catalog: #{ENV['CATALOG_BRANCH']} ( #{ENV['CATALOG_COMMIT']} )"
|
125
|
-
end
|
126
|
-
|
127
|
-
|
128
|
-
if (opts[:util])
|
129
|
-
AddEnv.new(opts.fetch(:raw, false)).injectEnvironmentVariables
|
130
|
-
|
131
|
-
util = opts[:util]
|
132
|
-
if (util == "add-env")
|
133
|
-
AddEnv.new.add(args[0], args[1])
|
134
|
-
end
|
135
|
-
if (util == "add-env-secret")
|
136
|
-
AddEnv.new.addSecret(args[0], args[1])
|
137
|
-
end
|
138
|
-
if (util == "register-metadata")
|
139
|
-
RegisterMetadata.new.do(opts[:role], opts[:solution], test)
|
140
|
-
end
|
141
|
-
|
142
|
-
if (util == "analyze-command")
|
143
|
-
step = Integer(opts.fetch(:step, '0'))
|
144
|
-
|
145
|
-
list = []
|
146
|
-
args = JSON.parse(opts.fetch(:args, "{'phases'=>['install']}"))
|
147
|
-
phases = args['phases']
|
148
|
-
|
149
|
-
publicIp = File.read("#{Canzea::config[:pwd]}/vps-#{opts[:serverBase]}-#{opts[:serverNumber]}.json")
|
150
|
-
publicIp.strip!
|
151
|
-
|
152
|
-
basePath = "#{Pathname.new(Canzea::config[:catalog_location]).realpath}"
|
153
|
-
root = "#{basePath}/blocks/#{opts[:solution]}"
|
154
|
-
if File.exists? root
|
155
|
-
phases.each { | phase |
|
156
|
-
basePath = "#{Pathname.new(Canzea::config[:catalog_location]).realpath}"
|
157
|
-
cmd = "#{basePath}/blocks/#{opts[:solution]}/#{phase}.sh"
|
158
|
-
if File.exists? cmd
|
159
|
-
list += Worker.new.find (cmd)
|
160
|
-
end
|
161
|
-
}
|
162
|
-
else
|
163
|
-
phases.each { | phase |
|
164
|
-
basePath = "#{Pathname.new(Canzea::config[:catalog_location]).realpath}"
|
165
|
-
cmd = "#{basePath}/roles/#{opts[:role]}/#{opts[:solution]}/#{phase}.sh"
|
166
|
-
if File.exists? cmd
|
167
|
-
list += Worker.new.find (cmd)
|
168
|
-
end
|
169
|
-
}
|
170
|
-
end
|
171
|
-
|
172
|
-
list.each_with_index { | cmd, index |
|
173
|
-
if index >= step
|
174
|
-
puts "[#{index}] #{cmd}"
|
175
|
-
|
176
|
-
RemoteRun.new.doCommand publicIp, opts[:privateKey], cmd
|
177
|
-
else
|
178
|
-
puts "[#{index}] SKIP #{cmd}"
|
179
|
-
end
|
180
|
-
}
|
181
|
-
end
|
182
|
-
|
183
|
-
if (util == "gen-template")
|
184
|
-
t = Template.new
|
185
|
-
# canzea --util=gen-template --template="Result = {{#cname}}A:{{#tf_name}}name{{/tf_name}}{{/cname}} {{gravatar}}" --args='{"a":[{"name":"grafana.mon"}], "cname":[{"name":"www","address":"@"},{"name":"vault","address":"@"},{"name":"consul","address":"@"},{"name":"sc","address":"@"}]}'
|
186
|
-
puts t.processString opts[:template], JSON.parse(opts.fetch(:args, '{}'))
|
187
|
-
end
|
188
|
-
|
189
|
-
if (util == "gen-user")
|
190
|
-
GenUser.new.do(args[0])
|
191
|
-
end
|
192
|
-
if (util == "get-key-value")
|
193
|
-
r = Registry.new
|
194
|
-
puts r.getKeyValue (args[0])
|
195
|
-
end
|
196
|
-
if (util == "set-key-value")
|
197
|
-
r = Registry.new
|
198
|
-
puts r.setKeyValue args[0], args[1], args[2]
|
199
|
-
end
|
200
|
-
if (util == "prepare-plan")
|
201
|
-
ac = PreparePlan.new
|
202
|
-
ac.do opts[:blueprint], opts[:segment], opts[:step], opts[:task], test, opts[:privateKey], opts[:serverBase], opts[:serverNumber]
|
203
|
-
end
|
204
|
-
if (util == "prepare-patch")
|
205
|
-
ac = PreparePlan.new
|
206
|
-
ac.doPatch opts.fetch(:args, '{}'), test, opts[:privateKey], opts[:serverBase], opts[:serverNumber]
|
207
|
-
end
|
208
|
-
if (util == "apply-config")
|
209
|
-
gitRoot = opts.fetch(:gitRoot, Canzea::config[:git_repo])
|
210
|
-
ac = ApplyConfig.new
|
211
|
-
ac.do gitRoot, test, opts[:step], opts[:task]
|
212
|
-
end
|
213
|
-
if (util == "push-config")
|
214
|
-
PushConfig.new.do(args[0], args[1], JSON.parse(opts.fetch(:args, '{}')))
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
if (opts[:get] || opts[:put])
|
219
|
-
publicIp = File.read("#{Canzea::config[:pwd]}/vps-#{opts[:serverBase]}-#{opts[:serverNumber]}.json")
|
220
|
-
publicIp.strip!
|
221
|
-
if (opts[:get])
|
222
|
-
remote = RemoteCall.new
|
223
|
-
remote.get publicIp, opts[:privateKey], args[0], args[1]
|
224
|
-
end
|
225
|
-
if (opts[:put])
|
226
|
-
remote = RemoteCall.new
|
227
|
-
remote.put publicIp, opts[:privateKey], args[0], args[1]
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
if (opts[:encrypt])
|
232
|
-
remote = RemoteCall.new
|
233
|
-
remote.encrypt args[0], opts[:publicKey]
|
234
|
-
end
|
235
|
-
|
236
|
-
if (opts[:decrypt])
|
237
|
-
remote = RemoteCall.new
|
238
|
-
remote.decrypt args[0], opts[:privateKey]
|
239
|
-
end
|
240
|
-
|
241
|
-
if (opts[:lifecycle])
|
242
|
-
|
243
|
-
lifecycle = opts[:lifecycle]
|
244
|
-
|
245
|
-
AddEnv.new(opts.fetch(:raw, false)).injectEnvironmentVariables
|
246
|
-
|
247
|
-
if lifecycle == 'install'
|
248
|
-
puts "-- Running install step #{opts[:role]} #{opts[:solution]}"
|
249
|
-
ps = PlanStep.new
|
250
|
-
ps.runPhaseInstall opts[:role], opts[:solution], test, Integer(opts.fetch(:task, 1))
|
251
|
-
|
252
|
-
|
253
|
-
if (test == false)
|
254
|
-
gitRoot = opts.fetch(:gitRoot, Canzea::config[:git_repo])
|
255
|
-
|
256
|
-
conf = { :gitRoot => gitRoot, :role => opts[:role], :solution => opts[:solution] }
|
257
|
-
ps = UpdateConfig.new
|
258
|
-
ps.do opts[:role], opts[:solution], gitRoot
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
if lifecycle == 'configure'
|
263
|
-
puts "-- Running configure step #{opts[:role]} #{opts[:solution]}"
|
264
|
-
ps = PlanStep.new
|
265
|
-
ps.runPhaseConfigure opts[:role], opts[:solution], test, Integer(opts.fetch(:task, 1))
|
266
|
-
end
|
267
|
-
|
268
|
-
if lifecycle == 'patch'
|
269
|
-
puts "-- Running patch step #{opts[:commit]} #{opts[:solution]}"
|
270
|
-
ps = PlanStep.new
|
271
|
-
ps.runPhasePatch opts[:commit], opts[:solution], test, Integer(opts.fetch(:task, 1))
|
272
|
-
end
|
273
|
-
|
274
|
-
if lifecycle == 'wire'
|
275
|
-
# puts "-- Running helper #{opts[:solution]} #{opts[:action]}"
|
276
|
-
ps = HelperRun.new opts.fetch(:raw, false)
|
277
|
-
ps.run opts[:solution], opts[:action], opts.fetch(:args, '{}'), opts.fetch(:status,nil)
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
if opts[:init]
|
282
|
-
publicIp = File.read("#{Canzea::config[:pwd]}/vps-#{opts[:serverBase]}-#{opts[:serverNumber]}.json")
|
283
|
-
publicIp.strip!
|
284
|
-
RemoteInit.new.do publicIp, opts[:privateKey]
|
285
|
-
end
|
286
|
-
|
287
|
-
if opts[:remote]
|
288
|
-
publicIp = File.read("#{Canzea::config[:pwd]}/vps-#{opts[:serverBase]}-#{opts[:serverNumber]}.json")
|
289
|
-
publicIp.strip!
|
290
|
-
RemoteRun.new.do publicIp, opts[:privateKey], opts[:role], opts[:solution]
|
291
|
-
end
|
292
|
-
|
293
|
-
if opts[:remote_configure]
|
294
|
-
publicIp = File.read("#{Canzea::config[:pwd]}/vps-#{opts[:serverBase]}-#{opts[:serverNumber]}.json")
|
295
|
-
publicIp.strip!
|
296
|
-
RemoteRun.new.doConfigure publicIp, opts[:privateKey], opts[:role], opts[:solution]
|
297
|
-
end
|
298
|
-
|
299
|
-
if opts[:remote_wire]
|
300
|
-
publicIp = File.read("#{Canzea::config[:pwd]}/vps-#{opts[:serverBase]}-#{opts[:serverNumber]}.json")
|
301
|
-
publicIp.strip!
|
302
|
-
RemoteRun.new.doWire publicIp, opts[:privateKey], opts[:solution], opts[:action], opts.fetch(:args, '{}')
|
303
|
-
end
|
304
|
-
|
305
|
-
if opts[:config_git_commit]
|
306
|
-
if (Canzea::config[:track_changes_in_git] && ENV.has_key?('ECOSYSTEM') == false)
|
307
|
-
raise "ECOSYSTEM environment variable must be set for this command"
|
308
|
-
end
|
309
|
-
|
310
|
-
gitRoot = opts.fetch(:gitRoot, Canzea::config[:git_repo])
|
311
|
-
gitUri = opts.fetch(:gitUri, "");
|
312
|
-
|
313
|
-
basePath = "ecosystems/#{ENV['ECOSYSTEM']}/config/#{opts[:serverBase]}-#{opts[:serverNumber]}"
|
314
|
-
|
315
|
-
cg = ConfigGitCommit.new
|
316
|
-
cg.do gitRoot, gitUri, args[0], opts[:template], basePath, (args.length == 1 ? {}:JSON.parse(args[1]))
|
317
|
-
end
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
command.run(ARGV)
|
322
|
-
|
323
|
-
end
|