kontena-plugin-packet 0.2.6 → 0.2.7.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kontena/machine/packet/master_provisioner.rb +1 -1
- data/lib/kontena/machine/packet/packet_common.rb +3 -5
- data/lib/kontena/plugin/packet/master/create_command.rb +2 -1
- data/lib/kontena/plugin/packet/nodes/create_command.rb +2 -1
- data/lib/kontena/plugin/packet/ssh_key_option.rb +36 -0
- data/lib/kontena/plugin/packet.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56396a2bbd0d2d2f968939be04c0800272f70a2f
|
4
|
+
data.tar.gz: d0fc65bf26b7dbea0e36a31b958c71e90f85de61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 823613749101cfeeac9b5661e98066fb792217629f77dc8cdeb32efe4f063b1116b07776c7ded11f427c5663ee44ae40780c8edbc3a26920124b7b1087159a00
|
7
|
+
data.tar.gz: a321d9ad007d404d9ce0099f476d0c1e52add917abed5bf84bc9e897384d8dbdedcee94dc44eff15b028e7a795a4beac41dd38272dd0672659dfde5b8dfa611b
|
@@ -22,7 +22,7 @@ module Kontena
|
|
22
22
|
abort('Operating system coreos_stable does not exist in Packet') unless os = find_os('coreos_stable')
|
23
23
|
abort('Device type does not exist in Packet') unless plan = find_plan(opts[:plan])
|
24
24
|
|
25
|
-
check_or_create_ssh_key(
|
25
|
+
check_or_create_ssh_key(opts[:ssh_key]) if opts[:ssh_key]
|
26
26
|
|
27
27
|
if opts[:ssl_cert]
|
28
28
|
abort('Invalid ssl cert') unless File.exists?(File.expand_path(opts[:ssl_cert]))
|
@@ -22,11 +22,9 @@ module Kontena
|
|
22
22
|
label.empty? ? "kontena-ssh-key-#{rand(1..9)}" : label
|
23
23
|
end
|
24
24
|
|
25
|
-
# @param [String]
|
26
|
-
def check_or_create_ssh_key(
|
27
|
-
|
28
|
-
abort('Ssh key file not readable') unless File.readable?(keyfile_path)
|
29
|
-
ssh_key = File.read(keyfile_path).strip
|
25
|
+
# @param [String] ssh_key SSH public key
|
26
|
+
def check_or_create_ssh_key(ssh_key)
|
27
|
+
return nil if ssh_key.nil?
|
30
28
|
create_ssh_key(ssh_key) unless ssh_key_exist?(ssh_key)
|
31
29
|
end
|
32
30
|
|
@@ -2,6 +2,7 @@ require 'kontena/plugin/packet/token_option'
|
|
2
2
|
require 'kontena/plugin/packet/project_option'
|
3
3
|
require 'kontena/plugin/packet/type_option'
|
4
4
|
require 'kontena/plugin/packet/facility_option'
|
5
|
+
require 'kontena/plugin/packet/ssh_key_option'
|
5
6
|
|
6
7
|
module Kontena::Plugin::Packet::Master
|
7
8
|
class CreateCommand < Kontena::Command
|
@@ -10,11 +11,11 @@ module Kontena::Plugin::Packet::Master
|
|
10
11
|
include Kontena::Plugin::Packet::ProjectOption
|
11
12
|
include Kontena::Plugin::Packet::TypeOption
|
12
13
|
include Kontena::Plugin::Packet::FacilityOption
|
14
|
+
include Kontena::Plugin::Packet::SshKeyOption
|
13
15
|
|
14
16
|
option "--name", "[NAME]", "Set master name"
|
15
17
|
option "--ssl-cert", "PATH", "SSL certificate file (optional)"
|
16
18
|
option "--billing", "BILLING", "Billing cycle", default: 'hourly'
|
17
|
-
option "--ssh-key", "PATH", "Path to ssh public key", default: File.join(Dir.home, '.ssh', 'id_rsa.pub')
|
18
19
|
option "--vault-secret", "VAULT_SECRET", "Secret key for Vault (optional)"
|
19
20
|
option "--vault-iv", "VAULT_IV", "Initialization vector for Vault (optional)"
|
20
21
|
option "--mongodb-uri", "URI", "External MongoDB uri (optional)"
|
@@ -2,6 +2,7 @@ require 'kontena/plugin/packet/token_option'
|
|
2
2
|
require 'kontena/plugin/packet/project_option'
|
3
3
|
require 'kontena/plugin/packet/type_option'
|
4
4
|
require 'kontena/plugin/packet/facility_option'
|
5
|
+
require 'kontena/plugin/packet/ssh_key_option'
|
5
6
|
|
6
7
|
module Kontena::Plugin::Packet::Nodes
|
7
8
|
class CreateCommand < Kontena::Command
|
@@ -11,11 +12,11 @@ module Kontena::Plugin::Packet::Nodes
|
|
11
12
|
include Kontena::Plugin::Packet::ProjectOption
|
12
13
|
include Kontena::Plugin::Packet::TypeOption
|
13
14
|
include Kontena::Plugin::Packet::FacilityOption
|
15
|
+
include Kontena::Plugin::Packet::SshKeyOption
|
14
16
|
|
15
17
|
parameter "[NAME]", "Node name"
|
16
18
|
|
17
19
|
option "--billing", "BILLING", "Billing cycle", default: 'hourly'
|
18
|
-
option "--ssh-key", "PATH", "Path to ssh public key", default: File.join(Dir.home, '.ssh', 'id_rsa.pub')
|
19
20
|
option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
|
20
21
|
|
21
22
|
def execute
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Kontena::Plugin::Packet
|
2
|
+
module SshKeyOption
|
3
|
+
|
4
|
+
DEFAULT_PATH = File.join(Dir.home, '.ssh', 'id_rsa.pub')
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.option "--ssh-key", "PATH", "Path to ssh public key", attribute_name: :ssh_key_path, default: DEFAULT_PATH
|
8
|
+
base.class_eval do
|
9
|
+
def ssh_key
|
10
|
+
if ssh_key_path
|
11
|
+
begin
|
12
|
+
return File.read(ssh_key_path).strip
|
13
|
+
rescue => ex
|
14
|
+
unless ssh_key_path == DEFAULT_PATH
|
15
|
+
raise ex
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'packet'
|
21
|
+
client = Packet::Client.new(self.token || (self.respond_to?(:default_token) && self.default_token))
|
22
|
+
|
23
|
+
keys = client.list_ssh_keys
|
24
|
+
|
25
|
+
if keys.empty?
|
26
|
+
prompt.ask('SSH public key: (enter an ssh key in OpenSSH format "ssh-xxx xxxxx key_name")') do |q|
|
27
|
+
q.validate /^ssh-rsa \S+ \S+$/
|
28
|
+
end
|
29
|
+
else
|
30
|
+
keys.first.key
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kontena-plugin-packet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7.rc1
|
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-
|
11
|
+
date: 2017-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kontena-cli
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/kontena/plugin/packet/nodes/restart_command.rb
|
99
99
|
- lib/kontena/plugin/packet/nodes/terminate_command.rb
|
100
100
|
- lib/kontena/plugin/packet/project_option.rb
|
101
|
+
- lib/kontena/plugin/packet/ssh_key_option.rb
|
101
102
|
- lib/kontena/plugin/packet/token_option.rb
|
102
103
|
- lib/kontena/plugin/packet/type_option.rb
|
103
104
|
- lib/kontena/plugin/packet_command.rb
|
@@ -117,9 +118,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
118
|
version: '0'
|
118
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
120
|
requirements:
|
120
|
-
- - "
|
121
|
+
- - ">"
|
121
122
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
123
|
+
version: 1.3.1
|
123
124
|
requirements: []
|
124
125
|
rubyforge_project:
|
125
126
|
rubygems_version: 2.4.5
|