train-kubernetes 0.1.4 → 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 +2 -2
- data/lib/train-kubernetes/connection.rb +11 -2
- data/lib/train-kubernetes/kubectl_client.rb +34 -0
- data/lib/train-kubernetes/version.rb +1 -1
- data/train-kubernetes.gemspec +2 -0
- metadata +8 -7
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
@@ -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
|
65
|
+
inspec plugin list
|
66
66
|
```
|
67
67
|
|
68
68
|
```
|
@@ -81,7 +81,7 @@ If you run into issues installing via `inspec plugin install train-kubernetes`,
|
|
81
81
|
|
82
82
|
* Try running `gem install train-kubernetes` before `inspec plugin install train-kubernetes`.
|
83
83
|
* Ensure the `~/.inspec/plugins.json` has `"0.1.3"` and not `"= 0.1.3"` for the `version` value. Modify it by hand if needed.
|
84
|
-
* Ensure you can cleanly install the `k8s-
|
84
|
+
* Ensure you can cleanly install the `k8s-ruby` gem version `0.10.4` or greater. e.g. `gem install k8s-ruby -v 0.10.4`
|
85
85
|
* Ensure that only one version of the `excon` gem is installed. e.g. `gem list | grep excon`. If you see two versions, `gem uninstall excon` and remove the older version.
|
86
86
|
|
87
87
|
## Reporting Issues
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'train'
|
2
|
-
require 'k8s-
|
2
|
+
require 'k8s-ruby'
|
3
3
|
require 'train-kubernetes/platform'
|
4
4
|
|
5
5
|
module TrainPlugins
|
@@ -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
|
data/train-kubernetes.gemspec
CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.homepage = 'https://github.com/bgeesaman/train-kubernetes'
|
23
23
|
spec.license = 'Apache-2.0'
|
24
24
|
|
25
|
+
spec.required_ruby_version = '>= 2.4'
|
26
|
+
|
25
27
|
# Though complicated-looking, this is pretty standard for a gemspec.
|
26
28
|
# It just filters what will actually be packaged in the gem (leaving
|
27
29
|
# out tests, etc)
|
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
|
-
autorequire:
|
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
|
@@ -58,7 +59,7 @@ homepage: https://github.com/bgeesaman/train-kubernetes
|
|
58
59
|
licenses:
|
59
60
|
- Apache-2.0
|
60
61
|
metadata: {}
|
61
|
-
post_install_message:
|
62
|
+
post_install_message:
|
62
63
|
rdoc_options: []
|
63
64
|
require_paths:
|
64
65
|
- lib
|
@@ -66,15 +67,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
67
|
requirements:
|
67
68
|
- - ">="
|
68
69
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
70
|
+
version: '2.4'
|
70
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
72
|
requirements:
|
72
73
|
- - ">="
|
73
74
|
- !ruby/object:Gem::Version
|
74
75
|
version: '0'
|
75
76
|
requirements: []
|
76
|
-
rubygems_version: 3.
|
77
|
-
signing_key:
|
77
|
+
rubygems_version: 3.0.8
|
78
|
+
signing_key:
|
78
79
|
specification_version: 4
|
79
80
|
summary: Train Kubernetes
|
80
81
|
test_files: []
|