train-kubernetes 0.1.6 → 0.1.7

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: faf420c22d9eb580f5344f04af243d21b734195305b653ac60588a200b986557
4
- data.tar.gz: 631dbf7f1b8006cf0d41b4e11457e7821283b7d96bdecbbfbc1f3b4a2d5128bf
3
+ metadata.gz: 8986e6c4d497daf88599d830bcad43f9206936666311c6c0c0fab15002e41985
4
+ data.tar.gz: d1c56b619bceddf1c957ae6b29dfebfa583177202c9f6412616d519ee9e2ad26
5
5
  SHA512:
6
- metadata.gz: 54cefa2bf1f7e85fcd8a018dff9093c1de1a7bb20bceb123c595e439741f969baba9484f735f3bad7d39ad1a3e4d50cef1dea0265d064a257021801d1dc820d4
7
- data.tar.gz: 6b754a9da1e579667ee32b48f0b8a208a4ead1da47c5333e53d2ff95cc929a31792ad13368b27dd3ca170cb3050d11350801c3af196700d15f59425415152ac3
6
+ metadata.gz: e2cc0de3cded1306ef5edd69c47b8c66ee49dfd517ec9f50223d152c08debe4e01ed95d9d2d8714bf7dd30865b45d9db86422e284ec0ae1a7ba271495de9a03a
7
+ data.tar.gz: 8399e9ab6d48cbd741ff42208ca400a7e91f7b86bd76f0c4593b7e95c2c7daecc47135fead6faf0dd839e3cbe5bc2be2ed8cd4e7e5f4a998eed58be94eeb2d4d
data/README.md CHANGED
@@ -62,7 +62,7 @@ If it has the version set to `"= 0.1.3"`, modify it to `"0.1.3"` and save the fi
62
62
  Verify the plugin:
63
63
 
64
64
  ```
65
- inspec plugins list
65
+ inspec plugin list
66
66
  ```
67
67
 
68
68
  ```
@@ -9,7 +9,8 @@ module TrainPlugins
9
9
 
10
10
  def initialize(options)
11
11
  super(options)
12
-
12
+ @pod = options[:pod]
13
+ @container = options[:container]
13
14
  parse_kubeconfig
14
15
  connect
15
16
  end
@@ -35,6 +36,14 @@ module TrainPlugins
35
36
  kubeconfig_file = @options[:kubeconfig] if @options[:kubeconfig]
36
37
  @client = K8s::Client.config(K8s::Config.load_file(File.expand_path(kubeconfig_file)))
37
38
  end
39
+
40
+ private
41
+
42
+ attr_reader :pod, :container
43
+
44
+ def run_command_via_connection(cmd, &_data_handler)
45
+ KubectlClient.new(pod: pod, container: container).execute(cmd)
46
+ end
38
47
  end
39
48
  end
40
49
  end
@@ -0,0 +1,34 @@
1
+ require 'mixlib/shellout'
2
+
3
+ module TrainPlugins
4
+ module TrainKubernetes
5
+ class KubectlClient
6
+ attr_reader :pod, :container
7
+ def initialize(pod:, container: nil)
8
+ @pod = pod
9
+ @container = container
10
+ end
11
+
12
+ def execute(command, stdin: true, tty: true)
13
+ instruction = build_instruction(command, stdin, tty)
14
+ shell = Mixlib::ShellOut.new(instruction)
15
+ shell.run_command
16
+ end
17
+
18
+ private
19
+
20
+ def shell
21
+ @shell ||= Mixlib::ShellOut.new(instruction)
22
+ end
23
+
24
+ def build_instruction(command, stdin, tty)
25
+ ["kubectl exec"].tap do |arr|
26
+ arr << '--stdin' if stdin
27
+ arr << "--tty" if tty
28
+ arr << pod if pod
29
+ arr << command
30
+ end.join("\s")
31
+ end
32
+ end
33
+ end
34
+ end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module TrainPlugins
7
7
  module TrainKubernetes
8
- VERSION = '0.1.6'.freeze
8
+ VERSION = '0.1.7'.freeze
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: train-kubernetes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Geesaman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-08 00:00:00.000000000 Z
11
+ date: 2022-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: k8s-ruby
@@ -50,6 +50,7 @@ files:
50
50
  - README.md
51
51
  - lib/train-kubernetes.rb
52
52
  - lib/train-kubernetes/connection.rb
53
+ - lib/train-kubernetes/kubectl_client.rb
53
54
  - lib/train-kubernetes/platform.rb
54
55
  - lib/train-kubernetes/transport.rb
55
56
  - lib/train-kubernetes/version.rb