kuber_kit 0.4.5 → 0.4.6

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: dfc1d29b7283361acaed01c9ddd08a29d121020c75af2d6ec7e4245d347021fb
4
- data.tar.gz: 7e9063497954963223629beaa6d6ec914851c5e8c9633fa35d50986a95149aec
3
+ metadata.gz: 2bcee9236bf3bc1938a2fa671e3d4a060ddf72a113a932365e5804bfc8c15b38
4
+ data.tar.gz: d452258ab40ad77ac5663c872be237032a80d138164b9e60d98d713fe8d5793f
5
5
  SHA512:
6
- metadata.gz: d0dd8904d21b8ca6648111856a6a5d8b4b3d1950a5db786f108f2906bdfc2388c6f515b4d833ce87f30f3c5098ebd1807aa0e3ef832903a4bec180b66788f3dc
7
- data.tar.gz: b9cb8446b31460a27571b8a91defbf7882ff0ecf1d8d97dd581edaa496d2f60dae58b4bd8bd6fad091c5448a16830cee48259821751211e4e6751d2128d88fe2
6
+ metadata.gz: e34e7f2d8106d941e911ce600c692bcc1332f7d16673151641900462cbab1238be707ebff787dbc40ea9f270b0a27543136439353b32b82e4a4d00ceb2f07ce2
7
+ data.tar.gz: 464be38573b8d6bc6fffc83292c0b80e37bfdb725ad367d8243243aed676d98464a43ec69f7a7283007783e0506863da5e78e80753953da9bff7b8f6dfec193c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kuber_kit (0.4.5)
4
+ kuber_kit (0.4.6)
5
5
  cli-ui
6
6
  contracts-lite
7
7
  dry-auto_inject
data/lib/kuber_kit.rb CHANGED
@@ -175,6 +175,10 @@ module KuberKit
175
175
  autoload :Inspectable, 'extensions/inspectable'
176
176
  end
177
177
 
178
+ module Kubernetes
179
+ autoload :ResourcesFetcher, 'kubernetes/resources_fetcher'
180
+ end
181
+
178
182
  module UI
179
183
  autoload :Interactive, 'ui/interactive'
180
184
  autoload :Simple, 'ui/simple'
@@ -2,6 +2,7 @@ class KuberKit::Actions::KubectlAttacher
2
2
  include KuberKit::Import[
3
3
  "shell.kubectl_commands",
4
4
  "shell.local_shell",
5
+ "kubernetes.resources_fetcher",
5
6
  "ui"
6
7
  ]
7
8
 
@@ -10,10 +11,8 @@ class KuberKit::Actions::KubectlAttacher
10
11
  kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
11
12
  deployer_namespace = KuberKit.current_configuration.deployer_namespace
12
13
 
13
- if !pod_name
14
- resources = kubectl_commands.get_resources(local_shell, "deployments", jsonpath: ".items[*].metadata.name")
15
- options = resources.split(" ").map{|d| "deploy/#{d}" }
16
- pod_name = ui.prompt("Please select deployment to attach", options)
14
+ if !pod_name
15
+ pod_name = resources_fetcher.call("attach")
17
16
  end
18
17
 
