qtc-sdk 0.0.1 → 0.0.2

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: ae1a61e36df4c88b7796881f0c73fd5472094bd4
4
- data.tar.gz: 6fab0aab05f54655cc57c06dd4e74eff2abe3f18
3
+ metadata.gz: a4fa5b0dcf5a632850cb3a7d9db9cb5e4be9b094
4
+ data.tar.gz: 3d7ef952957e86962c1a156e37ed483f38115b8e
5
5
  SHA512:
6
- metadata.gz: 9ef6371c511a18cae763e32c577e8f5a62424a8ff78bafe8457d0dac9ef94cdfb17c47badea6dbb4a129c5318e4571bba7a929f4311bdeb7f7b599c5c17b2dfc
7
- data.tar.gz: d91e9aba94dcf0a24244436671cbae52533f43c463b2b49089dad2e25639451c8e7b77b28a15a9bf2ca7a46eca71005c467e030d0fc79e78efee88dbded1e149
6
+ metadata.gz: f6597366aa9a0aa4109131955639194a0e99eafbb2a355bdebe3a924666d8920731a9a65b0f061c13e3b35f7bf3352b688ff7c624deb3d9381c59eddd9c25cec
7
+ data.tar.gz: e90fab57614d8dba935174cbe6326429900c46b1056f38085fae048ccdc7f40edbdf444fc750f905373526f9dd1f9bc442accb39540914d508d28b65713fad17
@@ -7,30 +7,6 @@ program :description, 'Command line interface for Qt Cloud Services'
7
7
  default_command :help
8
8
  never_trace!
9
9
 
10
- require_relative 'clouds'
11
- command 'clouds' do |c|
12
- c.syntax = 'qtc-cli clouds'
13
- c.description = 'List all clouds'
14
- c.action do |args, options|
15
- Qtc::Cli::Clouds.new.list
16
- end
17
- end
18
-
19
- command 'login' do |c|
20
- c.syntax = 'qtc-cli login'
21
- c.description = 'Login to Qt Cloud Services'
22
- c.action do |args, options|
23
- Qtc::Cli::Clouds.new.login
24
- end
25
- end
26
-
27
- command 'logout' do |c|
28
- c.syntax = 'qtc-cli logout'
29
- c.description = 'Logout from Qt Cloud Services'
30
- c.action do |args, options|
31
- Qtc::Cli::Clouds.new.logout
32
- end
33
- end
34
-
10
+ require_relative 'platform/commands'
35
11
  require_relative 'eds/commands'
36
12
  require_relative 'mar/commands'
@@ -2,6 +2,7 @@ require_relative 'apps'
2
2
  require_relative 'domains'
3
3
  require_relative 'ssl_certificates'
4
4
  require_relative 'env'
5
+ require_relative 'repository'
5
6
 
6
7
  command 'mar list' do |c|
7
8
  c.syntax = 'qtc-cli mar list'
@@ -145,3 +146,23 @@ command 'mar ssl:remove' do |c|
145
146
  Qtc::Cli::Mar::SslCertificates.new.destroy(options)
146
147
  end
147
148
  end
149
+
150
+ command 'mar repo:purge_cache' do |c|
151
+ c.syntax = 'qtc-cli mar repo:purge_cache'
152
+ c.description = 'Delete remote repository build cache contents'
153
+ c.option '--app APP', String, 'App instance id'
154
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
155
+ c.action do |args, options|
156
+ Qtc::Cli::Mar::Repository.new.purge_cache(options)
157
+ end
158
+ end
159
+
160
+ command 'mar repo:reset' do |c|
161
+ c.syntax = 'qtc-cli mar repo:reset'
162
+ c.description = 'Reset remote git repository'
163
+ c.option '--app APP', String, 'App instance id'
164
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
165
+ c.action do |args, options|
166
+ Qtc::Cli::Mar::Repository.new.reset(options)
167
+ end
168
+ end
@@ -0,0 +1,26 @@
1
+ require_relative 'base'
2
+
3
+ module Qtc
4
+ module Cli
5
+ class Mar::Repository < Mar::Base
6
+
7
+ def purge_cache(options)
8
+ instance_id = resolve_instance_id(options)
9
+ instance_data = instance_info(instance_id)
10
+ if instance_data
11
+ token = instance_data['authorizations'][0]['access_token']
12
+ client.delete("/apps/#{instance_id}/build_cache", nil, {}, {'Authorization' => "Bearer #{token}"})
13
+ end
14
+ end
15
+
16
+ def reset(options)
17
+ instance_id = resolve_instance_id(options)
18
+ instance_data = instance_info(instance_id)
19
+ if instance_data
20
+ token = instance_data['authorizations'][0]['access_token']
21
+ client.delete("/apps/#{instance_id}/repository", nil, {}, {'Authorization' => "Bearer #{token}"})
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -7,8 +7,8 @@ module Qtc
7
7
 
