Skip to content

Commit 562423c

Browse files
authored
Regenerate APIs for Kubernetes 1.32 et al (#19)
* chore: Deduplicate knownOpts into new file * Regenerate APIs from Kubernetes 1.32.0 et al * Update JSR imports * Update README for 0.5.4 * fix readme typo
1 parent 9760fdc commit 562423c

File tree

33 files changed

+3774
-3076
lines changed

33 files changed

+3774
-3076
lines changed

generation/codegen-mod.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
import { SurfaceMap, SurfaceApi, SurfaceOperation } from "./describe-surface.ts";
22
import { OpenAPI2RequestParameter } from "./openapi.ts";
33
import { ApiShape } from "./describe-shapes.ts";
4+
import { knownOptsReverse } from "./known-opts.ts";
45

5-
const knownOpts: Record<string,string|undefined> = {
6-
'': 'NoOpts',
7-
'continue,fieldSelector,labelSelector,limit,resourceVersion,resourceVersionMatch,sendInitialEvents,timeoutSeconds': 'GetListOpts',
8-
'allowWatchBookmarks,fieldSelector,labelSelector,resourceVersion,resourceVersionMatch,sendInitialEvents,timeoutSeconds': 'WatchListOpts',
9-
'dryRun,fieldManager,fieldValidation': 'PutOpts', // both CreateOpts and ReplaceOpts
10-
'continue,dryRun,fieldSelector,gracePeriodSeconds,labelSelector,limit,orphanDependents,propagationPolicy,resourceVersion,resourceVersionMatch,sendInitialEvents,timeoutSeconds': 'DeleteListOpts',
11-
'dryRun,fieldManager,fieldValidation,force': 'PatchOpts',
12-
'exact,export': 'GetOpts',
13-
'dryRun,gracePeriodSeconds,orphanDependents,propagationPolicy': 'DeleteOpts',
14-
};
6+
const knownOpts = knownOptsReverse;
157

168
export function generateModuleTypescript(surface: SurfaceMap, api: SurfaceApi): string {
179
const chunks = new Array<string>();

generation/generate-all.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/bin/sh -eux
22

33
# https://github.com/kubernetes/kubernetes/releases
4-
./generation/sources/builtin.sh v1.30.4
4+
./generation/sources/builtin.sh v1.32.0
55

66
# https://github.com/argoproj/argo-cd/releases
7-
./generation/sources/argo-cd.sh v2.12.3
7+
./generation/sources/argo-cd.sh v2.13.3
88

99
# https://github.com/cert-manager/cert-manager/releases
10-
./generation/sources/cert-manager.sh v1.15.3
10+
./generation/sources/cert-manager.sh v1.16.2
1111

1212
# https://github.com/kubernetes-sigs/external-dns/releases
13-
./generation/sources/external-dns.sh v0.15.0
13+
./generation/sources/external-dns.sh v0.15.1
1414

1515
# https://github.com/kubernetes/autoscaler/releases?q=vertical
1616
./generation/sources/vpa.sh 1.2.1

generation/known-opts.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
export const knownOptsForward = {
3+
GetListOpts: 'continue,fieldSelector,labelSelector,limit,resourceVersion,resourceVersionMatch,sendInitialEvents,timeoutSeconds',
4+
WatchListOpts: 'allowWatchBookmarks,fieldSelector,labelSelector,resourceVersion,resourceVersionMatch,sendInitialEvents,timeoutSeconds',
5+
PutOpts: 'dryRun,fieldManager,fieldValidation', // both CreateOpts and ReplaceOpts
6+
DeleteListOpts: 'continue,dryRun,fieldSelector,gracePeriodSeconds,ignoreStoreReadErrorWithClusterBreakingPotential,labelSelector,limit,orphanDependents,propagationPolicy,resourceVersion,resourceVersionMatch,sendInitialEvents,timeoutSeconds',
7+
PatchOpts: 'dryRun,fieldManager,fieldValidation,force',
8+
GetOpts: '',
9+
DeleteOpts: 'dryRun,gracePeriodSeconds,ignoreStoreReadErrorWithClusterBreakingPotential,orphanDependents,propagationPolicy',
10+
};
11+
12+
export const knownOptsReverse: Record<string,string|undefined> = {
13+
'': 'NoOpts',
14+
[knownOptsForward.GetListOpts]: 'GetListOpts',
15+
[knownOptsForward.WatchListOpts]: 'WatchListOpts',
16+
[knownOptsForward.PutOpts]: 'PutOpts', // both CreateOpts and ReplaceOpts
17+
[knownOptsForward.DeleteListOpts]: 'DeleteListOpts',
18+
[knownOptsForward.PatchOpts]: 'PatchOpts',
19+
'exact,export': 'GetOpts',
20+
[knownOptsForward.DeleteOpts]: 'DeleteOpts',
21+
};

generation/run-on-crds.ts

+3-10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { OpenAPI2SchemaObject, OpenAPI2Methods, OpenAPI2PathMethod } from '
33
import { writeApiModule } from "./codegen.ts";
44
import { SurfaceMap, SurfaceApi, OpScope } from "./describe-surface.ts";
55
import { ShapeLibrary } from "./describe-shapes.ts";
6+
import { knownOptsForward } from "./known-opts.ts";
67

78
import {
89
CustomResourceDefinition as CRDv1,
@@ -11,18 +12,10 @@ import {
1112
CustomResourceDefinitionNames,
1213
} from "../lib/builtin/apiextensions.k8s.io@v1/structs.ts";
1314

14-
const knownOpts = {
15-
GetListOpts: 'continue,fieldSelector,labelSelector,limit,resourceVersion,resourceVersionMatch,sendInitialEvents,timeoutSeconds',
16-
WatchListOpts: 'allowWatchBookmarks,fieldSelector,labelSelector,resourceVersion,resourceVersionMatch,sendInitialEvents,timeoutSeconds',
17-
PutOpts: 'dryRun,fieldManager,fieldValidation', // both CreateOpts and ReplaceOpts
18-
DeleteListOpts: 'continue,dryRun,fieldSelector,gracePeriodSeconds,labelSelector,limit,orphanDependents,propagationPolicy,resourceVersion,resourceVersionMatch,sendInitialEvents,timeoutSeconds',
19-
PatchOpts: 'dryRun,fieldManager,fieldValidation,force',
20-
GetOpts: '',
21-
DeleteOpts: 'dryRun,gracePeriodSeconds,orphanDependents,propagationPolicy',
22-
};
23-
2415
const v1CRDs = new Array<CRDv1>();
2516

17+
const knownOpts = knownOptsForward;
18+
2619
for await (const dirEntry of Deno.readDir(Deno.args[0])) {
2720
if (!dirEntry.isFile) continue;
2821
if (!dirEntry.name.endsWith('.yaml')) continue;

lib/README.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Here's a basic request, listing all Pods in the `default` namespace.
1414
It uses the `autoDetectClient()` entrypoint which returns the first usable client.
1515

1616
```ts
17-
import { autoDetectClient } from 'https://deno.land/x/[email protected].0/mod.ts';
17+
import { autoDetectClient } from 'https://deno.land/x/[email protected].3/mod.ts';
1818
import { CoreV1Api } from 'https://deno.land/x/kubernetes_apis/builtin/core@v1/mod.ts';
1919

2020
const kubernetes = await autoDetectClient();
@@ -30,8 +30,31 @@ When running locally (with `kubectl` set up), you probably just to add `--allow-
3030
For a container being deployed onto a cluster, there's more flags to provide instead;
3131
see `/x/kubernetes_client` for more information.
3232

33+
34+
### Usage with JSR Imports
35+
Note that there is no default export, so you will need to
36+
import the particular Kubernetes API groups that you want to work with.
37+
This layout keeps program size smaller.
38+
39+
```ts
40+
import { autoDetectClient } from "jsr:@cloudydeno/[email protected]";
41+
import { CoreV1Api } from "jsr:@cloudydeno/kubernetes-apis/core/v1";
42+
43+
const kubernetes = await autoDetectClient();
44+
const coreApi = new CoreV1Api(kubernetes).namespace("default");
45+
46+
const podList = await coreApi.getPodList();
47+
console.log(podList);
48+
```
49+
3350
## Changelog
3451

52+
* `v0.5.4` on `2025-01-18`:
53+
* Includes 'builtin' APIs generated from K8s `v1.32.0`.
54+
* Several API versions were changed, removed, or added.
55+
* You may need to update imports if you used a non-stable API version which has been moved.
56+
* `cert-manager` and `argo-cd` CRDs have been updated.
57+
3558
* `v0.5.3` on `2024-10-16`:
3659
* Fix CRD codegen issues with particular definitions and when using JSR import paths.
3760

0 commit comments

Comments
 (0)