kube_schema 1.10.0 → 1.11.0
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/CHANGELOG.md +11 -0
- data/Gemfile.lock +1 -1
- data/lib/kube/schema/instance.rb +41 -0
- data/lib/kube/schema/version.rb +1 -1
- data/lib/kube/schema.rb +20 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a6007594b371eeb36c26edde49a50c9ad8f4a2024784f4ef1add3eee59afaa8d
|
|
4
|
+
data.tar.gz: abb0766ced76224828aa5356bc52bcaffe738ce99a4bd6369458a1555b2f3579
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61eb43c26cf34db4c66b078169f8b23d36db383b80eb337cd39f4b61c69c36604f6bcec08606d90496ca825b70c50875deb99105db198f81532d055501baf310
|
|
7
|
+
data.tar.gz: 05316b1722bb83a2e182ba39afe1c109b50e92fe0fcc5839d12aaa80649241e533c98d731a956181475799e57b9a30714f1e146eb01ce3207b785f889c1fcb10
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,17 @@ All notable changes to this project are documented here.
|
|
|
4
4
|
|
|
5
5
|
This file starts at 1.10.0; for earlier releases see the git history.
|
|
6
6
|
|
|
7
|
+
## [1.11.0]
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `Kube::Schema.api_groups` and `Instance#api_groups` — every API group known
|
|
12
|
+
to the schema (built-in types, the merged CRD bundles, and schemas
|
|
13
|
+
registered via `.register`), sorted and deduplicated, with the core group
|
|
14
|
+
as `""`. Intended for consumers that need to distinguish group/resource
|
|
15
|
+
from core resource/subresource strings — e.g. building RBAC rules — without
|
|
16
|
+
hardcoding a group list.
|
|
17
|
+
|
|
7
18
|
## [1.10.0]
|
|
8
19
|
|
|
9
20
|
### Added
|
data/Gemfile.lock
CHANGED
data/lib/kube/schema/instance.rb
CHANGED
|
@@ -102,6 +102,21 @@ module Kube
|
|
|
102
102
|
(gvk_index.keys + custom_kinds).uniq.sort
|
|
103
103
|
end
|
|
104
104
|
|
|
105
|
+
# All API groups known to this version, including any custom schemas
|
|
106
|
+
# registered via Kube::Schema.register. The core API group is the
|
|
107
|
+
# empty string.
|
|
108
|
+
#
|
|
109
|
+
# instance.api_groups # => ["", "apps", "argoproj.io", "batch", ...]
|
|
110
|
+
#
|
|
111
|
+
# @return [Array<String>] sorted, deduplicated group names
|
|
112
|
+
def api_groups
|
|
113
|
+
custom_groups = Schema.custom_schemas.keys.filter_map do |key|
|
|
114
|
+
parts = key.split("/")
|
|
115
|
+
parts.first if parts.size == 3
|
|
116
|
+
end
|
|
117
|
+
(gvk_index.values.flatten.map { |entry| entry[:group] } + custom_groups).uniq.sort
|
|
118
|
+
end
|
|
119
|
+
|
|
105
120
|
# Look up a sub-spec definition by short name (e.g. "Container",
|
|
106
121
|
# "ContainerPort", "Volume", "Probe"). Returns a class that
|
|
107
122
|
# inherits from Kube::Schema::SubSpec.
|
|
@@ -489,6 +504,32 @@ if __FILE__ == $0
|
|
|
489
504
|
end
|
|
490
505
|
end
|
|
491
506
|
|
|
507
|
+
describe "#api_groups" do
|
|
508
|
+
it "returns a sorted array of group names including the core group" do
|
|
509
|
+
groups = instance.api_groups
|
|
510
|
+
expect(groups).to be_an(Array)
|
|
511
|
+
expect(groups).to eq(groups.sort)
|
|
512
|
+
expect(groups).to include("")
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
it "includes built-in groups, including ones without dots" do
|
|
516
|
+
expect(instance.api_groups).to include("apps", "batch", "rbac.authorization.k8s.io")
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
it "includes groups from the merged CRD definition bundles" do
|
|
520
|
+
expect(instance.api_groups).to include("kubevirt.io", "argoproj.io")
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
it "includes groups from registered custom schemas" do
|
|
524
|
+
Kube::Schema.register("TenantVmClaim",
|
|
525
|
+
schema: { "type" => "object" },
|
|
526
|
+
api_version: "tradeportal.ai/v1")
|
|
527
|
+
expect(instance.api_groups).to include("tradeportal.ai")
|
|
528
|
+
ensure
|
|
529
|
+
Kube::Schema.reset_custom_schemas!
|
|
530
|
+
end
|
|
531
|
+
end
|
|
532
|
+
|
|
492
533
|
describe "KubeVirt schemas" do
|
|
493
534
|
it "resolves VirtualMachine" do
|
|
494
535
|
klass = instance["VirtualMachine"]
|
data/lib/kube/schema/version.rb
CHANGED
data/lib/kube/schema.rb
CHANGED
|
@@ -160,6 +160,16 @@ module Kube
|
|
|
160
160
|
schema_versions.last
|
|
161
161
|
end
|
|
162
162
|
|
|
163
|
+
# All API groups known to the default schema version, including any
|
|
164
|
+
# custom schemas registered via .register. The core group is "".
|
|
165
|
+
#
|
|
166
|
+
# Kube::Schema.api_groups # => ["", "apps", "argoproj.io", "batch", ...]
|
|
167
|
+
#
|
|
168
|
+
# @return [Array<String>] sorted, deduplicated group names
|
|
169
|
+
def api_groups
|
|
170
|
+
self[schema_version || DEFAULT_VERSION].api_groups
|
|
171
|
+
end
|
|
172
|
+
|
|
163
173
|
def has_version?(version)
|
|
164
174
|
schema_versions.include?(version)
|
|
165
175
|
end
|
|
@@ -314,5 +324,15 @@ if __FILE__ == $0
|
|
|
314
324
|
expect(Kube::Schema.has_version?("0.0.1")).to be false
|
|
315
325
|
end
|
|
316
326
|
end
|
|
327
|
+
|
|
328
|
+
describe ".api_groups" do
|
|
329
|
+
it "delegates to the default version's instance" do
|
|
330
|
+
expect(Kube::Schema.api_groups).to eq(Kube::Schema[Kube::Schema::DEFAULT_VERSION].api_groups)
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
it "includes core and built-in groups" do
|
|
334
|
+
expect(Kube::Schema.api_groups).to include("", "apps", "batch")
|
|
335
|
+
end
|
|
336
|
+
end
|
|
317
337
|
end
|
|
318
338
|
end
|