8
8
 
9
9
  def create(options)
10
- raise ArgumentError.new("--key=#{opts.key} is not a file") unless File.exists(opts.key)
11
- raise ArgumentError.new("--cert=#{opts.cert} is not a file") unless File.exists(opts.cert)
10
+ raise ArgumentError.new("--key=#{options.key} is not a file") unless File.exists?(File.expand_path(options.key))
11
+ raise ArgumentError.new("--cert=#{options.cert} is not a file") unless File.exists?(File.expand_path(options.cert))
12
12
 
13
13
  instance_id = resolve_instance_id(options)
14
14
  instance_data = instance_info(instance_id)
@@ -16,8 +16,8 @@ module Qtc
16
16
  token = instance_data['authorizations'][0]['access_token']
17
17
  data = {
18
18
  name: instance_id,
19
- privateKey: File.read(opts.key),
20
- certificateBody: File.read(opts.cert)
19
+ privateKey: File.read(File.expand_path(options.key)),
20
+ certificateBody: File.read(File.expand_path(options.cert))
21
21
  }
22
22
  client.post("/apps/#{instance_id}/ssl_certificate", data, {}, {'Authorization' => "Bearer #{token}"})
23
23
  end
@@ -0,0 +1,32 @@
1
+ require 'qtc/client'
2
+ require_relative '../common'
3
+
4
+ module Qtc::Cli::Platform
5
+ class Clouds
6
+ include Qtc::Cli::Common
7
+
8
+ def list
9
+ accounts = platform_client.get('/user/accounts')
10
+ accounts['results'].each do |account|
11
+ print color("~ #{account['name']} (#{account['id']})", :bold)
12
+ end
13
+ end
14
+
15
+ def login
16
+ pass = password("Personal Access Token (copy from https://console.qtcloudservices.com/#/user/profile):")
17
+ inifile['platform']['token'] = pass
18
+
19
+ response = platform_client(pass).get('/user/accounts', {}) rescue nil
20
+ if response
21
+ inifile.save(filename: ini_filename)
22
+ else
23
+ print color('Invalid Personal Access Token', :red)
24
+ end
25
+ end
26
+
27
+ def logout
28
+ inifile['platform'].delete('token')
29
+ inifile.save(filename: ini_filename)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,57 @@
1
+ require_relative 'clouds'
2
+ require_relative 'user'
3
+ require_relative 'ssh_keys'
4
+
5
+ module Qtc::Cli::Platform
6
+ end
7
+
8
+ command 'clouds' do |c|
9
+ c.syntax = 'qtc-cli clouds'
10
+ c.description = 'List all clouds'
11
+ c.action do |args, options|
12
+ Qtc::Cli::Platform::Clouds.new.list
13
+ end
14
+ end
15
+
16
+ command 'login' do |c|
17
+ c.syntax = 'qtc-cli login'
18
+ c.description = 'Login to Qt Cloud Services'
19
+ c.action do |args, options|
20
+ Qtc::Cli::Platform::User.new.login
21
+ end
22
+ end
23
+
24
+ command 'logout' do |c|
25
+ c.syntax = 'qtc-cli logout'
26
+ c.description = 'Logout from Qt Cloud Services'
27
+ c.action do |args, options|
28
+ Qtc::Cli::Platform::User.new.logout
29
+ end
30
+ end
31
+
32
+ command 'ssh-keys' do |c|
33
+ c.syntax = 'qtc-cli ssh-keys'
34
+ c.description = 'List ssh keys'
35
+ c.action do |args, options|
36
+ Qtc::Cli::Platform::SshKeys.new.list
37
+ end
38
+ end
39
+
40
+ command 'ssh-keys:add' do |c|
41
+ c.syntax = 'qtc-cli ssh-keys:add'
42
+ c.description = 'Add ssh key'
43
+ c.option '--name NAME', String, 'SSH key name'
44
+ c.option '--key KEY', String, 'Path to SSH public key file'
45
+ c.action do |args, options|
46
+ Qtc::Cli::Platform::SshKeys.new.create(options)
47
+ end
48
+ end
49
+
50
+ command 'ssh-keys:remove' do |c|
51
+ c.syntax = 'qtc-cli ssh-keys:remove'
52
+ c.description = 'Add ssh key'
53
+ c.option '--name NAME', String, 'SSH key name'
54
+ c.action do |args, options|
55
+ Qtc::Cli::Platform::SshKeys.new.destroy(options)
56
+ end
57
+ end
@@ -0,0 +1,41 @@
1
+ require 'qtc/client'
2
+ require_relative '../common'
3
+
4
+ module Qtc::Cli::Platform
5
+ class SshKeys
6
+ include Qtc::Cli::Common
7
+
8
+ def list
9
+ response = platform_client.get('/user/ssh_keys')
10
+ response['results'].each do |ssh_key|
11
+ say "~ #{ssh_key['name']}"
12
+ end
13
+ end
14
+
15
+ def create(options)
16
+ raise ArgumentError.new('--name is required') if options.name.nil?
17
+ raise ArgumentError.new('--key is required') if options.key.nil?
18
+ unless File.exists?(options.key)
19
+ raise ArgumentError.new("#{options.key} does not exist")
20
+ end
21
+
22
+ data = {
23
+ name: options.name,
24
+ key: File.read(options.key)
25
+ }
26
+
27
+ platform_client.post('/user/ssh_keys', data)
28
+ end
29
+
30
+ def destroy(options)
31
+ raise ArgumentError.new('--name is required') if options.name.nil?
32
+ response = platform_client.get('/user/ssh_keys')
33
+ matches = response['results'].select{|r| r['name'] == options.name}
34
+ if matches.size == 0
35
+ raise ArgumentError.new("SSH key with name #{options.name} does not exist")
36
+ else
37
+ platform_client.delete("/user/ssh_keys/#{matches[0]['id']}")
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,25 @@
1
+ require 'qtc/client'
2
+ require_relative '../common'
3
+
4
+ module Qtc::Cli:Platform
5
+ class User
6
+ include Qtc::Cli::Common
7
+
8
+ def login
9
+ pass = password("Personal Access Token (copy from https://console.qtcloudservices.com/#/user/profile):")
10
+ inifile['platform']['token'] = pass
11
+
12
+ response = platform_client(pass).get('/user/accounts', {}) rescue nil
13
+ if response
14
+ inifile.save(filename: ini_filename)
15
+ else
16
+ print color('Invalid Personal Access Token', :red)
17
+ end
18
+ end
19
+
20
+ def logout
21
+ inifile['platform'].delete('token')
22
+ inifile.save(filename: ini_filename)
23
+ end
24
+ end
25
+ end
data/lib/qtc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qtc
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qtc-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Kolehmainen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-04 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -151,7 +151,6 @@ files:
151
151
  - Rakefile
152
152
  - bin/qtc-cli
153
153
  - lib/qtc-sdk.rb
154
- - lib/qtc/cli/clouds.rb
155
154
  - lib/qtc/cli/commands.rb
156
155
  - lib/qtc/cli/common.rb
157
156
  - lib/qtc/cli/eds/base.rb
@@ -162,7 +161,12 @@ files:
162
161
  - lib/qtc/cli/mar/commands.rb
163
162
  - lib/qtc/cli/mar/domains.rb
164
163
  - lib/qtc/cli/mar/env.rb
164
+ - lib/qtc/cli/mar/repository.rb
165
165
  - lib/qtc/cli/mar/ssl_certificates.rb
166
+ - lib/qtc/cli/platform/clouds.rb
167
+ - lib/qtc/cli/platform/commands.rb
168
+ - lib/qtc/cli/platform/ssh_keys.rb
169
+ - lib/qtc/cli/platform/user.rb
166
170
  - lib/qtc/client.rb
167
171
  - lib/qtc/eds/client.rb
168
172
  - lib/qtc/eds/collection.rb
@@ -1,34 +0,0 @@
1
- require 'qtc/client'
2
- require_relative 'common'
3
-
4
- module Qtc
5
- module Cli
6
- class Clouds
7
- include Common
8
-
9
- def list
10
- accounts = platform_client.get('/user/accounts')
11
- accounts['results'].each do |account|
12
- print color("~ #{account['name']} (#{account['id']})", :bold)
13
- end
14
- end
15
-
16
- def login
17
- pass = password("Personal Access Token (copy from https://console.qtcloudservices.com/#/user/profile):")
18
- inifile['platform']['token'] = pass
19
-
20
- response = platform_client(pass).get('/user/accounts', {}) rescue nil
21
- if response
22
- inifile.save(filename: ini_filename)
23
- else
24
- print color('Invalid Personal Access Token', :red)
25
- end
26
- end
27
-
28
- def logout
29
- inifile['platform'].delete('token')
30
- inifile.save(filename: ini_filename)
31
- end
32
- end
33
- end
34
- end