train-kubernetes 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/train-kubernetes/connection.rb +10 -1
- data/lib/train-kubernetes/kubectl_client.rb +34 -0
- data/lib/train-kubernetes/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8986e6c4d497daf88599d830bcad43f9206936666311c6c0c0fab15002e41985
|
4
|
+
data.tar.gz: d1c56b619bceddf1c957ae6b29dfebfa583177202c9f6412616d519ee9e2ad26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2cc0de3cded1306ef5edd69c47b8c66ee49dfd517ec9f50223d152c08debe4e01ed95d9d2d8714bf7dd30865b45d9db86422e284ec0ae1a7ba271495de9a03a
|
7
|
+
data.tar.gz: 8399e9ab6d48cbd741ff42208ca400a7e91f7b86bd76f0c4593b7e95c2c7daecc47135fead6faf0dd839e3cbe5bc2be2ed8cd4e7e5f4a998eed58be94eeb2d4d
|
data/README.md
CHANGED
@@ -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
|
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.
|
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:
|
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
|