kube_schema 1.10.0 → 1.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95c2a3f8aa906bd8a40d43eedf4b209a4cdc83754c0ffe6a1b74a5c4aeab14c0
4
- data.tar.gz: 0f14d9a60d65d003dd11b0f0f0f344f5f1ac9e3b8c5bf44fde3b489b8828bebc
3
+ metadata.gz: 7b5c93b3a4aa288687e6b1248f9a56040da8a1818668de9a4a6d6dd220ffd561
4
+ data.tar.gz: c9a224adc2270ae7551244939e9ce65ede7f96001fe0622e34bba0c3346b7d76
5
5
  SHA512:
6
- metadata.gz: 1ae77de844bff9919b8a429202648f85c97ac6ad2c2f522be9602008cf2cec518bd1544bd6ab4de98f29dc7a76262293138286a33ec89e4a4d2063fbdcb769cf
7
- data.tar.gz: 1ba74962b756416d428b793c3afb51847b1e3ce1b5366e4a089f0eac4614949fd1a1c8976c219b1e0adccda5ed3ae9da364b5d3848a7ca51bf27a68645fc6332
6
+ metadata.gz: f8a4978a52e7c7ecfba7de840202976a79359a319b9001bf1a1786ecf790533fc6c8ef5c047fd95e03b4b5523e57019960089ee9fa3f81becb85b221c1cb73cf
7
+ data.tar.gz: c5cc5671b5d85777f18140a7e71561e3d9a2e9ea82a21b9544578e1adaec3dc04277695eb6b8caf3ac624b8a4888126a7b1d0e28cbcf5acbe87846df35564b6e
data/CHANGELOG.md CHANGED
@@ -4,6 +4,35 @@ 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.12.0]
8
+
9
+ ### Added
10
+
11
+ - Ruby pattern matching support. `Resource#deconstruct_keys` exposes `to_h`,
12
+ so resources match against hash patterns all the way down; `Manifest#deconstruct`
13
+ exposes the resource array, so manifests match against array patterns.
14
+
15
+ resource => {metadata: {name:}}
16
+
17
+ Deployment = Kube::Schema["Deployment"]
18
+ manifest => [Deployment => dep, *rest]
19
+
20
+ Note that `Kube::Schema["Deployment"]` cannot be written inline in a pattern:
21
+ Ruby parses `Const[...]` as array-pattern syntax, not a method call. Assign
22
+ the class to a constant, or use a pin expression —
23
+ `^(Kube::Schema["Deployment"])`.
24
+
25
+ ## [1.11.0]
26
+
27
+ ### Added
28
+
29
+ - `Kube::Schema.api_groups` and `Instance#api_groups` — every API group known
30
+ to the schema (built-in types, the merged CRD bundles, and schemas
31
+ registered via `.register`), sorted and deduplicated, with the core group
32
+ as `""`. Intended for consumers that need to distinguish group/resource
33
+ from core resource/subresource strings — e.g. building RBAC rules — without
34
+ hardcoding a group list.
35
+
7
36
  ## [1.10.0]
8
37
 
9
38
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kube_schema (1.10.0)
4
+ kube_schema (1.12.0)
5
5
  json_schemer (~> 2.5.0)
6
6
  rubyshell (~> 1.5.0)
7
7
 
