@@ -7,190 +7,6 @@ export interface YamlExample {
77 resourceType : string ;
88}
99
10- export const yamlExamples : YamlExample [ ] = [
11- {
12- title : 'Sample Pod' ,
13- filename : 'sample-pod.yaml' ,
14- resourceType : 'Pod' ,
15- yaml : `apiVersion: v1
16- kind: Pod
17- metadata:
18- name: sample-pod
19- namespace: default
20- spec:
21- containers:
22- - name: nginx
23- image: nginx:alpine
24- ports:
25- - containerPort: 80` ,
26- } ,
27- {
28- title : 'Sample Deployment' ,
29- filename : 'sample-deployment.yaml' ,
30- resourceType : 'Deployment' ,
31- yaml : `apiVersion: apps/v1
32- kind: Deployment
33- metadata:
34- name: sample-deployment
35- namespace: default
36- spec:
37- replicas: 3
38- selector:
39- matchLabels:
40- app: sample-app
41- template:
42- metadata:
43- labels:
44- app: sample-app
45- spec:
46- containers:
47- - name: sample-container
48- image: nginx:stable
49- ports:
50- - containerPort: 80` ,
51- } ,
52- {
53- title : 'Sample Service' ,
54- filename : 'sample-service.yaml' ,
55- resourceType : 'Service' ,
56- yaml : `apiVersion: v1
57- kind: Service
58- metadata:
59- name: sample-service
60- namespace: default
61- spec:
62- selector:
63- app: sample-app
64- ports:
65- - protocol: TCP
66- port: 80
67- targetPort: 80
68- type: ClusterIP` ,
69- } ,
70- {
71- title : 'Sample Ingress' ,
72- filename : 'sample-ingress.yaml' ,
73- resourceType : 'Ingress' ,
74- yaml : `apiVersion: networking.k8s.io/v1
75- kind: Ingress
76- metadata:
77- name: sample-ingress
78- namespace: default
79- annotations:
80- nginx.ingress.kubernetes.io/rewrite-target: /
81- spec:
82- rules:
83- - host: example.local
84- http:
85- paths:
86- - path: /
87- pathType: Prefix
88- backend:
89- service:
90- name: sample-service
91- port:
92- number: 80` ,
93- } ,
94- {
95- title : 'Sample ConfigMap' ,
96- filename : 'sample-configmap.yaml' ,
97- resourceType : 'ConfigMap' ,
98- yaml : `apiVersion: v1
99- kind: ConfigMap
100- metadata:
101- name: sample-config
102- namespace: default
103- data:
104- sample.property: "Hello, Kubernetes!"
105- another.property: "This is a sample value."` ,
106- } ,
107- {
108- title : 'Sample Secret' ,
109- filename : 'sample-secret.yaml' ,
110- resourceType : 'Secret' ,
111- yaml : `apiVersion: v1
112- kind: Secret
113- metadata:
114- name: sample-secret
115- namespace: default
116- type: Opaque
117- data:
118- # These values are base64-encoded. For example, "admin" becomes "YWRtaW4="
119- username: YWRtaW4=
120- password: c2VjcmV0` ,
121- } ,
122- {
123- title : 'Sample Namespace' ,
124- filename : 'sample-namespace.yaml' ,
125- resourceType : 'Namespace' ,
126- yaml : `apiVersion: v1
127- kind: Namespace
128- metadata:
129- name: sample-namespace` ,
130- } ,
131- {
132- title : 'Sample Job' ,
133- filename : 'sample-job.yaml' ,
134- resourceType : 'Job' ,
135- yaml : `apiVersion: batch/v1
136- kind: Job
137- metadata:
138- name: sample-job
139- namespace: default
140- spec:
141- template:
142- metadata:
143- name: sample-job
144- spec:
145- containers:
146- - name: job
147- image: busybox
148- command: ["echo", "Hello from the Job!"]
149- restartPolicy: Never
150- backoffLimit: 4` ,
151- } ,
152- {
153- title : 'Sample CronJob' ,
154- filename : 'sample-cronjob.yaml' ,
155- resourceType : 'CronJob' ,
156- yaml : `apiVersion: batch/v1
157- kind: CronJob
158- metadata:
159- name: sample-cronjob
160- namespace: default
161- spec:
162- schedule: "*/5 * * * *"
163- jobTemplate:
164- spec:
165- template:
166- spec:
167- containers:
168- - name: cronjob
169- image: busybox
170- args:
171- - /bin/sh
172- - -c
173- - date; echo "Hello from the CronJob!"
174- restartPolicy: OnFailure` ,
175- } ,
176- {
177- title : 'Sample PersistentVolumeClaim' ,
178- filename : 'sample-pvc.yaml' ,
179- resourceType : 'PersistentVolumeClaim' ,
180- yaml : `apiVersion: v1
181- kind: PersistentVolumeClaim
182- metadata:
183- name: sample-pvc
184- namespace: default
185- spec:
186- accessModes:
187- - ReadWriteOnce
188- resources:
189- requests:
190- storage: 1Gi` ,
191- } ,
192- ] ;
193-
19410// Function to validate and parse YAML to extract resource type and metadata
19511export function parseKubernetesYAML ( yamlStr : string ) : {
19612 isValid : boolean ;
0 commit comments