kubeclient_exec 0.1.2 → 0.1.3
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 +4 -4
- data/lib/kubeclient_exec/copy/copy.rb +43 -10
- data/lib/kubeclient_exec/execute/executor.rb +14 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17b3e2d61714b926cddbdd6735e6f6e068a32831313753597a2d05fcf4de6eb0
|
4
|
+
data.tar.gz: 03b121f120609632f793217d42e7f1cab6b95c8655086fa68a7ed28e9b9e15e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33986e59d05b7c4cf4a0e1c98bc97b7c227689da60cb6932176ac2dea8ce35fe26b1dfe1802cb1435fcb7ec10fb203abaacaa3747a666b932659c03ab017c116
|
7
|
+
data.tar.gz: d37fcd4f1e3cf30449a8b8a73c0084c6f202d6a12b0599d394ecca3d5f9bbb14207077b3413522282d3ae3286834114cf99b293f8fac03d4df782b246930d438
|
@@ -42,13 +42,22 @@ module KubeclientExec
|
|
42
42
|
|
43
43
|
if copy_file
|
44
44
|
exec_pod("tar xf - -C #{remote_path.split('/')[0...-1].join('/')}", name, namespace, options: { tty: false }.merge!(options)) do |executor|
|
45
|
-
|
45
|
+
chunks = split_string_into_chunks(tar_file.string, 1024 * 1024) # 1MB
|
46
|
+
chunks.each do |chunk|
|
47
|
+
executor.write(chunk)
|
48
|
+
end
|
46
49
|
|
47
50
|
# Feels like there should be a better way for this
|
51
|
+
stopping = false
|
48
52
|
EM.add_periodic_timer(0.1) do
|
49
|
-
if executor.done?
|
53
|
+
if executor.done? && !stopping
|
54
|
+
stopping = true
|
50
55
|
executor.stop
|
51
56
|
end
|
57
|
+
|
58
|
+
if executor.ready_state == 3
|
59
|
+
EM.stop_event_loop
|
60
|
+
end
|
52
61
|
end
|
53
62
|
end
|
54
63
|
else
|
@@ -56,10 +65,16 @@ module KubeclientExec
|
|
56
65
|
executor.write(tar_file.string)
|
57
66
|
|
58
67
|
# Feels like there should be a better way for this
|
68
|
+
stopping = false
|
59
69
|
EM.add_periodic_timer(0.1) do
|
60
|
-
if executor.done?
|
70
|
+
if executor.done? && !stopping
|
71
|
+
stopping = true
|
61
72
|
executor.stop
|
62
73
|
end
|
74
|
+
|
75
|
+
if executor.ready_state == 3
|
76
|
+
EM.stop_event_loop
|
77
|
+
end
|
63
78
|
end
|
64
79
|
end
|
65
80
|
end
|
@@ -70,22 +85,40 @@ module KubeclientExec
|
|
70
85
|
|
71
86
|
exec_pod("tar cf - #{remote_path}", name, namespace, options: { tty: false }.merge!(options)) do |executor|
|
72
87
|
count = 0
|
88
|
+
content = ''
|
73
89
|
|
74
90
|
executor.on_stdout do |data|
|
75
|
-
if count
|
76
|
-
|
77
|
-
untar(StringIO.new(data), local_path)
|
78
|
-
elsif local_path == :single_result
|
79
|
-
result = single_untar(StringIO.new(data))
|
80
|
-
end
|
81
|
-
executor.stop
|
91
|
+
if count >= 1
|
92
|
+
content += data
|
82
93
|
end
|
83
94
|
|
84
95
|
count += 1
|
85
96
|
end
|
97
|
+
|
98
|
+
executor.on_close do
|
99
|
+
if local_path.is_a? String
|
100
|
+
untar(StringIO.new(content), local_path)
|
101
|
+
elsif local_path == :single_result
|
102
|
+
result = single_untar(StringIO.new(content))
|
103
|
+
end
|
104
|
+
end
|
86
105
|
end
|
87
106
|
|
88
107
|
result
|
89
108
|
end
|
109
|
+
|
110
|
+
private
|
111
|
+
def split_string_into_chunks(string, chunk_size)
|
112
|
+
chunks = []
|
113
|
+
start_index = 0
|
114
|
+
|
115
|
+
while start_index < string.length
|
116
|
+
chunk = string[start_index, chunk_size]
|
117
|
+
chunks << chunk
|
118
|
+
start_index += chunk_size
|
119
|
+
end
|
120
|
+
|
121
|
+
chunks
|
122
|
+
end
|
90
123
|
end
|
91
124
|
end
|
@@ -55,8 +55,12 @@ module KubeclientExec
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def stop
|
58
|
-
@ws.
|
58
|
+
@ws.instance_variable_get(:@stream).close_connection_after_writing
|
59
59
|
@on_close.call if @on_close
|
60
|
+
end
|
61
|
+
|
62
|
+
def stop!
|
63
|
+
stop
|
60
64
|
EM.stop_event_loop
|
61
65
|
end
|
62
66
|
|
@@ -64,6 +68,10 @@ module KubeclientExec
|
|
64
68
|
@ws.instance_variable_get(:@driver).instance_variable_get(:@queue).empty?
|
65
69
|
end
|
66
70
|
|
71
|
+
def ready_state
|
72
|
+
@ws.ready_state
|
73
|
+
end
|
74
|
+
|
67
75
|
private
|
68
76
|
def setup
|
69
77
|
@ws = Faye::WebSocket::Client.new(@url, nil, {
|
@@ -73,12 +81,13 @@ module KubeclientExec
|
|
73
81
|
cert_chain_file: @kubeclient_options[:tls][:cert_chain_file],
|
74
82
|
private_key_file: @kubeclient_options[:tls][:private_key_file],
|
75
83
|
verify_peer: @kubeclient_options[:tls][:verify_peer],
|
76
|
-
}
|
84
|
+
},
|
85
|
+
max_length: 2**32,
|
77
86
|
})
|
78
87
|
|
79
88
|
@ws.on(:message) do |msg|
|
80
89
|
if msg.type == :close
|
81
|
-
stop
|
90
|
+
stop!
|
82
91
|
return
|
83
92
|
end
|
84
93
|
|
@@ -91,7 +100,7 @@ module KubeclientExec
|
|
91
100
|
if @options[:mode] == :adhoc
|
92
101
|
@last_stdout = 1 if type == EXEC_STDOUT
|
93
102
|
@last_stderr = 1 if type == EXEC_STDERR || EXEC_DCKERR
|
94
|
-
stop
|
103
|
+
stop!
|
95
104
|
end
|
96
105
|
end
|
97
106
|
|
@@ -112,7 +121,7 @@ module KubeclientExec
|
|
112
121
|
end
|
113
122
|
|
114
123
|
@ws.on(:close) do
|
115
|
-
stop
|
124
|
+
stop!
|
116
125
|
end
|
117
126
|
|
118
127
|
@ws.on(:open) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubeclient_exec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wout Ceulemans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kubeclient
|