train-kubernetes 0.1.7 → 0.1.10
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e4bbb998822377221a31b8839373f73d298d6f2bd4226300ff8428742ca247c
|
4
|
+
data.tar.gz: e87a4add57561718dc7780d20aa0741de23e9bc615108dd139609377edb4d05b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
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
|
-
[
|
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
|
data/train-kubernetes.gemspec
CHANGED
@@ -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
|
-
|
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.
|
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-
|
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:
|
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:
|
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.
|
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: []
|