data/flake.lock CHANGED
@@ -1,23 +1,45 @@
1
1
  {
2
2
  "nodes": {
3
+ "mine": {
4
+ "inputs": {
5
+ "nixpkgs": [
6
+ "nixpkgs"
7
+ ],
8
+ "systems": "systems"
9
+ },
10
+ "locked": {
11
+ "lastModified": 1790556091,
12
+ "narHash": "sha256-+kgvg6vuaxjEUUad6pL+pxa3LZFveq3XvWGSZ+Z9gOA=",
13
+ "owner": "n-at-han-k",
14
+ "repo": "flake.nix",
15
+ "rev": "d023f40398596a5d80bf03e429c678a99b3f259a",
16
+ "type": "github"
17
+ },
18
+ "original": {
19
+ "owner": "n-at-han-k",
20
+ "repo": "flake.nix",
21
+ "type": "github"
22
+ }
23
+ },
3
24
  "nixpkgs": {
4
25
  "locked": {
5
- "lastModified": 1776169885,
6
- "narHash": "sha256-l/iNYDZ4bGOAFQY2q8y5OAfBBtrDAaPuRQqWaFHVRXM=",
26
+ "lastModified": 1780902259,
27
+ "narHash": "sha256-q8yYEC5f1mFlQO9RGna4LTc9QrcvWunX6FYp83munkQ=",
7
28
  "owner": "NixOS",
8
29
  "repo": "nixpkgs",
9
- "rev": "4bd9165a9165d7b5e33ae57f3eecbcb28fb231c9",
30
+ "rev": "bd0ff2d3eac24699c3664d5966b9ef36f388e2ca",
10
31
  "type": "github"
11
32
  },
12
33
  "original": {
13
34
  "owner": "NixOS",
14
- "ref": "nixos-unstable",
15
35
  "repo": "nixpkgs",
36
+ "rev": "bd0ff2d3eac24699c3664d5966b9ef36f388e2ca",
16
37
  "type": "github"
17
38
  }
18
39
  },
19
40
  "root": {
20
41
  "inputs": {
42
+ "mine": "mine",
21
43
  "nixpkgs": "nixpkgs",
22
44
  "utils": "utils"
23
45
  }
@@ -37,9 +59,24 @@
37
59
  "type": "github"
38
60
  }
39
61
  },
62
+ "systems_2": {
63
+ "locked": {
64
+ "lastModified": 1681028828,
65
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
66
+ "owner": "nix-systems",
67
+ "repo": "default",
68
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
69
+ "type": "github"
70
+ },
71
+ "original": {
72
+ "owner": "nix-systems",
73
+ "repo": "default",
74
+ "type": "github"
75
+ }
76
+ },
40
77
  "utils": {
41
78
  "inputs": {
42
- "systems": "systems"
79
+ "systems": "systems_2"
43
80
  },
44
81
  "locked": {
45
82
  "lastModified": 1731533236,
data/flake.nix CHANGED
@@ -2,38 +2,38 @@
2
2
  description = "Ruby gem flake";
3
3
 
4
4
  inputs = {
5
- nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
5
+ nixpkgs.url = "github:NixOS/nixpkgs/bd0ff2d3eac24699c3664d5966b9ef36f388e2ca"; # == this machine's system nixpkgs
6
6
  utils.url = "github:numtide/flake-utils";
7
+ mine.url = "github:n-at-han-k/flake.nix";
8
+ mine.inputs.nixpkgs.follows = "nixpkgs";
7
9
  };
8
- outputs = { self, nixpkgs, utils }:
10
+ outputs = { self, nixpkgs, utils, mine }:
9
11
  utils.lib.eachDefaultSystem (system:
10
12
  let
13
+ # No mine.overlays.default: it overrides pkg-config, which stdenv
14
+ # splices, so the overlay rebuilds stdenv and all of nixpkgs from
15
+ # source. mine.inputs.nixpkgs.follows makes it redundant anyway.
11
16
  pkgs = nixpkgs.legacyPackages.${system};
12
- ruby = pkgs.ruby_3_4; # Specify version
17
+ ruby = pkgs.ruby_3_4;
13
18
  in
14
19
  {
15
- devShells.default = pkgs.mkShell {
16
- nativeBuildInputs = [
17
- pkgs.pkg-config # native extension discovery
18
- ];
19
-
20
+ # pkg-config, bundix, libyaml, openssl, overmind, tmux and `bundix -l`
21
+ # come from mkRubyShell.
22
+ devShells.default = mine.lib.${system}.mkRubyShell {
20
23
  buildInputs = [
21
24
  pkgs.trufflehog
22
25
  ruby
23
- pkgs.libyaml # psych gem
24
- pkgs.openssl # openssl gem
25
26
  ];
26
27
 
27
28
  shellHook = ''
28
- export GEM_HOME="$HOME/.gem-${ruby.version}"
29
- export GEM_PATH="$GEM_HOME"
30
- export PATH="$GEM_HOME/bin:$PATH"
31
- export BUNDLE_GEMFILE="$PWD/Gemfile"
32
- export BUNDLE_PATH="$GEM_HOME"
33
- export BUNDLE_BIN="$GEM_HOME/bin"
34
- '';
29
+ export GEM_HOME="$HOME/.gem-${ruby.version}"
30
+ export GEM_PATH="$GEM_HOME"
31
+ export PATH="$GEM_HOME/bin:$PATH"
32
+ export BUNDLE_GEMFILE="$PWD/Gemfile"
33
+ export BUNDLE_PATH="$GEM_HOME"
34
+ export BUNDLE_BIN="$GEM_HOME/bin"
35
+ '';
35
36
  };
36
37
  }
37
38
  );
38
39
  }
39
-
data/gemset.nix ADDED
@@ -0,0 +1,914 @@
1
+ {
2
+ async = {
3
+ dependencies = ["console" "fiber-annotation" "io-event" "metrics" "traces"];
4
+ groups = ["default" "maintenance"];
5
+ platforms = [];
6
+ source = {
7
+ remotes = ["https://rubygems.org"];
8
+ sha256 = "1ah038cvb5k7vr29z5jkjhdwqpinrchglz87i1bv9fzjfc07666z";
9
+ type = "gem";
10
+ };
11
+ version = "2.39.0";
12
+ };
13
+ async-container = {
14
+ dependencies = ["async"];
15
+ groups = ["default" "maintenance"];
16
+ platforms = [];
17
+ source = {
18
+ remotes = ["https://rubygems.org"];
19
+ sha256 = "1g9lcawa16wjgq131ngczx54vdy4qqda3lqlh8iijlncnh5rapch";
20
+ type = "gem";
21
+ };
22
+ version = "0.34.5";
23
+ };
24
+ async-http = {
25
+ dependencies = ["async" "async-pool" "io-endpoint" "io-stream" "metrics" "protocol-http" "protocol-http1" "protocol-http2" "protocol-url" "traces"];
26
+ groups = ["default" "maintenance"];
27
+ platforms = [];
28
+ source = {
29
+ remotes = ["https://rubygems.org"];
30
+ sha256 = "1ajlaxwssid5lczzmfl8gk2z20d0pnfglsw53qfy8j2s4nmqq4h8";
31
+ type = "gem";
32
+ };
33
+ version = "0.95.0";
34
+ };
35
+ async-http-cache = {
36
+ dependencies = ["async-http"];
37
+ groups = ["default" "maintenance"];
38
+ platforms = [];
39
+ source = {
40
+ remotes = ["https://rubygems.org"];
41
+ sha256 = "1mnzzlq0bnya0hlzrz0bl66r7qw5a3173cjd1fsicbqqjgqd2f10";
42
+ type = "gem";
43
+ };
44
+ version = "0.4.6";
45
+ };
46
+ async-ollama = {
47
+ dependencies = ["async" "async-rest"];
48
+ groups = ["default" "maintenance"];
49
+ platforms = [];
50
+ source = {
51
+ remotes = ["https://rubygems.org"];
52
+ sha256 = "1myl413dynl0z0rwmf3sswly9yamz5ysk8nwb3wm2230ljdlqp0h";
53
+ type = "gem";
54
+ };
55
+ version = "0.10.3";
56
+ };
57
+ async-pool = {
58
+ dependencies = ["async"];
59
+ groups = ["default" "maintenance"];
60
+ platforms = [];
61
+ source = {
62
+ remotes = ["https://rubygems.org"];
63
+ sha256 = "1vg3lwb3yhq0rad3dm00vp35vrahkbxgl4kx3d2rqkdh09xs2hqa";
64
+ type = "gem";
65
+ };
66
+ version = "0.11.2";
67
+ };
68
+ async-rest = {
69
+ dependencies = ["async-http" "protocol-url"];
70
+ groups = ["default" "maintenance"];
71
+ platforms = [];
72
+ source = {
73
+ remotes = ["https://rubygems.org"];
74
+ sha256 = "1swmgq79knydk05ylkhv43x4l6yqyclbh4pwchxaasajyrkx9c3j";
75
+ type = "gem";
76
+ };
77
+ version = "0.20.0";
78
+ };
79
+ async-service = {
80
+ dependencies = ["async" "async-container" "string-format"];
81
+ groups = ["default" "maintenance"];
82
+ platforms = [];
83
+ source = {
84
+ remotes = ["https://rubygems.org"];
85
+ sha256 = "0q9vwq9iidm7426s23dz90as44cqygp9f82ck4px8m2n2j468qc4";
86
+ type = "gem";
87
+ };
88
+ version = "0.22.0";
89
+ };
90
+ async-utilization = {
91
+ dependencies = ["console"];
92
+ groups = ["default" "maintenance"];
93
+ platforms = [];
94
+ source = {
95
+ remotes = ["https://rubygems.org"];
96
+ sha256 = "1d7k3nrmzi3gwlv1z9g3pb72f3j2bszfr8019b0kzqlgjkh2f6i0";
97
+ type = "gem";
98
+ };
99
+ version = "0.3.2";
100
+ };
101
+ bake = {
102
+ dependencies = ["bigdecimal" "samovar"];
103
+ groups = ["default" "maintenance"];
104
+ platforms = [];
105
+ source = {
106
+ remotes = ["https://rubygems.org"];
107
+ sha256 = "1izlqnz0828mgdq04s1w291ky912w6jzcg5iwch7gc8l2pkcgylb";
108
+ type = "gem";
109
+ };
110
+ version = "0.24.1";
111
+ };
112
+ bake-gem = {
113
+ dependencies = ["console"];
114
+ groups = ["maintenance"];
115
+ platforms = [];
116
+ source = {
117
+ remotes = ["https://rubygems.org"];
118
+ sha256 = "14qvrxrcy1g6as6nbcs7di20kvzx46yw0bwczjaa3v6p8dil2p27";
119
+ type = "gem";
120
+ };
121
+ version = "0.13.1";
122
+ };
123
+ bake-modernize = {
124
+ dependencies = ["async-http" "async-ollama" "bake" "build-files" "markly" "rugged"];
125
+ groups = ["maintenance"];
126
+ platforms = [];
127
+ source = {
128
+ remotes = ["https://rubygems.org"];
129
+ sha256 = "069gic0y7klh0wixf9q3gpqg0xhf2s1i6qx005pwfyha8daccbbb";
130
+ type = "gem";
131
+ };
132
+ version = "0.54.1";
133
+ };
134
+ bake-releases = {
135
+ dependencies = ["bake" "markly"];
136
+ groups = ["maintenance"];
137
+ platforms = [];
138
+ source = {
139
+ remotes = ["https://rubygems.org"];
140
+ sha256 = "1q1kwrxfv9z4l7c94kid52z15jiqvg1snmr9qdrh7p91l5qwm4pn";
141
+ type = "gem";
142
+ };
143
+ version = "0.5.4";
144
+ };
145
+ bigdecimal = {
146
+ groups = ["default" "maintenance"];
147
+ platforms = [];
148
+ source = {
149
+ remotes = ["https://rubygems.org"];
150
+ sha256 = "1g9zi8c4i7g8zz0c3hxrw6mblrjvgn7akys60clb9si7c1k1gljk";
151
+ type = "gem";
152
+ };
153
+ version = "4.1.2";
154
+ };
155
+ build-files = {
156
+ groups = ["default" "maintenance"];
157
+ platforms = [];
158
+ source = {
159
+ remotes = ["https://rubygems.org"];
160
+ sha256 = "1g9p6dhnycc2649fd2pi5jzklyqn2cjbvggccqkjqgalajf971hh";
161
+ type = "gem";
162
+ };
163
+ version = "1.10.2";
164
+ };
165
+ concurrent-ruby = {
166
+ groups = ["default" "maintenance"];
167
+ platforms = [];
168
+ source = {
169
+ remotes = ["https://rubygems.org"];
170
+ sha256 = "1aymcakhzl83k77g2f2krz07bg1cbafbcd2ghvwr4lky3rz86mkb";
171
+ type = "gem";
172
+ };
173
+ version = "1.3.6";
174
+ };
175
+ console = {
176
+ dependencies = ["fiber-annotation" "fiber-local" "json"];
177
+ groups = ["default" "maintenance"];
178
+ platforms = [];
179
+ source = {
180
+ remotes = ["https://rubygems.org"];
181
+ sha256 = "1k0dxi072mz8j72r32kkzpky825hn092hb8hdxh4rz3yd5sbv7w6";
182
+ type = "gem";
183
+ };
184
+ version = "1.34.3";
185
+ };
186
+ date = {
187
+ groups = ["default" "maintenance"];
188
+ platforms = [];
189
+ source = {
190
+ remotes = ["https://rubygems.org"];
191
+ sha256 = "1h0db8r2v5llxdbzkzyllkfniqw9gm092qn7cbaib73v9lw0c3bm";
192
+ type = "gem";
193
+ };
194
+ version = "3.5.1";
195
+ };
196
+ decode = {
197
+ dependencies = ["prism" "rbs"];
198
+ groups = ["default" "maintenance"];
199
+ platforms = [];
200
+ source = {
201
+ remotes = ["https://rubygems.org"];
202
+ sha256 = "0mp1ha7sg6l6f5dqwidxwnpm7lj7my5vsxwz7nlnpg7lqsj0fnvb";
203
+ type = "gem";
204
+ };
205
+ version = "0.27.0";
206
+ };
207
+ diff-lcs = {
208
+ groups = ["default" "development"];
209
+ platforms = [];
210
+ source = {
211
+ remotes = ["https://rubygems.org"];
212
+ sha256 = "0qlrj2qyysc9avzlr4zs1py3x684hqm61n4czrsk1pyllz5x5q4s";
213
+ type = "gem";
214
+ };
215
+ version = "1.6.2";
216
+ };
217
+ erb = {
218
+ groups = ["default" "maintenance"];
219
+ platforms = [];
220
+ source = {
221
+ remotes = ["https://rubygems.org"];
222
+ sha256 = "1ncmbdjf2bwmk0jf5cxywns9zbxyfiy4h4p3pzi7yddyjhv81qrq";
223
+ type = "gem";
224
+ };
225
+ version = "6.0.4";
226
+ };
227
+ falcon = {
228
+ dependencies = ["async" "async-container" "async-http" "async-http-cache" "async-service" "async-utilization" "localhost" "openssl" "protocol-http" "protocol-rack" "samovar"];
229
+ groups = ["default" "maintenance"];
230
+ platforms = [];
231
+ source = {
232
+ remotes = ["https://rubygems.org"];
233
+ sha256 = "0fwp7i3f9gvsg0qyn33i522fvj0gh1w25byq1plv4jsmwfnbv1q2";
234
+ type = "gem";
235
+ };
236
+ version = "0.55.3";
237
+ };
238
+ fiber-annotation = {
239
+ groups = ["default" "maintenance"];
240
+ platforms = [];
241
+ source = {
242
+ remotes = ["https://rubygems.org"];
243
+ sha256 = "00vcmynyvhny8n4p799rrhcx0m033hivy0s1gn30ix8rs7qsvgvs";
244
+ type = "gem";
245
+ };
246
+ version = "0.2.0";
247
+ };
248
+ fiber-local = {
249
+ dependencies = ["fiber-storage"];
250
+ groups = ["default" "maintenance"];
251
+ platforms = [];
252
+ source = {
253
+ remotes = ["https://rubygems.org"];
254
+ sha256 = "01lz929qf3xa90vra1ai1kh059kf2c8xarfy6xbv1f8g457zk1f8";
255
+ type = "gem";
256
+ };
257
+ version = "1.1.0";
258
+ };
259
+ fiber-storage = {
260
+ groups = ["default" "maintenance"];
261
+ platforms = [];
262
+ source = {
263
+ remotes = ["https://rubygems.org"];
264
+ sha256 = "1qa0j9qjwav9xb0n3isx0rbh0942xrfback392n6vs8bidnmp3pl";
265
+ type = "gem";
266
+ };
267
+ version = "1.0.1";
268
+ };
269
+ hana = {
270
+ groups = ["default"];
271
+ platforms = [];
272
+ source = {
273
+ remotes = ["https://rubygems.org"];
274
+ sha256 = "03cvrv2wl25j9n4n509hjvqnmwa60k92j741b64a1zjisr1dn9al";
275
+ type = "gem";
276
+ };
277
+ version = "1.3.7";
278
+ };
279
+ http-accept = {
280
+ groups = ["default" "maintenance"];
281
+ platforms = [];
282
+ source = {
283
+ remotes = ["https://rubygems.org"];
284
+ sha256 = "03shmn4nn1cwqwhjfii2ad7gz7s4481b5ipmalsy90pp43nisj7q";
285
+ type = "gem";
286
+ };
287
+ version = "2.2.1";
288
+ };
289
+ io-console = {
290
+ groups = ["default" "maintenance"];
291
+ platforms = [];
292
+ source = {
293
+ remotes = ["https://rubygems.org"];
294
+ sha256 = "1k0lk3pwadm2myvpg893n8jshmrf2sigrd4ki15lymy7gixaxqyn";
295
+ type = "gem";
296
+ };
297
+ version = "0.8.2";
298
+ };
299
+ io-endpoint = {
300
+ groups = ["default" "maintenance"];
301
+ platforms = [];
302
+ source = {
303
+ remotes = ["https://rubygems.org"];
304
+ sha256 = "0f1kzf4d5qgqgfjh52a8pf3pii5dmav6ib0zq4wmicqnq5kggsiz";
305
+ type = "gem";
306
+ };
307
+ version = "0.17.2";
308
+ };
309
+ io-event = {
310
+ groups = ["default" "maintenance"];
311
+ platforms = [];
312
+ source = {
313
+ remotes = ["https://rubygems.org"];
314
+ sha256 = "1k1hkgjjnxa9xa023904n9diyirm5x4z92sm7zb1ah15937wsi66";
315
+ type = "gem";
316
+ };
317
+ version = "1.15.1";
318
+ };
319
+ io-stream = {
320
+ groups = ["default" "maintenance"];
321
+ platforms = [];
322
+ source = {
323
+ remotes = ["https://rubygems.org"];
324
+ sha256 = "0dhnkjf59ayw5xi873a939i63d47lrlqcpphvv73xprb635vq96f";
325
+ type = "gem";
326
+ };
327
+ version = "0.13.0";
328
+ };
329
+ irb = {
330
+ dependencies = ["pp" "prism" "rdoc" "reline"];
331
+ groups = ["default" "maintenance"];
332
+ platforms = [];
333
+ source = {
334
+ remotes = ["https://rubygems.org"];
335
+ sha256 = "1qs8a9vprg7s8krgq4s0pygr91hclqqyz98ik15p0m1sf2h5956y";
336
+ type = "gem";
337
+ };
338
+ version = "1.18.0";
339
+ };
340
+ json = {
341
+ groups = ["default" "maintenance"];
342
+ platforms = [];
343
+ source = {
344
+ remotes = ["https://rubygems.org"];
345
+ sha256 = "0il6qxkxqql7n7sgrws5bi5a36v51dswqcxb6j6gm8aj62shp6r8";
346
+ type = "gem";
347
+ };
348
+ version = "2.19.3";
349
+ };
350
+ json_schemer = {
351
+ dependencies = ["bigdecimal" "hana" "regexp_parser" "simpleidn"];
352
+ groups = ["default"];
353
+ platforms = [];
354
+ source = {
355
+ remotes = ["https://rubygems.org"];
356
+ sha256 = "15p31bq932bfpsi1wgrkgwm71l7z1h1w53q6vl44w6kjrr6gn09g";
357
+ type = "gem";
358
+ };
359
+ version = "2.5.0";
360
+ };
361
+ kube_schema = {
362
+ dependencies = ["json_schemer" "rubyshell"];
363
+ groups = ["default"];
364
+ platforms = [];
365
+ source = {
366
+ path = ./.;
367
+ type = "path";
368
+ };
369
+ version = "1.11.0";
370
+ };
371
+ lefthook = {
372
+ groups = ["development"];
373
+ platforms = [];
374
+ source = {
375
+ remotes = ["https://rubygems.org"];
376
+ sha256 = "0r8vwq96i3wfsb3c2q0qjl3nssadwmlrgavf06wfi2d6isyhd76c";
377
+ type = "gem";
378
+ };
379
+ version = "2.1.10";
380
+ };
381
+ localhost = {
382
+ groups = ["default" "maintenance"];
383
+ platforms = [];
384
+ source = {
385
+ remotes = ["https://rubygems.org"];
386
+ sha256 = "0zslqi1xj21pzlm4lr7gnq0p8lb2n7x9bid7y36lr4bzaccjicq9";
387
+ type = "gem";
388
+ };
389
+ version = "1.7.0";
390
+ };
391
+ logger = {
392
+ groups = ["default" "maintenance"];
393
+ platforms = [];
394
+ source = {
395
+ remotes = ["https://rubygems.org"];
396
+ sha256 = "00q2zznygpbls8asz5knjvvj2brr3ghmqxgr83xnrdj4rk3xwvhr";
397
+ type = "gem";
398
+ };
399
+ version = "1.7.0";
400
+ };
401
+ mail = {
402
+ dependencies = ["logger" "mini_mime" "net-imap" "net-pop" "net-smtp"];
403
+ groups = ["default" "maintenance"];
404
+ platforms = [];
405
+ source = {
406
+ remotes = ["https://rubygems.org"];
407
+ sha256 = "0ha9sgkfqna62c1basc17dkx91yk7ppgjq32k4nhrikirlz6g9kg";
408
+ type = "gem";
409
+ };
410
+ version = "2.9.0";
411
+ };
412
+ mapping = {
413
+ groups = ["default" "maintenance"];
414
+ platforms = [];
415
+ source = {
416
+ remotes = ["https://rubygems.org"];
417
+ sha256 = "18jdbz3x6cvprhsw7jiv44xi6wklric0rq6iznm6xm7c40fr6x12";
418
+ type = "gem";
419
+ };
420
+ version = "1.1.3";
421
+ };
422
+ markly = {
423
+ groups = ["default" "maintenance"];
424
+ platforms = [];
425
+ source = {
426
+ remotes = ["https://rubygems.org"];
427
+ sha256 = "04ammhfwf91r7kh7iiz6kw1mjql250bchx0z2yggq7jv72gdfw3g";
428
+ type = "gem";
429
+ };
430
+ version = "0.16.0";
431
+ };
432
+ metrics = {
433
+ groups = ["default" "maintenance"];
434
+ platforms = [];
435
+ source = {
436
+ remotes = ["https://rubygems.org"];
437
+ sha256 = "0wlh0g4xmfqa41dsh4m3514q3jcvy6jx97mwn6ayj62ir6xdbpk1";
438
+ type = "gem";
439
+ };
440
+ version = "0.15.0";
441
+ };
442
+ mime-types = {
443
+ dependencies = ["logger" "mime-types-data"];
444
+ groups = ["default" "maintenance"];
445
+ platforms = [];
446
+ source = {
447
+ remotes = ["https://rubygems.org"];
448
+ sha256 = "0mjyxl7c0xzyqdqa8r45hqg7jcw2prp3hkp39mdf223g4hfgdsyw";
449
+ type = "gem";
450
+ };
451
+ version = "3.7.0";
452
+ };
453
+ mime-types-data = {
454
+ groups = ["default" "maintenance"];
455
+ platforms = [];
456
+ source = {
457
+ remotes = ["https://rubygems.org"];
458
+ sha256 = "1k28j6ww8rf43r5i8278jvm2cq3pnzsvqm7yqpb4p93kadjlq726";
459
+ type = "gem";
460
+ };
461
+ version = "3.2026.0414";
462
+ };
463
+ mini_mime = {
464
+ groups = ["default" "maintenance"];
465
+ platforms = [];
466
+ source = {
467
+ remotes = ["https://rubygems.org"];
468
+ sha256 = "1vycif7pjzkr29mfk4dlqv3disc5dn0va04lkwajlpr1wkibg0c6";
469
+ type = "gem";
470
+ };
471
+ version = "1.1.5";
472
+ };
473
+ msgpack = {
474
+ groups = ["default" "maintenance"];
475
+ platforms = [];
476
+ source = {
477
+ remotes = ["https://rubygems.org"];
478
+ sha256 = "0cnpnbn2yivj9gxkh8mjklbgnpx6nf7b8j2hky01dl0040hy0k76";
479
+ type = "gem";
480
+ };
481
+ version = "1.8.0";
482
+ };
483
+ net-imap = {
484
+ dependencies = ["date" "net-protocol"];
485
+ groups = ["default" "maintenance"];
486
+ platforms = [];
487
+ source = {
488
+ remotes = ["https://rubygems.org"];
489
+ sha256 = "0ax0f0r97jm83q462vsrcbdxprs894fyyc44v62c48ihgb39hmcs";
490
+ type = "gem";
491
+ };
492
+ version = "0.6.4";
493
+ };
494
+ net-pop = {
495
+ dependencies = ["net-protocol"];
496
+ groups = ["default" "maintenance"];
497
+ platforms = [];
498
+ source = {
499
+ remotes = ["https://rubygems.org"];
500
+ sha256 = "1wyz41jd4zpjn0v1xsf9j778qx1vfrl24yc20cpmph8k42c4x2w4";
501
+ type = "gem";
502
+ };
503
+ version = "0.1.2";
504
+ };
505
+ net-protocol = {
506
+ dependencies = ["timeout"];
507
+ groups = ["default" "maintenance"];
508
+ platforms = [];
509
+ source = {
510
+ remotes = ["https://rubygems.org"];
511
+ sha256 = "1a32l4x73hz200cm587bc29q8q9az278syw3x6fkc9d1lv5y0wxa";
512
+ type = "gem";
513
+ };
514
+ version = "0.2.2";
515
+ };
516
+ net-smtp = {
517
+ dependencies = ["net-protocol"];
518
+ groups = ["default" "maintenance"];
519
+ platforms = [];
520
+ source = {
521
+ remotes = ["https://rubygems.org"];
522
+ sha256 = "0dh7nzjp0fiaqq1jz90nv4nxhc2w359d7c199gmzq965cfps15pd";
523
+ type = "gem";
524
+ };
525
+ version = "0.5.1";
526
+ };
527
+ openssl = {
528
+ groups = ["default" "maintenance"];
529
+ platforms = [];
530
+ source = {
531
+ remotes = ["https://rubygems.org"];
532
+ sha256 = "0zazkk5q3p2ldd23ka04wypsz2g8gqwwainf3d58j0kvdc9p8yg2";
533
+ type = "gem";
534
+ };
535
+ version = "4.0.1";
536
+ };
537
+ pp = {
538
+ dependencies = ["prettyprint"];
539
+ groups = ["default" "maintenance"];
540
+ platforms = [];
541
+ source = {
542
+ remotes = ["https://rubygems.org"];
543
+ sha256 = "1xlxmg86k5kifci1xvlmgw56x88dmqf04zfzn7zcr4qb8ladal99";
544
+ type = "gem";
545
+ };
546
+ version = "0.6.3";
547
+ };
548
+ prettyprint = {
549
+ groups = ["default" "maintenance"];
550
+ platforms = [];
551
+ source = {
552
+ remotes = ["https://rubygems.org"];
553
+ sha256 = "14zicq3plqi217w6xahv7b8f7aj5kpxv1j1w98344ix9h5ay3j9b";
554
+ type = "gem";
555
+ };
556
+ version = "0.2.0";
557
+ };
558
+ prism = {
559
+ groups = ["default" "maintenance"];
560
+ platforms = [];
561
+ source = {
562
+ remotes = ["https://rubygems.org"];
563
+ sha256 = "11ggfikcs1lv17nhmhqyyp6z8nq5pkfcj6a904047hljkxm0qlvv";
564
+ type = "gem";
565
+ };
566
+ version = "1.9.0";
567
+ };
568
+ protocol-hpack = {
569
+ groups = ["default" "maintenance"];
570
+ platforms = [];
571
+ source = {
572
+ remotes = ["https://rubygems.org"];
573
+ sha256 = "14ddqg5mcs9ysd1hdzkm5pwil0660vrxcxsn576s3387p0wa5v3g";
574
+ type = "gem";
575
+ };
576
+ version = "1.5.1";
577
+ };
578
+ protocol-http = {
579
+ groups = ["default" "maintenance"];
580
+ platforms = [];
581
+ source = {
582
+ remotes = ["https://rubygems.org"];
583
+ sha256 = "0fvpza7nnbyd3nfxkn5gych6diwns386g2ib9s6azh99c3sz5hg1";
584
+ type = "gem";
585
+ };
586
+ version = "0.62.2";
587
+ };
588
+ protocol-http1 = {
589
+ dependencies = ["protocol-http"];
590
+ groups = ["default" "maintenance"];
591
+ platforms = [];
592
+ source = {
593
+ remotes = ["https://rubygems.org"];
594
+ sha256 = "1syqgaklsn9rf11xmll2s3ms7jvpd5zjng9jdb3r8pbgv963z6z4";
595
+ type = "gem";
596
+ };
597
+ version = "0.39.0";
598
+ };
599
+ protocol-http2 = {
600
+ dependencies = ["protocol-hpack" "protocol-http"];
601
+ groups = ["default" "maintenance"];
602
+ platforms = [];
603
+ source = {
604
+ remotes = ["https://rubygems.org"];
605
+ sha256 = "11kl6768hpzgvvvlpyvmr74v0jqf2vslcwngs3643cl2h3brrj5s";
606
+ type = "gem";
607
+ };
608
+ version = "0.26.0";
609
+ };
610
+ protocol-rack = {
611
+ dependencies = ["io-stream" "protocol-http" "rack"];
612
+ groups = ["default" "maintenance"];
613
+ platforms = [];
614
+ source = {
615
+ remotes = ["https://rubygems.org"];
616
+ sha256 = "1hwz5bb3wcx4lkprigsgfa4vqlx33jcxc01pc2d89ybyj92x518i";
617
+ type = "gem";
618
+ };
619
+ version = "0.22.1";
620
+ };
621
+ protocol-url = {
622
+ groups = ["default" "maintenance"];
623
+ platforms = [];
624
+ source = {
625
+ remotes = ["https://rubygems.org"];
626
+ sha256 = "1qd9vsn9sif58swfqsyj429aynqyv6hpgbzxqrd83baidcxw1m34";
627
+ type = "gem";
628
+ };
629
+ version = "0.4.0";
630
+ };
631
+ psych = {
632
+ dependencies = ["date" "stringio"];
633
+ groups = ["default" "maintenance"];
634
+ platforms = [];
635
+ source = {
636
+ remotes = ["https://rubygems.org"];
637
+ sha256 = "0x0r3gc66abv8i4dw0x0370b5hrshjfp6kpp7wbp178cy775fypb";
638
+ type = "gem";
639
+ };
640
+ version = "5.3.1";
641
+ };
642
+ rack = {
643
+ groups = ["default" "maintenance"];
644
+ platforms = [];
645
+ source = {
646
+ remotes = ["https://rubygems.org"];
647
+ sha256 = "1hhjy9gcp52dzij05gmidqac8g28ski5xm67prwmdqmjfcgqxmsy";
648
+ type = "gem";
649
+ };
650
+ version = "3.2.6";
651
+ };
652
+ rackula = {
653
+ dependencies = ["falcon" "samovar" "variant"];
654
+ groups = ["default" "maintenance"];
655
+ platforms = [];
656
+ source = {
657
+ remotes = ["https://rubygems.org"];
658
+ sha256 = "0qdv10k36c3qmfpv6321in5k7x9xgpm55h25d0q8hbb5ph74p0j6";
659
+ type = "gem";
660
+ };
661
+ version = "1.4.1";
662
+ };
663
+ rake = {
664
+ groups = ["development"];
665
+ platforms = [];
666
+ source = {
667
+ remotes = ["https://rubygems.org"];
668
+ sha256 = "009p524zl0p0kfa65nii8wdmaigkmawv9pbvlcffky7islmmp0nb";
669
+ type = "gem";
670
+ };
671
+ version = "13.4.2";
672
+ };
673
+ rbs = {
674
+ dependencies = ["logger" "prism" "tsort"];
675
+ groups = ["default" "maintenance"];
676
+ platforms = [];
677
+ source = {
678
+ remotes = ["https://rubygems.org"];
679
+ sha256 = "09ggg2zk0qrh0mc3fa23xjbn2gzqxd0jfqj6qm6460ydcqg6fxdg";
680
+ type = "gem";
681
+ };
682
+ version = "4.0.2";
683
+ };
684
+ rdoc = {
685
+ dependencies = ["erb" "psych" "tsort"];
686
+ groups = ["default" "maintenance"];
687
+ platforms = [];
688
+ source = {
689
+ remotes = ["https://rubygems.org"];
690
+ sha256 = "14iiyb4yi1chdzrynrk74xbhmikml3ixgdayjma3p700singfl46";
691
+ type = "gem";
692
+ };
693
+ version = "7.2.0";
694
+ };
695
+ regexp_parser = {
696
+ groups = ["default"];
697
+ platforms = [];
698
+ source = {
699
+ remotes = ["https://rubygems.org"];
700
+ sha256 = "1fwfw26a32rps78920nn29shqg2zmqv72i89j1fap41isshida9m";
701
+ type = "gem";
702
+ };
703
+ version = "2.12.0";
704
+ };
705
+ reline = {
706
+ dependencies = ["io-console"];
707
+ groups = ["default" "maintenance"];
708
+ platforms = [];
709
+ source = {
710
+ remotes = ["https://rubygems.org"];
711
+ sha256 = "0d8q5c4nh2g9pp758kizh8sfrvngynrjlm0i1zn3cnsnfd4v160i";
712
+ type = "gem";
713
+ };
714
+ version = "0.6.3";
715
+ };
716
+ rspec = {
717
+ dependencies = ["rspec-core" "rspec-expectations" "rspec-mocks"];
718
+ groups = ["development"];
719
+ platforms = [];
720
+ source = {
721
+ remotes = ["https://rubygems.org"];
722
+ sha256 = "11q5hagj6vr694innqj4r45jrm8qcwvkxjnphqgyd66piah88qi0";
723
+ type = "gem";
724
+ };
725
+ version = "3.13.2";
726
+ };
727
+ rspec-core = {
728
+ dependencies = ["rspec-support"];
729
+ groups = ["default" "development"];
730
+ platforms = [];
731
+ source = {
732
+ remotes = ["https://rubygems.org"];
733
+ sha256 = "0bcbh9yv6cs6pv299zs4bvalr8yxa51kcdd1pjl60yv625j3r0m8";
734
+ type = "gem";
735
+ };
736
+ version = "3.13.6";
737
+ };
738
+ rspec-expectations = {
739
+ dependencies = ["diff-lcs" "rspec-support"];
740
+ groups = ["default" "development"];
741
+ platforms = [];
742
+ source = {
743
+ remotes = ["https://rubygems.org"];
744
+ sha256 = "0dl8npj0jfpy31bxi6syc7jymyd861q277sfr6jawq2hv6hx791k";
745
+ type = "gem";
746
+ };
747
+ version = "3.13.5";
748
+ };
749
+ rspec-mocks = {
750
+ dependencies = ["diff-lcs" "rspec-support"];
751
+ groups = ["default" "development"];
752
+ platforms = [];
753
+ source = {
754
+ remotes = ["https://rubygems.org"];
755
+ sha256 = "0iqxmw0knjiz5nf6pgr8ihs6cjzh89f0ppj3fqiz8cvms79x6sh8";
756
+ type = "gem";
757
+ };
758
+ version = "3.13.8";
759
+ };
760
+ rspec-support = {
761
+ groups = ["default" "development"];
762
+ platforms = [];
763
+ source = {
764
+ remotes = ["https://rubygems.org"];
765
+ sha256 = "0z64h5rznm2zv21vjdjshz4v0h7bxvg02yc6g7yzxakj11byah06";
766
+ type = "gem";
767
+ };
768
+ version = "3.13.7";
769
+ };
770
+ rubyshell = {
771
+ groups = ["default"];
772
+ platforms = [];
773
+ source = {
774
+ remotes = ["https://rubygems.org"];
775
+ sha256 = "1dkaj6a038m23r2xph0k2jc03i6aq8xzqmf17qpjprb2b50jimgz";
776
+ type = "gem";
777
+ };
778
+ version = "1.5.0";
779
+ };
780
+ rugged = {
781
+ groups = ["default" "maintenance"];
782
+ platforms = [];
783
+ source = {
784
+ remotes = ["https://rubygems.org"];
785
+ sha256 = "1b7gcf6pxg4x607bica68dbz22b4kch33yi0ils6x3c8ql9akakz";
786
+ type = "gem";
787
+ };
788
+ version = "1.9.0";
789
+ };
790
+ samovar = {
791
+ dependencies = ["console" "mapping"];
792
+ groups = ["default" "maintenance"];
793
+ platforms = [];
794
+ source = {
795
+ remotes = ["https://rubygems.org"];
796
+ sha256 = "104y60zqn1mznv1smbzzvhljam193w8w2886c2yf6w87b381vff3";
797
+ type = "gem";
798
+ };
799
+ version = "2.4.1";
800
+ };
801
+ simpleidn = {
802
+ groups = ["default"];
803
+ platforms = [];
804
+ source = {
805
+ remotes = ["https://rubygems.org"];
806
+ sha256 = "0a9c1mdy12y81ck7mcn9f9i2s2wwzjh1nr92ps354q517zq9dkh8";
807
+ type = "gem";
808
+ };
809
+ version = "0.2.3";
810
+ };
811
+ string-format = {
812
+ groups = ["default" "maintenance"];
813
+ platforms = [];
814
+ source = {
815
+ remotes = ["https://rubygems.org"];
816
+ sha256 = "1xlsg0m748bcb4vgvmjxlfsif6nnl8pz6ja52c91y1kb24a1r65w";
817
+ type = "gem";
818
+ };
819
+ version = "0.2.0";
820
+ };
821
+ stringio = {
822
+ groups = ["default" "maintenance"];
823
+ platforms = [];
824
+ source = {
825
+ remotes = ["https://rubygems.org"];
826
+ sha256 = "1q92y9627yisykyscv0bdsrrgyaajc2qr56dwlzx7ysgigjv4z63";
827
+ type = "gem";
828
+ };
829
+ version = "3.2.0";
830
+ };
831
+ thread-local = {
832
+ groups = ["default" "maintenance"];
833
+ platforms = [];
834
+ source = {
835
+ remotes = ["https://rubygems.org"];
836
+ sha256 = "1ryjgfwcsbkxph1l24x87p1yabnnbqy958s57w37iwhf3z9nid9g";
837
+ type = "gem";
838
+ };
839
+ version = "1.1.0";
840
+ };
841
+ timeout = {
842
+ groups = ["default" "maintenance"];
843
+ platforms = [];
844
+ source = {
845
+ remotes = ["https://rubygems.org"];
846
+ sha256 = "1jxcji88mh6xsqz0mfzwnxczpg7cyniph7wpavnavfz7lxl77xbq";
847
+ type = "gem";
848
+ };
849
+ version = "0.6.1";
850
+ };
851
+ traces = {
852
+ groups = ["default" "maintenance"];
853
+ platforms = [];
854
+ source = {
855
+ remotes = ["https://rubygems.org"];
856
+ sha256 = "05722prvh34n96irnxa762wz0yj2nyrz70ab2zby3b6snjf69wc0";
857
+ type = "gem";
858
+ };
859
+ version = "0.18.2";
860
+ };
861
+ tsort = {
862
+ groups = ["default" "maintenance"];
863
+ platforms = [];
864
+ source = {
865
+ remotes = ["https://rubygems.org"];
866
+ sha256 = "17q8h020dw73wjmql50lqw5ddsngg67jfw8ncjv476l5ys9sfl4n";
867
+ type = "gem";
868
+ };
869
+ version = "0.2.0";
870
+ };
871
+ utopia = {
872
+ dependencies = ["bake" "concurrent-ruby" "console" "http-accept" "irb" "mail" "mime-types" "msgpack" "net-smtp" "protocol-url" "rack" "samovar" "traces" "variant" "xrb"];
873
+ groups = ["default" "maintenance"];
874
+ platforms = [];
875
+ source = {
876
+ remotes = ["https://rubygems.org"];
877
+ sha256 = "0d6njl2lw3j68nd34wm6szr7yk8h2xq6a15b1sv8r49rpcddi3l8";
878
+ type = "gem";
879
+ };
880
+ version = "2.32.1";
881
+ };
882
+ utopia-project = {
883
+ dependencies = ["decode" "falcon" "markly" "rackula" "thread-local" "utopia"];
884
+ groups = ["maintenance"];
885
+ platforms = [];
886
+ source = {
887
+ remotes = ["https://rubygems.org"];
888
+ sha256 = "0j4jq3b9y6mly85s16yy6alrlyydzinylh4zly9v7y2bwd2y5604";
889
+ type = "gem";
890
+ };
891
+ version = "0.40.0";
892
+ };
893
+ variant = {
894
+ dependencies = ["thread-local"];
895
+ groups = ["default" "maintenance"];
896
+ platforms = [];
897
+ source = {
898
+ remotes = ["https://rubygems.org"];
899
+ sha256 = "0mizrq6819baz3s0zqwb5qz2dx21k3d0kav6alrcn14kvkfqzssk";
900
+ type = "gem";
901
+ };
902
+ version = "0.1.1";
903
+ };
904
+ xrb = {
905
+ groups = ["default" "maintenance"];
906
+ platforms = [];
907
+ source = {
908
+ remotes = ["https://rubygems.org"];
909
+ sha256 = "0w08kwxw9yll1p2sn2fhczzwgnx6q79ybl1xvkivnn3vig6jls0y";
910
+ type = "gem";
911
+ };
912
+ version = "0.11.2";
913
+ };
914
+ }
@@ -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"]
@@ -86,6 +86,9 @@ module Kube
86
86
  @resources.dup
87
87
  end
88
88
 
89
+ # Ruby pattern matching: `manifest => [Kube::Cluster["Deployment"], *]`.
90
+ def deconstruct = to_a
91
+
89
92
  # -------------------------------------------------------------------
90
93
  # File I/O
91
94
  # -------------------------------------------------------------------
@@ -298,6 +301,21 @@ if __FILE__ == $0
298
301
  end
299
302
  end
300
303
 
304
+ describe "pattern matching" do
305
+ it "destructures into an array of resources" do
306
+ manifest = described_class.new(resource_a, resource_b)
307
+ manifest => [Kube::Schema::Resource => first, *rest]
308
+
309
+ expect(first).to eq(resource_a)
310
+ expect(rest).to eq([resource_b])
311
+ end
312
+
313
+ it "enforces arity" do
314
+ manifest = described_class.new(resource_a, resource_b)
315
+ expect { manifest => [Kube::Schema::Resource] }.to raise_error(NoMatchingPatternError)
316
+ end
317
+ end
318
+
301
319
  describe "#to_a" do
302
320
  it "returns a copy of the internal resources array" do
303
321
  manifest = described_class.new(resource_a, resource_b)
@@ -101,6 +101,11 @@ module Kube
101
101
  other.is_a?(Resource) && to_h == other.to_h
102
102
  end
103
103
 
104
+ # Ruby pattern matching: `resource => {metadata: {name:}}`.
105
+ # to_h is already plain nested symbol-keyed Hashes, so nested
106
+ # patterns work all the way down for free.
107
+ def deconstruct_keys(keys) = to_h
108
+
104
109
  private
105
110
 
106
111
  def deep_compact(obj)
@@ -219,6 +224,20 @@ if __FILE__ == $0
219
224
  end
220
225
  end
221
226
 
227
+ describe "pattern matching" do
228
+ it "destructures nested keys" do
229
+ resource = Kube::Schema["Deployment"].new { metadata.name = "web" }
230
+ resource => {kind: "Deployment", metadata: {name: String => name}}
231
+
232
+ expect(name).to eq("web")
233
+ end
234
+
235
+ it "does not match when a nested value differs" do
236
+ resource = Kube::Schema["Deployment"].new { metadata.name = "web" }
237
+ expect { resource => {metadata: {name: "other"}} }.to raise_error(NoMatchingPatternError)
238
+ end
239
+ end
240
+
222
241
  describe "#==" do
223
242
  it "considers two resources equal when their data matches" do
224
243
  a = Kube::Schema["Pod"].new
@@ -522,6 +541,28 @@ if __FILE__ == $0
522
541
  end
523
542
  end
524
543
 
544
+ describe "pattern matching" do
545
+ let(:deployment) do
546
+ Kube::Schema["Deployment"].new {
547
+ metadata.name = "some-resource"
548
+ metadata.namespace = "prod"
549
+ }
550
+ end
551
+
552
+ it "destructures with a nested hash pattern" do
553
+ deployment => {kind: String => kind, metadata: {name:, namespace:}}
554
+ expect([kind, name, namespace]).to eq(["Deployment", "some-resource", "prod"])
555
+ end
556
+
557
+ it "matches in a case/in" do
558
+ matched = case deployment
559
+ in {metadata: {name: "some-resource"}} then true
560
+ else false
561
+ end
562
+ expect(matched).to be true
563
+ end
564
+ end
565
+
525
566
  describe "instantiation via Instance lookup" do
526
567
  let(:klass) { Kube::Schema["Deployment"] }
527
568
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kube
4
4
  module Schema
5
- VERSION = "1.10.0"
5
+ VERSION = "1.12.0"
6
6
  end
7
7
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kube_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan K
@@ -120,6 +120,7 @@ files:
120
120
  - examples/vcluster.rb
121
121
  - flake.lock
122
122
  - flake.nix
123
+ - gemset.nix
123
124
  - guides/block-dsl/readme.md
124
125
  - guides/getting-started/readme.md
125
126
  - guides/links.yaml