Skip to content

Commit c74186b

Browse files
committed
refactor: reorganize volume-related interfaces and types for better structure and clarity
1 parent a2efdc1 commit c74186b

File tree

2 files changed

+215
-168
lines changed

2 files changed

+215
-168
lines changed

src/lib/kuview/pod.ts

Lines changed: 5 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
import type { KubernetesObject, Metadata, ResourceList } from "./types";
12
import type {
2-
KubernetesObject,
3-
Metadata,
4-
ResourceList,
5-
KeyToPath,
6-
LabelSelector,
7-
} from "./types";
3+
Volume,
4+
ObjectFieldSelector,
5+
ResourceFieldSelector,
6+
} from "./volume";
87

98
export interface PodObject extends KubernetesObject {
109
kind: "Pod";
@@ -61,17 +60,6 @@ interface EnvVarSource {
6160
secretKeyRef?: SecretKeySelector;
6261
}
6362

64-
interface ObjectFieldSelector {
65-
apiVersion?: string;
66-
fieldPath: string;
67-
}
68-
69-
interface ResourceFieldSelector {
70-
containerName?: string;
71-
resource: string;
72-
divisor?: string;
73-
}
74-
7563
interface ConfigMapKeySelector {
7664
name?: string;
7765
key: string;
@@ -147,87 +135,6 @@ interface Toleration {
147135
value?: string;
148136
}
149137

150-
export interface Volume {
151-
name: string;
152-
persistentVolumeClaim?: PersistentVolumeClaimVolumeSource;
153-
hostPath?: HostPathVolumeSource;
154-
projected?: ProjectedVolumeSource;
155-
configMap?: ConfigMapVolumeSource;
156-
secret?: SecretVolumeSource;
157-
emptyDir?: EmptyDirVolumeSource;
158-
ephemeral?: EphemeralVolumeSource;
159-
}
160-
161-
interface PersistentVolumeClaimVolumeSource {
162-
claimName: string;
163-
readOnly?: boolean;
164-
}
165-
166-
interface HostPathVolumeSource {
167-
path: string;
168-
type?: string;
169-
}
170-
171-
interface ProjectedVolumeSource {
172-
defaultMode?: number;
173-
sources?: VolumeProjection[];
174-
}
175-
176-
interface VolumeProjection {
177-
configMap?: ConfigMapProjection;
178-
downwardAPI?: DownwardAPIProjection;
179-
secret?: SecretProjection;
180-
serviceAccountToken?: ServiceAccountTokenProjection;
181-
}
182-
183-
interface ConfigMapProjection {
184-
name?: string;
185-
items?: KeyToPath[];
186-
optional?: boolean;
187-
}
188-
189-
interface DownwardAPIProjection {
190-
items?: DownwardAPIVolumeFile[];
191-
}
192-
193-
interface SecretProjection {
194-
name?: string;
195-
items?: KeyToPath[];
196-
optional?: boolean;
197-
}
198-
199-
interface ServiceAccountTokenProjection {
200-
audience?: string;
201-
expirationSeconds?: number;
202-
path: string;
203-
}
204-
205-
interface DownwardAPIVolumeFile {
206-
fieldRef?: ObjectFieldSelector;
207-
mode?: number;
208-
path: string;
209-
resourceFieldRef?: ResourceFieldSelector;
210-
}
211-
212-
interface ConfigMapVolumeSource {
213-
name?: string;
214-
defaultMode?: number;
215-
items?: KeyToPath[];
216-
optional?: boolean;
217-
}
218-
219-
interface SecretVolumeSource {
220-
secretName?: string;
221-
defaultMode?: number;
222-
items?: KeyToPath[];
223-
optional?: boolean;
224-
}
225-
226-
interface EmptyDirVolumeSource {
227-
medium?: string;
228-
sizeLimit?: string;
229-
}
230-
231138
interface PodStatus {
232139
conditions?: PodCondition[];
233140
phase: "Pending" | "Running" | "Succeeded" | "Failed" | "Unknown";
@@ -291,58 +198,3 @@ interface PodCondition {
291198
message?: string;
292199
reason?: string;
293200
}
294-
295-
export interface Volume {
296-
name: string;
297-
volumeSource: VolumeSource;
298-
}
299-
300-
export interface VolumeSource {
301-
hostPath?: HostPathVolumeSource;
302-
emptyDir?: EmptyDirVolumeSource;
303-
secret?: SecretVolumeSource;
304-
persistentVolumeClaim?: PersistentVolumeClaimVolumeSource;
305-
configMap?: ConfigMapVolumeSource;
306-
ephemeral?: EphemeralVolumeSource;
307-
}
308-
309-
export type HostPathType =
310-
| ""
311-
| "DirectoryOrCreate"
312-
| "Directory"
313-
| "FileOrCreate"
314-
| "File"
315-
| "Socket"
316-
| "CharDevice"
317-
| "BlockDevice";
318-
319-
export interface EphemeralVolumeSource {
320-
volumeClaimTemplate?: PersistentVolumeClaimTemplate;
321-
}
322-
323-
export interface PersistentVolumeClaimTemplate {
324-
metadata?: Metadata;
325-
spec: PersistentVolumeClaimSpec;
326-
}
327-
328-
export type PersistentVolumeAccessMode =
329-
| "ReadWriteOnce"
330-
| "ReadOnlyMany"
331-
| "ReadWriteMany"
332-
| "ReadWriteOncePod";
333-
334-
export interface VolumeResourceRequirements {
335-
limits?: ResourceList;
336-
requests?: ResourceList;
337-
}
338-
339-
export type PersistentVolumeMode = "Block" | "Filesystem";
340-
341-
export interface PersistentVolumeClaimSpec {
342-
accessModes?: PersistentVolumeAccessMode[];
343-
selector?: LabelSelector;
344-
resources?: VolumeResourceRequirements;
345-
volumeName?: string;
346-
storageClassName?: string;
347-
volumeMode?: PersistentVolumeMode;
348-
}

0 commit comments

Comments
 (0)