kubernetes-fluent-client 0.0.0-development

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.
package/src/types.ts ADDED
@@ -0,0 +1,186 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
3
+
4
+ import { KubernetesListObject, KubernetesObject, V1ObjectMeta } from "@kubernetes/client-node";
5
+
6
+ export { KubernetesListObject, KubernetesObject };
7
+
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ export type GenericClass = abstract new () => any;
10
+
11
+ export enum Operation {
12
+ CREATE = "CREATE",
13
+ UPDATE = "UPDATE",
14
+ DELETE = "DELETE",
15
+ CONNECT = "CONNECT",
16
+ }
17
+
18
+ /**
19
+ * GenericKind is a generic Kubernetes object that can be used to represent any Kubernetes object
20
+ * that is not explicitly supported. This can be used on its own or as a base class for
21
+ * other types.
22
+ */
23
+ export class GenericKind implements KubernetesObject {
24
+ apiVersion?: string;
25
+ kind?: string;
26
+ metadata?: V1ObjectMeta;
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ [key: string]: any;
29
+ }
30
+
31
+ /**
32
+ * GroupVersionKind unambiguously identifies a kind. It doesn't anonymously include GroupVersion
33
+ * to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
34
+ **/
35
+ export interface GroupVersionKind {
36
+ /** The K8s resource kind, e..g "Pod". */
37
+ readonly kind: string;
38
+ readonly group: string;
39
+ readonly version?: string;
40
+ /** Optional, override the plural name for use in Webhook rules generation */
41
+ readonly plural?: string;
42
+ }
43
+
44
+ /**
45
+ * GroupVersionResource unambiguously identifies a resource. It doesn't anonymously include GroupVersion
46
+ * to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
47
+ */
48
+ export interface GroupVersionResource {
49
+ readonly group: string;
50
+ readonly version: string;
51
+ readonly resource: string;
52
+ }
53
+
54
+ /**
55
+ * A Kubernetes admission request to be processed by a capability.
56
+ */
57
+ export interface Request<T = KubernetesObject> {
58
+ /** UID is an identifier for the individual request/response. */
59
+ readonly uid: string;
60
+
61
+ /** Kind is the fully-qualified type of object being submitted (for example, v1.Pod or autoscaling.v1.Scale) */
62
+ readonly kind: GroupVersionKind;
63
+
64
+ /** Resource is the fully-qualified resource being requested (for example, v1.pods) */
65
+ readonly resource: GroupVersionResource;
66
+
67
+ /** SubResource is the sub-resource being requested, if any (for example, "status" or "scale") */
68
+ readonly subResource?: string;
69
+
70
+ /** RequestKind is the fully-qualified type of the original API request (for example, v1.Pod or autoscaling.v1.Scale). */
71
+ readonly requestKind?: GroupVersionKind;
72
+
73
+ /** RequestResource is the fully-qualified resource of the original API request (for example, v1.pods). */
74
+ readonly requestResource?: GroupVersionResource;
75
+
76
+ /** RequestSubResource is the sub-resource of the original API request, if any (for example, "status" or "scale"). */
77
+ readonly requestSubResource?: string;
78
+
79
+ /**
80
+ * Name is the name of the object as presented in the request. On a CREATE operation, the client may omit name and
81
+ * rely on the server to generate the name. If that is the case, this method will return the empty string.
82
+ */
83
+ readonly name: string;
84
+
85
+ /** Namespace is the namespace associated with the request (if any). */
86
+ readonly namespace?: string;
87
+
88
+ /**
89
+ * Operation is the operation being performed. This may be different than the operation
90
+ * requested. e.g. a patch can result in either a CREATE or UPDATE Operation.
91
+ */
92
+ readonly operation: Operation;
93
+
94
+ /** UserInfo is information about the requesting user */
95
+ readonly userInfo: {
96
+ /** The name that uniquely identifies this user among all active users. */
97
+ username?: string;
98
+
99
+ /**
100
+ * A unique value that identifies this user across time. If this user is deleted
101
+ * and another user by the same name is added, they will have different UIDs.
102
+ */
103
+ uid?: string;
104
+
105
+ /** The names of groups this user is a part of. */
106
+ groups?: string[];
107
+
108
+ /** Any additional information provided by the authenticator. */
109
+ extra?: {
110
+ [key: string]: string[];
111
+ };
112
+ };
113
+
114
+ /** Object is the object from the incoming request prior to default values being applied */
115
+ readonly object: T;
116
+
117
+ /** OldObject is the existing object. Only populated for UPDATE or DELETE requests. */
118
+ readonly oldObject?: T;
119
+
120
+ /** DryRun indicates that modifications will definitely not be persisted for this request. Defaults to false. */
121
+ readonly dryRun?: boolean;
122
+
123
+ /**
124
+ * Options contains the options for the operation being performed.
125
+ * e.g. `meta.k8s.io/v1.DeleteOptions` or `meta.k8s.io/v1.CreateOptions`. This may be
126
+ * different than the options the caller provided. e.g. for a patch request the performed
127
+ * Operation might be a CREATE, in which case the Options will a
128
+ * `meta.k8s.io/v1.CreateOptions` even though the caller provided `meta.k8s.io/v1.PatchOptions`.
129
+ */
130
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
+ readonly options?: any;
132
+ }
133
+
134
+ export interface MutateResponse {
135
+ /** UID is an identifier for the individual request/response. This must be copied over from the corresponding AdmissionRequest. */
136
+ uid: string;
137
+
138
+ /** Allowed indicates whether or not the admission request was permitted. */
139
+ allowed: boolean;
140
+
141
+ /** Result contains extra details into why an admission request was denied. This field IS NOT consulted in any way if "Allowed" is "true". */
142
+ result?: string;
143
+
144
+ /** The patch body. Currently we only support "JSONPatch" which implements RFC 6902. */
145
+ patch?: string;
146
+
147
+ /** The type of Patch. Currently we only allow "JSONPatch". */
148
+ patchType?: "JSONPatch";
149
+
150
+ /**
151
+ * AuditAnnotations is an unstructured key value map set by remote admission controller (e.g. error=image-blacklisted).
152
+ *
153
+ * See https://kubernetes.io/docs/reference/labels-annotations-taints/audit-annotations/ for more information
154
+ */
155
+ auditAnnotations?: {
156
+ [key: string]: string;
157
+ };
158
+
159
+ /** warnings is a list of warning messages to return to the requesting API client. */
160
+ warnings?: string[];
161
+ }
162
+
163
+ export interface ValidateResponse extends MutateResponse {
164
+ /** Status contains extra details into why an admission request was denied. This field IS NOT consulted in any way if "Allowed" is "true". */
165
+ status?: {
166
+ /** A machine-readable description of why this operation is in the
167
+ "Failure" status. If this value is empty there is no information available. */
168
+ code: number;
169
+
170
+ /** A human-readable description of the status of this operation. */
171
+ message: string;
172
+ };
173
+ }
174
+
175
+ // Special types to handle the recursive keyof typescript lookup
176
+ type Join<K, P> = K extends string | number
177
+ ? P extends string | number
178
+ ? `${K}${"" extends P ? "" : "."}${P}`
179
+ : never
180
+ : never;
181
+
182
+ export type Paths<T, D extends number = 10> = [D] extends [never]
183
+ ? never
184
+ : T extends object
185
+ ? { [K in keyof T]-?: K extends string | number ? `${K}` | Join<K, Paths<T[K]>> : never }[keyof T]
186
+ : "";
@@ -0,0 +1,53 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
3
+
4
+ /** a is a collection of K8s types to be used within an action: `When(a.Configmap)` */
5
+ export {
6
+ CoreV1Event as Event,
7
+ V1APIService as APIService,
8
+ V1CertificateSigningRequest as CertificateSigningRequest,
9
+ V1ClusterRole as ClusterRole,
10
+ V1ClusterRoleBinding as ClusterRoleBinding,
11
+ V1ConfigMap as ConfigMap,
12
+ V1ControllerRevision as ControllerRevision,
13
+ V1CronJob as CronJob,
14
+ V1CSIDriver as CSIDriver,
15
+ V1CustomResourceDefinition as CustomResourceDefinition,
16
+ V1DaemonSet as DaemonSet,
17
+ V1Deployment as Deployment,
18
+ V1EndpointSlice as EndpointSlice,
19
+ V1HorizontalPodAutoscaler as HorizontalPodAutoscaler,
20
+ V1Ingress as Ingress,
21
+ V1IngressClass as IngressClass,
22
+ V1Job as Job,
23
+ V1LimitRange as LimitRange,
24
+ V1LocalSubjectAccessReview as LocalSubjectAccessReview,
25
+ V1MutatingWebhookConfiguration as MutatingWebhookConfiguration,
26
+ V1Namespace as Namespace,
27
+ V1NetworkPolicy as NetworkPolicy,
28
+ V1Node as Node,
29
+ V1PersistentVolume as PersistentVolume,
30
+ V1PersistentVolumeClaim as PersistentVolumeClaim,
31
+ V1Pod as Pod,
32
+ V1PodDisruptionBudget as PodDisruptionBudget,
33
+ V1PodTemplate as PodTemplate,
34
+ V1ReplicaSet as ReplicaSet,
35
+ V1ReplicationController as ReplicationController,
36
+ V1ResourceQuota as ResourceQuota,
37
+ V1Role as Role,
38
+ V1RoleBinding as RoleBinding,
39
+ V1RuntimeClass as RuntimeClass,
40
+ V1Secret as Secret,
41
+ V1SelfSubjectAccessReview as SelfSubjectAccessReview,
42
+ V1SelfSubjectRulesReview as SelfSubjectRulesReview,
43
+ V1Service as Service,
44
+ V1ServiceAccount as ServiceAccount,
45
+ V1StatefulSet as StatefulSet,
46
+ V1StorageClass as StorageClass,
47
+ V1SubjectAccessReview as SubjectAccessReview,
48
+ V1TokenReview as TokenReview,
49
+ V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration,
50
+ V1VolumeAttachment as VolumeAttachment,
51
+ } from "@kubernetes/client-node";
52
+
53
+ export { GenericKind } from "./types";
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "declarationMap": true,
5
+ "esModuleInterop": true,
6
+ "lib": ["ES2022"],
7
+ "module": "CommonJS",
8
+ "moduleResolution": "node",
9
+ "outDir": "dist",
10
+ "resolveJsonModule": true,
11
+ "rootDir": "src",
12
+ "strict": true,
13
+ "target": "ES2022",
14
+ "useUnknownInCatchVariables": false
15
+ },
16
+ "include": ["src/**/*.ts"],
17
+ "exclude": ["node_modules", "dist"]
18
+ }