kontena-plugin-cloud 1.1.0 → 1.1.1

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: 98fd5d4936d0b4d5b4ad2d5679c7b83414b24a79
4
- data.tar.gz: 5f819102b0986dd1c5dcdc141bf7be1646316cd1
3
+ metadata.gz: 5ae8fbe7ad9b70e0f0bc5c56b841dbc57991b245
4
+ data.tar.gz: a9663fc54506816ac95156e46c86ed401bab7e7b
5
5
  SHA512:
6
- metadata.gz: 4dedac3e0968c4f84c9d54a4d8f41e4ab4445f239142d32da653be42b675903e2a57237ec909c8e09ab78b200a01c7ee0407dae9fc943d97d632d1610cae8924
7
- data.tar.gz: 1be0dc1b7c1c958b865febf435982009ce7d335867028b24fa6c4d3503c8717bb22f0856cd03466681d848b5277e9e80be30efc77b8edfb08b7b4c4c430e38c3
6
+ metadata.gz: d34d7bafe586d8dc217210bb6f1209501da31ddc9ff7da86cd730b013a589670825bc65c02b62e919f7d1fc13cf9d43b4e3f0b883bb48eeb01eef5ac272c4a90
7
+ data.tar.gz: 73db780fb7f58fef28c64060d04d809adbc8ce0e7eef29b8b03e64487dc465a8e83f42422319732882567dccf5878228b00140c17659ac39a8a2c24341bf40b9
@@ -1,7 +1,7 @@
1
1
  module Kontena
2
2
  module Plugin
3
3
  module Cloud
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.1"
5
5
 
6
6
  module Organization
7
7
  module User; end
@@ -78,8 +78,12 @@ module Kontena::Plugin::Cloud::Platform::Common
78
78
  !self.config.find_server_by(name: name).nil?
79
79
  end
80
80
 
81
- def find_platform_by_name(name, org)
82
- if platform = cached_platforms.find{|p| p.name == name && p.organization == org }
81
+ # @param name [String]
82
+ # @param org [String]
83
+ # @param cache [Boolean]
84
+ # @return [Kontena::Cli::Models::Platform, NilClass]
85
+ def find_platform_by_name(name, org, cache = true)
86
+ if cache && platform = cached_platforms.find{|p| p.name == name && p.organization == org }
83
87
  platform
84
88
  else
85
89
  data = cloud_client.get("/organizations/#{org}/platforms/#{name}")['data']
@@ -8,7 +8,7 @@ class Kontena::Plugin::Cloud::Platform::CreateCommand < Kontena::Command
8
8
  parameter "[NAME]", "Platform name"
9
9
 
10
10
  option ['--organization', '--org'], 'ORG', 'Organization name', environment_variable: 'KONTENA_ORGANIZATION'
11
- option ['--region'], 'region', 'Region (us-east, eu-west)'
11
+ option ['--region'], 'region', 'Region (us-east-1, eu-west-1)'
12
12
  option ['--initial-size', '-i'], 'SIZE', 'Initial size (number of nodes) for platform'
13
13
  option '--[no-]use', :flag, 'Switch to use created platform', default: true
14
14
  option '--version', 'VERSION', 'Platform version', visible: false
@@ -13,32 +13,39 @@ class Kontena::Plugin::Cloud::Platform::UpgradeCommand < Kontena::Command
13
13
  def execute
14
14
  require_platform(name)
15
15
 
16
+ to_version = self.version
16
17
  platform = find_platform_by_name(current_platform, current_organization)
17
- unless version
18
- version = prompt_version(platform)
19
- if Gem::Version.new(version) < Gem::Version.new(platform.version)
20
- exit_with_error "Dowgrade is not supported"
18
+ unless to_version
19
+ to_version = prompt_version(platform)
20
+ if Gem::Version.new(to_version) < Gem::Version.new(platform.version)
21
+ exit_with_error "Downgrade is not supported"
21
22
  end
22
23
  end
23
24
  data = {
24
25
  attributes: {
25
26
  name: platform.name,
26
- version: platform.version
27
+ version: to_version
27
28
  }
28
29
  }
29
- cloud_client.put("/organizations/#{current_organization}/platforms/#{platform.name}", { data: data })
30
+ spinner "Upgrading platform #{pastel.cyan(name)} to version #{to_version}" do
31
+ cloud_client.put("/organizations/#{current_organization}/platforms/#{platform.name}", { data: data })
32
+ while platform.version != to_version do
33
+ sleep 5
34
+ platform = find_platform_by_name(platform.id, current_organization, false)
35
+ end
36
+ end
30
37
  end
31
38
 
32
- # @param
39
+ # @param platform [Platform]
33
40
  def prompt_version(platform)
34
41
  versions = cloud_client.get("/platform_versions")['data']
35
42
 
36
43
  platform_version = Gem::Version.new(platform.version)
37
44
  versions = versions.select { |v| Gem::Version.new(v['id']) > platform_version }
38
45
 
39
- default_version = versions.find_index{ |v| v['id'] == platform.version } + 1
46
+ exit_with_error "Platform is already on the latest version" if versions.size == 0
47
+
40
48
  prompt.select("Upgrade to version:") do |menu|
41
- menu.default default_version
42
49
  versions.each do |v|
43
50
  menu.choice v['id']
44
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontena-plugin-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kontena, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-16 00:00:00.000000000 Z
11
+ date: 2017-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kontena-cli