civo 0.2.5 → 0.2.6

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
  SHA1:
3
- metadata.gz: 2f2f3efe7d12a09a1f5bf5560b1ef16d92305be2
4
- data.tar.gz: 3220e7033a111fd8d110046277ffb7260cb57bcf
3
+ metadata.gz: 1082d3b978ce84ff03add64d9a1f20883b83e2f9
4
+ data.tar.gz: 462382d9c3352af1d28fce02410df740db249f1b
5
5
  SHA512:
6
- metadata.gz: 110ca63190ade1a4e7ac6f626cd209f6b48c937da11f637a78d3d5ee4d79d2efe64b325a5b82d797faa962d0526928e65c8867a5f94b7b1972c965952eb22f4d
7
- data.tar.gz: f109913db65e322b20752eb1ddb1e83dde362d85423b8526354b4651721fc3447d39f233f9fa8b3a234a84a669b32fb868dd4741b006b428288b8101147b14a1
6
+ metadata.gz: aec42aea434594ced9cb25461ad188e91dce2dad87dbbbce8dbcc6bb547dc5dc01d9ede072358036f3c63cb266a022948096610863507e1a0dd1954f0bdd5b98
7
+ data.tar.gz: 0cad5e94b3c539d411734043b6558fd6e7c566f5d9197e70533b08eae866b39f51a4441a3944e0bb910e15eda5af6cf8080a9d4e3685f5e80d458a00417bd9c4
@@ -1,5 +1,7 @@
1
1
  module Civo
2
2
  class Template < Base
3
3
  get :all, "/v1/templates"
4
+ put :save, "/v1/templates/:id"
5
+ post :create, "/v1/templates"
4
6
  end
5
7
  end
@@ -15,7 +15,7 @@ command "sshkeys:upload" do |c|
15
15
  c.description = "Upload an SSH public key for installing in to new instances"
16
16
  c.example "Uploads an SSH public key, calling it 'default' from file '~/.ssh/id_rsa.pub'", 'civo sshkeys:upload default ~/.ssh/id_rsa.pub'
17
17
  c.action do |args, options|
18
- pub_key = File.read(args[1])
18
+ pub_key = File.read(File.expand_path(args[1]))
19
19
  begin
20
20
  Civo::SshKey.create(name: args.first, public_key: pub_key)
21
21
  puts "SSH key '#{args.first}' uploaded."
@@ -10,3 +10,65 @@ command "templates" do |c|
10
10
  end
11
11
  end
12
12
  alias_command "template", "templates"
13
+
14
+ if Civo::Config.admin?
15
+ command "templates:create" do |c|
16
+ c.description = "Create a template (the ID should be all lower-case, hyphens and full stops)"
17
+ c.option "--name STRING", String, "The name of the template"
18
+ c.option "--image-id STRING", String, "The Openstack Image ID"
19
+ c.option "--short-description STRING", String, "A short (one-line) description of this template"
20
+ c.option "--description STRING", String, "A longer (Markdown format) description of this template"
21
+ c.option "--cloud-init-file STRING", String, "The filename of a cloud init file"
22
+ c.example "Creates a template with the ID 'ubuntu-apache' with a cloud init file called 'my-cloud-config'", 'civo template:create ubuntu-apache --image-id 12345-67890-12345 --cloud-init-file=my-cloud-config'
23
+ c.action do |args, options|
24
+ params = {
25
+ id: args[0]
26
+ }
27
+ params[:name] = options.name if options.name
28
+ params[:image_id] = options.image_id if options.image_id
29
+ params[:short_description] = options.short_description if options.short_description
30
+ params[:description] = options.description if options.description
31
+ cloud_init_file = File.expand_path(options.cloud_init_file)
32
+ params[:cloud_config] = File.read(cloud_init_file) if options.cloud_init_file && File.exist?(cloud_init_file)
33
+ begin
34
+ Civo::Template.create(params)
35
+ puts "Template '#{args.first}' updated."
36
+ rescue Flexirest::HTTPUnauthorisedClientException, Flexirest::HTTPForbiddenClientException
37
+ puts "Access denied to your default token, ensure it's set correctly with 'civo tokens'"
38
+ end
39
+ end
40
+ end
41
+ alias_command "template:create", "templates:create"
42
+ alias_command "template:new", "templates:create"
43
+ alias_command "templates:new", "templates:create"
44
+
45
+ command "templates:update" do |c|
46
+ c.description = "Update a template"
47
+ c.option "--name STRING", String, "The name of the template"
48
+ c.option "--image-id STRING", String, "The Openstack Image ID"
49
+ c.option "--short-description STRING", String, "A short (one-line) description of this template"
50
+ c.option "--description STRING", String, "A longer (Markdown format) description of this template"
51
+ c.option "--cloud-init-file STRING", String, "The filename of a cloud init file"
52
+ c.example "Updates a template with the ID 'ubuntu-apache' with a cloud init file called 'my-cloud-config'", 'civo template:update ubuntu-apache --cloud-init-file=my-cloud-config'
53
+ c.action do |args, options|
54
+ params = {
55
+ id: args[0]
56
+ }
57
+ cloud_init_file = File.expand_path(options.cloud_init_file)
58
+ params[:name] = options.name if options.name
59
+ params[:image_id] = options.image_id if options.image_id
60
+ params[:short_description] = options.short_description if options.short_description
61
+ params[:description] = options.description if options.description
62
+ params[:cloud_config] = File.read(cloud_init_file) if options.cloud_init_file && File.exist?(cloud_init_file)
63
+ begin
64
+ Civo::Template.save(params)
65
+ puts "Template '#{args.first}' updated."
66
+ rescue Flexirest::HTTPUnauthorisedClientException, Flexirest::HTTPForbiddenClientException
67
+ puts "Access denied to your default token, ensure it's set correctly with 'civo tokens'"
68
+ end
69
+ end
70
+ end
71
+ alias_command "template:update", "templates:update"
72
+ alias_command "template:save", "templates:update"
73
+ alias_command "templates:save", "templates:update"
74
+ end
data/lib/civo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Civo
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: civo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries