civo_cli 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a7a4c12bb6c33fb8d195ea6fd6989103363efa2be613047e339a8097f84f7bb
4
- data.tar.gz: a2af203425f38eeec1d797f89c216c8ab97a52750f55eb9e4922971bc04b3f72
3
+ metadata.gz: dcf79296d9423f63f2c20427cfa0463f79f1d217e6cbc9ee85008790e670c6da
4
+ data.tar.gz: 6b0a853cb65b6be32f0e4e855cedc81168d8bc407cbfaadb2aad2ac374e1b594
5
5
  SHA512:
6
- metadata.gz: 6d46a626d26bcce98694c596b759e7160788c4425bdc552ea4375193039a42eaf4189338c18552c940e84848546f320860c0ebe16b29f5bd1244b49d1495968c
7
- data.tar.gz: 1e7dff95bfbde8521d86a7ce7570435fe67021c78ba33571cf1d4111d6c37daae60e48ded5a1615afa32026024826a3c9f410bcba5560edbee899ad3d934e27d
6
+ metadata.gz: d39ad0c61f725e01a267357ffa55d6cfba2fcd3a374d83d7e6d4432d1ce306066ca897e75366c1212ccffc3c896f82aee58fd24b58ba2120c67530f8085a6e98
7
+ data.tar.gz: e159923f394e4988b35611a748b5385b8288be0d36f6008db2c57039863a0843e8ea8b89340516e78b79f10c4d4a4e699d0b12d0cb485ca1432aace2d365dc9d
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@ All notable changes to the Civo CLI will be documented in this file.
3
3
 
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
5
 
6
+ ## [0.5.3] - 2019-11-01
7
+ ### Added
8
+ - New feature, you can now specify a script to be run from the cloud-init process (it's saved on the instance as `/usr/local/bin/civo-user-init-script` with root ownership and only root permissions). `civo instance create --script=~/code/myscript.sh`
9
+
6
10
  ## [0.5.2] - 2019-11-01
7
11
  ### Fixed
8
12
  - Updated bundler dependency requirements to allow for new versions of bundler (v. 2 onwards)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- civo_cli (0.5.2)
4
+ civo_cli (0.5.3)
5
5
  bundler (>= 1.17)
6
6
  civo (>= 1.2.9)
7
7
  colorize
@@ -1,3 +1,3 @@
1
1
  module CivoCLI
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
data/lib/instance.rb CHANGED
@@ -85,6 +85,11 @@ module CivoCLI
85
85
  puts " Template ID : #{instance.template_id}"
86
86
  puts " Snapshot ID : #{instance.snapshot_id}"
87
87
  puts ""
88
+ if instance.script.present?
89
+ puts "-" * 26 + " INIT SCRIPT " + "-" * 26
90
+ puts instance.script
91
+ puts ""
92
+ end
88
93
  puts "-" * 29 + " NOTES " + "-" * 29
89
94
  puts ""
90
95
  puts instance.notes
@@ -104,6 +109,7 @@ module CivoCLI
104
109
  option :snapshot, banner: 'snapshot_id'
105
110
  option :ssh_key, banner: 'ssh_key_id', aliases: '--ssh'
106
111
  option :tags, banner: "'tag1 tag2 tag3...'"
112
+ option :script, type: :string, desc: "The filename of a file to be used as an initialization script", aliases: ["-s"], banner: "SCRIPT"
107
113
  option :wait, type: :boolean
108
114
  long_desc <<-LONGDESC
109
115
  Create a new instance with hostname (randomly assigned if blank), instance size (default: g2.small),
@@ -138,11 +144,18 @@ module CivoCLI
138
144
  options[:template] = DEFAULT_TEMPLATE
139
145
  end
140
146
 
147
+ if options[:script]
148
+ unless File.exist?(File.expand_path(options[:script]))
149
+ puts "The file #{options[:script].colorize(:red)} doesn't exist or isn't readable"
150
+ exit 2
151
+ end
152
+ script = File.read(File.expand_path(options[:script]))
153
+ end
141
154
 
142
155
  if options[:template]
143
- @instance = Civo::Instance.create(hostname: hostname, size: options[:size], template: options[:template], public_ip: options[:public_ip], initial_user: options[:initial_user], region: options[:region], ssh_key_id: options[:ssh_key], tags: options[:tags])
156
+ @instance = Civo::Instance.create(hostname: hostname, size: options[:size], template: options[:template], public_ip: options[:public_ip], initial_user: options[:initial_user], region: options[:region], ssh_key_id: options[:ssh_key], tags: options[:tags], script: script)
144
157
  elsif options[:snapshot]
145
- @instance = Civo::Instance.create(hostname: hostname, size: options[:size], snapshot_id: options[:snapshot], public_ip: options[:public_ip], initial_user: options[:initial_user], region: options[:region], ssh_key_id: options[:ssh_key], tags: options[:tags])
158
+ @instance = Civo::Instance.create(hostname: hostname, size: options[:size], snapshot_id: options[:snapshot], public_ip: options[:public_ip], initial_user: options[:initial_user], region: options[:region], ssh_key_id: options[:ssh_key], tags: options[:tags], script: script)
146
159
  end
147
160
 
148
161
  if options[:wait]
@@ -214,6 +227,7 @@ module CivoCLI
214
227
  exit 1
215
228
  end
216
229
  map "delete" => "remove"
230
+ map "rm" => "remove"
217
231
 
218
232
  desc "reboot ID/HOSTNAME", "reboots instance with ID/hostname entered"
219
233
  def reboot(id)
@@ -316,7 +330,7 @@ module CivoCLI
316
330
  option :quiet, type: :boolean, aliases: '-q'
317
331
  def public_ip(id)
318
332
  CivoCLI::Config.set_api_auth
319
-
333
+
320
334
  instance = detect_instance(id)
321
335
  unless instance.public_ip.nil?
322
336
  if options[:quiet]
@@ -324,7 +338,7 @@ module CivoCLI
324
338
  else
325
339
  puts "The public IP for #{instance.hostname.colorize(:green)} is #{instance.public_ip.colorize(:green)}"
326
340
  end
327
- else
341
+ else
328
342
  puts "Error: Instance has no public IP"
329
343
  exit 2
330
344
  end
@@ -348,9 +362,9 @@ module CivoCLI
348
362
  end
349
363
  rescue Flexirest::HTTPException => e
350
364
  puts e.result.reason.colorize(:red)
351
- exit 1
365
+ exit 1
352
366
  end
353
-
367
+
354
368
  default_task :help
355
369
 
356
370
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: civo_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries