train-kubernetes 0.1.7 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8986e6c4d497daf88599d830bcad43f9206936666311c6c0c0fab15002e41985
4
- data.tar.gz: d1c56b619bceddf1c957ae6b29dfebfa583177202c9f6412616d519ee9e2ad26
3
+ metadata.gz: 7e4bbb998822377221a31b8839373f73d298d6f2bd4226300ff8428742ca247c
4
+ data.tar.gz: e87a4add57561718dc7780d20aa0741de23e9bc615108dd139609377edb4d05b
5
5
  SHA512:
6
- metadata.gz: e2cc0de3cded1306ef5edd69c47b8c66ee49dfd517ec9f50223d152c08debe4e01ed95d9d2d8714bf7dd30865b45d9db86422e284ec0ae1a7ba271495de9a03a
7
- data.tar.gz: 8399e9ab6d48cbd741ff42208ca400a7e91f7b86bd76f0c4593b7e95c2c7daecc47135fead6faf0dd839e3cbe5bc2be2ed8cd4e7e5f4a998eed58be94eeb2d4d
6
+ metadata.gz: dfd9ca8003441da0bb8abd13f6a5ceae755239f406201b76d94ec2088a07ea12cc29e2fbe0a7132e4e6745910752823c9753a3b17585b39de62e1a5527192c6c
7
+ data.tar.gz: c50d9c99fe60b9b51b71b789f7c233815cf0391a89d8ffa6bc2faaae3f5f74e416211400b02e273da1f8c4348f4e749ce368eba5148acefa91faf43a533610fc
@@ -1,6 +1,7 @@
1
1
  require 'train'
2
2
  require 'k8s-ruby'
3
3
  require 'train-kubernetes/platform'
4
+ require 'train-kubernetes/kubectl_client'
4
5
 
5
6
  module TrainPlugins
6
7
  module TrainKubernetes
@@ -9,8 +10,9 @@ module TrainPlugins
9
10
 
10
11
  def initialize(options)
11
12
  super(options)
12
- @pod = options[:pod]
13
+ @pod = options[:pod] || options[:path]&.gsub('/', '')
13
14
  @container = options[:container]
15
+ @namespace = options[:namespace] || options[:host]
14
16
  parse_kubeconfig
15
17
  connect
16
18
  end
@@ -39,10 +41,13 @@ module TrainPlugins
39
41
 
40
42
  private
41
43
 
42
- attr_reader :pod, :container
44
+ attr_reader :pod, :container, :namespace
43
45
 
44
- def run_command_via_connection(cmd, &_data_handler)
45
- KubectlClient.new(pod: pod, container: container).execute(cmd)
46
+ def run_command_via_connection(cmd, opts = {}, &_data_handler)
47
+ KubectlClient.new(pod: opts[:pod] || pod,
48
+ container: opts[:container] || container,
49
+ namespace: opts[:namespace] || namespace)
50
+ .execute(cmd)
46
51
  end
47
52
  end
48
53
  end
@@ -3,10 +3,13 @@ require 'mixlib/shellout'
3
3
  module TrainPlugins
4
4
  module TrainKubernetes
5
5
  class KubectlClient
6
- attr_reader :pod, :container
7
- def initialize(pod:, container: nil)
6
+ attr_reader :pod, :container, :namespace
7
+ DEFAULT_NAMESPACE = 'default'.freeze
8
+
9
+ def initialize(pod:, namespace: nil, container: nil)
8
10
  @pod = pod
9
11
  @container = container
12
+ @namespace = namespace || DEFAULT_NAMESPACE
10
13
  end
11
14
 
12
15
  def execute(command, stdin: true, tty: true)
@@ -22,13 +25,15 @@ module TrainPlugins
22
25
  end
23
26
 
24
27
  def build_instruction(command, stdin, tty)
25
- ["kubectl exec"].tap do |arr|
28
+ ['kubectl exec'].tap do |arr|
26
29
  arr << '--stdin' if stdin
27
- arr << "--tty" if tty
28
30
  arr << pod if pod
31
+ arr << '-n'
32
+ arr << namespace
33
+ arr << '--'
29
34
  arr << command
30
35
  end.join("\s")
31
36
  end
32
37
  end
33
38
  end
34
- end
39
+ end
@@ -5,6 +5,9 @@ module TrainPlugins
5
5
  class Transport < Train.plugin(1)
6
6
  name 'k8s'
7
7
  option :kubeconfig, default: ENV['KUBECONFIG'] || '~/.kube/config'
8
+ option :pod, default: nil
9
+ option :container, default: nil
10
+ option :namespace, default: nil
8
11
  def connection(_instance_opts = nil)
9
12
  @connection ||= TrainPlugins::TrainKubernetes::Connection.new(@options)
10
13
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module TrainPlugins
7
7
  module TrainKubernetes
8
- VERSION = '0.1.7'.freeze
8
+ VERSION = '0.1.10'.freeze
9
9
  end
10
10
  end
@@ -44,6 +44,7 @@ Gem::Specification.new do |spec|
44
44
  # Do not list inspec as a dependency of the train plugin.
45
45
 
46
46
  # All plugins should mention train, > 1.4
47
- spec.add_dependency 'k8s-ruby', '~> 0.10'
47
+ # pinning k8s-ruby to 0.10.5 to avoid broken dry-type gem upgrades from k8s-ruby
48
+ spec.add_dependency 'k8s-ruby', '0.10.5'
48
49
  spec.add_dependency 'train', '~> 3.0'
49
50
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: train-kubernetes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Geesaman
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-08 00:00:00.000000000 Z
11
+ date: 2022-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: k8s-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0.10'
19
+ version: 0.10.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '0.10'
26
+ version: 0.10.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: train
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -59,7 +59,7 @@ homepage: https://github.com/bgeesaman/train-kubernetes
59
59
  licenses:
60
60
  - Apache-2.0
61
61
  metadata: {}
62
- post_install_message:
62
+ post_install_message:
63
63
  rdoc_options: []
64
64
  require_paths:
65
65
  - lib
@@ -74,8 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 3.0.8
78
- signing_key:
77
+ rubygems_version: 3.1.4
78
+ signing_key:
79
79
  specification_version: 4
80
80
  summary: Train Kubernetes
81
81
  test_files: []