k8s-client 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/k8s-client +12 -0
- data/lib/k8s/api_client.rb +5 -4
- data/lib/k8s/client.rb +3 -2
- data/lib/k8s/client/version.rb +1 -1
- data/lib/k8s/error.rb +4 -0
- data/lib/k8s/resource_client.rb +5 -0
- 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: 0c52ed78175ae8e13a19fdc6a8e0140bd638f49e7120c7b8227bbfb23086487a
|
4
|
+
data.tar.gz: 43224378fdcb6d08636e346d8c79090e572957cf298d72b2fb6be1bb4a13c948
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb131b63d5a7ea82c0afbb0a32543ee60b13156c13f13f62b23ff9260491c26561e863c76495600f2db1ccf1cd51a956f9acc195d494a97f9e7e66b1764209cc
|
7
|
+
data.tar.gz: 71d19732db165ac68306d031981f95b4d1dda404ada3e6a2dca146b42c2b7bb427432e74c2192d673010d92668eefb046efd22782c9ba7f9e460cd685c4c2e9a
|
data/bin/k8s-client
CHANGED
@@ -10,6 +10,7 @@ Options = Struct.new(
|
|
10
10
|
:server,
|
11
11
|
:insecure_skip_tls_verify,
|
12
12
|
:prefetch_resources,
|
13
|
+
:list_resource_kinds,
|
13
14
|
:namespace,
|
14
15
|
:all_namespaces,
|
15
16
|
:label_selector,
|
@@ -76,6 +77,9 @@ parser = OptionParser.new do |parser|
|
|
76
77
|
parser.on('--prefetch-resources', TrueClass) do |bool|
|
77
78
|
options.prefetch_resources = bool
|
78
79
|
end
|
80
|
+
parser.on('--list-resource-kinds', TrueClass) do |bool|
|
81
|
+
options.list_resource_kinds = true
|
82
|
+
end
|
79
83
|
parser.on('-n', '--namespace=NAMESPACE') do |namespace|
|
80
84
|
options.namespace = namespace
|
81
85
|
end
|
@@ -171,6 +175,14 @@ if options.prefetch_resources
|
|
171
175
|
client.apis(prefetch_resources: true)
|
172
176
|
end
|
173
177
|
|
178
|
+
if options.list_resource_kinds
|
179
|
+
client.resources.sort_by{|r| r.kind}.each do |resource_client|
|
180
|
+
next if resource_client.subresource?
|
181
|
+
|
182
|
+
puts "#{resource_client.kind} => #{resource_client.api_version} #{resource_client.name}"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
174
186
|
if options.all_namespaces
|
175
187
|
namespace = nil # all
|
176
188
|
elsif options.namespace
|
data/lib/k8s/api_client.rb
CHANGED
@@ -57,7 +57,7 @@ module K8s
|
|
57
57
|
# @return [K8s::ResourceClient]
|
58
58
|
def resource(resource_name, namespace: nil)
|
59
59
|
unless api_resource = api_resources.find{ |api_resource| api_resource.name == resource_name }
|
60
|
-
raise K8s::Error, "Unknown resource #{resource_name} for #{@api_version}"
|
60
|
+
raise K8s::Error::UndefinedResource, "Unknown resource #{resource_name} for #{@api_version}"
|
61
61
|
end
|
62
62
|
|
63
63
|
ResourceClient.new(@transport, self, api_resource,
|
@@ -67,15 +67,16 @@ module K8s
|
|
67
67
|
|
68
68
|
# @param resource [K8s::Resource]
|
69
69
|
# @param namespace [String, nil] default if resource is missing namespace
|
70
|
-
# @raise [K8s::Error]
|
70
|
+
# @raise [K8s::Error::NotFound] API Group does not exist
|
71
|
+
# @raise [K8s::Error::UndefinedResource]
|
71
72
|
# @return [K8s::ResourceClient]
|
72
73
|
def client_for_resource(resource, namespace: nil)
|
73
74
|
unless @api_version == resource.apiVersion
|
74
|
-
raise K8s::Error, "Invalid apiVersion=#{resource.apiVersion} for #{@api_version} client"
|
75
|
+
raise K8s::Error::UndefinedResource, "Invalid apiVersion=#{resource.apiVersion} for #{@api_version} client"
|
75
76
|
end
|
76
77
|
|
77
78
|
unless api_resource = api_resources.find{ |api_resource| api_resource.kind == resource.kind }
|
78
|
-
raise K8s::Error, "Unknown resource kind=#{
|
79
|
+
raise K8s::Error::UndefinedResource, "Unknown resource kind=#{resource.kind} for #{@api_version}"
|
79
80
|
end
|
80
81
|
|
81
82
|
ResourceClient.new(@transport, self, api_resource,
|
data/lib/k8s/client.rb
CHANGED
@@ -48,7 +48,7 @@ module K8s
|
|
48
48
|
def api_groups!
|
49
49
|
@api_groups = @transport.get('/apis',
|
50
50
|
response_class: K8s::API::MetaV1::APIGroupList,
|
51
|
-
).groups.map{|api_group| api_group.
|
51
|
+
).groups.map{|api_group| api_group.versions.map{|api_version| api_version.groupVersion} }.flatten
|
52
52
|
end
|
53
53
|
|
54
54
|
# Cached /apis preferred group apiVersions
|
@@ -101,7 +101,8 @@ module K8s
|
|
101
101
|
|
102
102
|
# @param resource [K8s::Resource]
|
103
103
|
# @param namespace [String, nil] default if resource is missing namespace
|
104
|
-
# @raise [K8s::Error]
|
104
|
+
# @raise [K8s::Error::NotFound] API Group does not exist
|
105
|
+
# @raise [K8s::Error::UndefinedResource]
|
105
106
|
# @return [K8s::ResourceClient]
|
106
107
|
def client_for_resource(resource, namespace: nil)
|
107
108
|
api(resource.apiVersion).client_for_resource(resource, namespace: namespace)
|
data/lib/k8s/client/version.rb
CHANGED
data/lib/k8s/error.rb
CHANGED
data/lib/k8s/resource_client.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: k8s-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kontena, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|