19
18
  kubectl_commands.exec(
@@ -2,6 +2,7 @@ class KuberKit::Actions::KubectlConsole
2
2
  include KuberKit::Import[
3
3
  "shell.kubectl_commands",
4
4
  "shell.local_shell",
5
+ "kubernetes.resources_fetcher",
5
6
  "ui"
6
7
  ]
7
8
 
@@ -11,9 +12,7 @@ class KuberKit::Actions::KubectlConsole
11
12
  deployer_namespace = KuberKit.current_configuration.deployer_namespace
12
13
 
13
14
  if !pod_name
14
- resources = kubectl_commands.get_resources(local_shell, "deployments", jsonpath: ".items[*].metadata.name")
15
- options = resources.split(" ").map{|d| "deploy/#{d}" }
16
- pod_name = ui.prompt("Please select deployment to attach", options)
15
+ pod_name = resources_fetcher.call("attach")
17
16
  end
18
17
 
19
18
  kubectl_commands.exec(
@@ -2,6 +2,7 @@ class KuberKit::Actions::KubectlDescribe
2
2
  include KuberKit::Import[
3
3
  "shell.kubectl_commands",
4
4
  "shell.local_shell",
5
+ "kubernetes.resources_fetcher",
5
6
  "ui"
6
7
  ]
7
8
 
@@ -11,7 +12,7 @@ class KuberKit::Actions::KubectlDescribe
11
12
  deployer_namespace = KuberKit.current_configuration.deployer_namespace
12
13
 
13
14
  if !resource_name
14
- resource_name = get_resource_name
15
+ resource_name = resources_fetcher.call("describe", include_ingresses: true, include_pods: true)
15
16
  end
16
17
 
17
18
  args = nil
@@ -32,25 +33,4 @@ class KuberKit::Actions::KubectlDescribe
32
33
 
33
34
  false
34
35
  end
35
-
36
- def get_resource_name
37
- deployments = kubectl_commands.get_resources(local_shell, "deployments", jsonpath: ".items[*].metadata.name")
38
- options = deployments.split(" ").map{|d| "deploy/#{d}" }
39
- options += ["ingresses", "pods"]
40
- option = ui.prompt("Please select resource to describe", options)
41
-
42
- if option == "ingresses"
43
- ingresses = kubectl_commands.get_resources(local_shell, "ingresses", jsonpath: ".items[*].metadata.name")
44
- options = ingresses.split(" ").map{|d| "ingresses/#{d}" }
45
- return ui.prompt("Please select ingress to describe", options)
46
- end
47
-
48
- if option == "pods"
49
- ingresses = kubectl_commands.get_resources(local_shell, "pods", jsonpath: ".items[*].metadata.name")
50
- options = ingresses.split(" ").map{|d| "pods/#{d}" }
51
- return ui.prompt("Please select pod to describe", options)
52
- end
53
-
54
- option
55
- end
56
36
  end
@@ -2,6 +2,7 @@ class KuberKit::Actions::KubectlLogs
2
2
  include KuberKit::Import[
3
3
  "shell.kubectl_commands",
4
4
  "shell.local_shell",
5
+ "kubernetes.resources_fetcher",
5
6
  "ui"
6
7
  ]
7
8
 
@@ -11,9 +12,7 @@ class KuberKit::Actions::KubectlLogs
11
12
  deployer_namespace = KuberKit.current_configuration.deployer_namespace
12
13
 
13
14
  if !pod_name
14
- deployments = kubectl_commands.get_resources(local_shell, "deployments", jsonpath: ".items[*].metadata.name")
15
- deploy_options = deployments.split(" ").map{|d| "deploy/#{d}" }
16
- pod_name = ui.prompt("Please select deployment to attach", deploy_options)
15
+ pod_name = resources_fetcher.call("attach")
17
16
  end
18
17
 
19
18
  args = nil
@@ -261,6 +261,10 @@ class KuberKit::Container
261
261
  KuberKit::ServiceReader::Reader.new
262
262
  end
263
263
 
264
+ register "kubernetes.resources_fetcher" do
265
+ KuberKit::Kubernetes::ResourcesFetcher.new
266
+ end
267
+
264
268
  register "ui" do
265
269
  if KuberKit.ui_mode == :debug
266
270
  KuberKit::UI::Debug.new
@@ -0,0 +1,41 @@
1
+ class KuberKit::Kubernetes::ResourcesFetcher
2
+ include KuberKit::Import[
3
+ "shell.kubectl_commands",
4
+ "shell.local_shell",
5
+ "ui"
6
+ ]
7
+
8
+ Contract String, KeywordArgs[
9
+ include_ingresses: Optional[Bool],
10
+ include_pods: Optional[Bool]
11
+ ] => Any
12
+ def call(action_name, include_ingresses: false, include_pods: false)
13
+ deployments = get_resources("deployments")
14
+ options = deployments.split(" ").map{|d| "deploy/#{d}" }
15
+ options << "ingresses" if include_ingresses
16
+ options << "pods" if include_pods
17
+ option = ui.prompt("Please select resource to #{action_name}", options)
18
+
19
+ if option == "ingresses" && include_ingresses
20
+ ingresses = get_resources("ingresses")
21
+ options = ingresses.split(" ").map{|d| "ingresses/#{d}" }
22
+ return ui.prompt("Please select ingress to #{action_name}", options)
23
+ end
24
+
25
+ if option == "pods" && include_pods
26
+ ingresses = get_resources("pods")
27
+ options = ingresses.split(" ").map{|d| "pods/#{d}" }
28
+ return ui.prompt("Please select pod to #{action_name}", options)
29
+ end
30
+
31
+ option
32
+ end
33
+
34
+ def get_resources(type)
35
+ kubectl_commands.get_resources(
36
+ local_shell, type,
37
+ jsonpath: ".items[*].metadata.name",
38
+ namespace: KuberKit.current_configuration.deployer_namespace
39
+ )
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuber_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Khaziev
@@ -273,6 +273,7 @@ files:
273
273
  - lib/kuber_kit/image_compiler/image_builder.rb
274
274
  - lib/kuber_kit/image_compiler/image_dependency_resolver.rb
275
275
  - lib/kuber_kit/image_compiler/version_tag_builder.rb
276
+ - lib/kuber_kit/kubernetes/resources_fetcher.rb
276
277
  - lib/kuber_kit/preprocessing/file_preprocessor.rb
277
278
  - lib/kuber_kit/preprocessing/text_preprocessor.rb
278
279
  - lib/kuber_kit/service_deployer/action_handler.rb