knife-bastion 1.1.1 → 1.2.0

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: 07a201e08855df9b35ea48ed9cc65c177ca07dd1
4
- data.tar.gz: 847d377d8e45f2ac6bde7b605959016f0c0753fb
3
+ metadata.gz: 1b24716fc37c04b006176389326e4ec86c082c96
4
+ data.tar.gz: a5846efa9fdc348f6362ce22bcedc8a225509c4d
5
5
  SHA512:
6
- metadata.gz: 4ce9362c97eb7d2797f7bdf338e68c6f0be78893ae1b262f25439cb48c19e47238674f3417b2c8cfd9597d43e14f934bf8a0b6bcbe9017a3461aa0bfcb3e7d2a
7
- data.tar.gz: 5caf485251fefc458c98f0ce7cb77e5605d5e491e0d3e637c6057907d3f64c74ac9a52d52b4b7e0906e052e72abbf2971de6d38bde76e18bcad113f8cc0b6c82
6
+ metadata.gz: cd0ba2173642ef7a4d657a3526a5ed68d6106f572868c6e5e882071a4f9ea07b427b07fa54b3e52c0439642e63cbe607746d1587a35861a51e9d576260232ef3
7
+ data.tar.gz: a497fc9cd48866a20663ff1e097ef04857c5add9936c212e509869c428cd804dcbec61ae71c4c098585c0c79298a469a063edc2311124c6170e705999f0c86bc
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,8 @@
1
+ ## 1.2.0 (Development)
2
+
3
+ Features:
4
+ - Berkshelf now supports bastion (`berks upload`)
5
+
1
6
  ## 1.1.1 (September 27, 2016)
2
7
 
3
8
  Bugfixes:
@@ -1,4 +1,9 @@
1
- # Only activate socks proxy for Knife
1
+ # Activate socks proxy for Knife
2
2
  if defined?(Chef::Application::Knife)
3
3
  require_relative 'chef_socks_proxy'
4
4
  end
5
+
6
+ # Activate socks proxy for Berkshelf
7
+ if defined?(Berkshelf)
8
+ require_relative 'berkshelf_socks_proxy'
9
+ end
@@ -0,0 +1,10 @@
1
+ require_relative 'client_proxy'
2
+
3
+ # Load socksify gem, required to make Chef work with SOCKS proxy
4
+ begin
5
+ require 'socksify'
6
+ rescue LoadError
7
+ puts HighLine.color("FATAL:", [:bold, :red]) + " Failed to load #{HighLine.color("socksify", [:bold, :magenta])} gem. Please run #{HighLine.color("bundle install", [:bold, :magenta])} to continue"
8
+ # Hard exit to skip Chef exception reporting
9
+ exit! 1
10
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'base_socks_proxy'
2
+
3
+ # Override `ridley_connection` method in `Berkshelf` to enable Socks proxy
4
+ # for the connection.
5
+ Berkshelf.module_eval do
6
+ class << self
7
+ alias_method :ridley_connection_without_bastion, :ridley_connection
8
+
9
+ def ridley_connection(*args, &block)
10
+ options = {
11
+ local_port: ::ChefConfig::Config[:knife][:bastion_local_port],
12
+ server_type: 'Chef',
13
+ }
14
+ proxy = ::KnifeBastion::ClientProxy.new(Berkshelf, options)
15
+ proxy.ridley_connection_without_bastion(*args, &block)
16
+ end
17
+ end
18
+ end
@@ -1,13 +1,4 @@
1
- require_relative 'client_proxy'
2
-
3
- # Load socksify gem, required to make Chef work with SOCKS proxy
4
- begin
5
- require 'socksify'
6
- rescue LoadError
7
- puts HighLine.color("FATAL:", [:bold, :red]) + " Failed to load #{HighLine.color("socksify", [:bold, :magenta])} gem. Please run #{HighLine.color("bundle install", [:bold, :magenta])} to continue"
8
- # Hard exit to skip Chef exception reporting
9
- exit! 1
10
- end
1
+ require_relative 'base_socks_proxy'
11
2
 
12
3
  # Override `http_client` method in `Chef::HTTP` to return proxy object instead
13
4
  # of normal client object.
@@ -21,12 +12,7 @@ Chef::HTTP.class_eval do
21
12
  client = http_client_without_bastion(*args)
22
13
  options = {
23
14
  local_port: ::Chef::Config[:knife][:bastion_local_port],
24
- error_handler: -> (_) {
25
- puts ::HighLine.color("WARNING:", [:bold, :red]) + " Failed to contact Chef server!"
26
- puts "You might need to start bastion connection with #{::HighLine.color("knife bastion start", [:bold, :magenta])} to access Chef."
27
- puts
28
- raise
29
- }
15
+ server_type: 'Chef',
30
16
  }
31
17
  KnifeBastion::ClientProxy.new(client, options)
32
18
  end
@@ -15,7 +15,8 @@ module KnifeBastion
15
15
  ::Errno::ECONNREFUSED,
16
16
  ::Timeout::Error,
17
17
  ::OpenSSL::SSL::SSLError,
18
- ].freeze
18
+ defined?(::Berkshelf::ChefConnectionError) ? ::Berkshelf::ChefConnectionError : nil,
19
+ ].compact.freeze
19
20
 
20
21
  # Initializes an instance of the generic client proxy which sends all the
21
22
  # network traffic through the SOCKS proxy.
@@ -31,9 +32,14 @@ module KnifeBastion
31
32
  @client = client
32
33
 
33
34
  @local_port = options[:local_port] || 4443
35
+
36
+ server_type = ::HighLine.color("#{options[:server_type]} ", [:bold, :cyan]) if options[:server_type]
34
37
  @network_errors_handler = options[:error_handler] || -> (_) {
35
- ::Kernel.puts ::HighLine.color("WARNING:", [:bold, :red]) + " Failed to contact server!"
38
+ ::Kernel.puts
39
+ ::Kernel.puts '-' * 80
40
+ ::Kernel.puts ::HighLine.color("WARNING:", [:bold, :red]) + " Failed to contact #{server_type}server!"
36
41
  ::Kernel.puts "You might need to start bastion connection with #{::HighLine.color("knife bastion start", [:bold, :magenta])} to access server."
42
+ ::Kernel.puts '-' * 80
37
43
  ::Kernel.puts
38
44
  ::Kernel.raise
39
45
  }
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Bastion
3
- VERSION = "1.1.1"
3
+ VERSION = "1.2.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-bastion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmytro Shteflyuk
@@ -30,7 +30,7 @@ cert_chain:
30
30
  DHSQkPQADqf52XlDQ7I6fBAn6E2bH38Wvwpu593AvE02KRKqaK8XEtBBldE4d/It
31
31
  2ysZ/sPJras9LFb2MpjJNRCdXr3z2ed6QwuLnsyEfuk=
32
32
  -----END CERTIFICATE-----
33
- date: 2016-09-27 00:00:00.000000000 Z
33
+ date: 2017-08-02 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: chef
@@ -125,6 +125,8 @@ files:
125
125
  - lib/chef/knife/bastion_status.rb
126
126
  - lib/chef/knife/bastion_stop.rb
127
127
  - lib/knife-bastion/activate.rb
128
+ - lib/knife-bastion/base_socks_proxy.rb
129
+ - lib/knife-bastion/berkshelf_socks_proxy.rb
128
130
  - lib/knife-bastion/chef_socks_proxy.rb
129
131
  - lib/knife-bastion/client_proxy.rb
130
132
  - lib/knife-bastion/version.rb
@@ -148,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
150
  version: '0'
149
151
  requirements: []
150
152
  rubyforge_project:
151
- rubygems_version: 2.4.5.1
153
+ rubygems_version: 2.6.7
152
154
  signing_key:
153
155
  specification_version: 4
154
156
  summary: Access Chef securely via bastion server.
metadata.gz.sig CHANGED
@@ -1 +1,2 @@
1
- ��N�6���~[R�k��rʕ���B��>�NS*8�����l7���������,��,������Җr�W���d�X�1~�CGhy�F N��W~��NF��=l/K�!i�.kߖ��@��Qc*ʝ����.8� �QMw�ۨiҜG?��@Ɵ�4!�WEh�l��(d�h`�o��sL��A(%�ga!P��V'2�Yy�=nKT@��v�ç��Τ��ivm�F!U���Ԕ���r��S?��5�:���T)�L
1
+ }�-T5Z/6
2
+ �׬V�D�^,�M�J�F�}���D�w�#�����Qns�W�rEgƛ{����,��~_��?�S+�����o��͈7���P�O� �Z�q=u�`}���(��{�ʕ P��E�E��A �|����p�E���7�,��t�[ f��~