@@ -5,10 +5,11 @@ import { k8sApi } from './cluster';
55import { IKubeObjectMetadata , WorkloadKind } from './types' ;
66import logger = require( '../common/logger' ) ;
77
8+ type IKubeObjectMetadataWithoutPodSpec = Omit < IKubeObjectMetadata , 'podSpec' > ;
89type IWorkloadReaderFunc = (
910 workloadName : string ,
1011 namespace : string ,
11- ) => Promise < IKubeObjectMetadata | undefined > ;
12+ ) => Promise < IKubeObjectMetadataWithoutPodSpec | undefined > ;
1213
1314const deploymentReader : IWorkloadReaderFunc = async ( workloadName , namespace ) => {
1415 const deploymentResult = await kubernetesApiWrappers . retryKubernetesApiRequest (
@@ -22,14 +23,14 @@ const deploymentReader: IWorkloadReaderFunc = async (workloadName, namespace) =>
2223 return undefined ;
2324 }
2425
25- return {
26+ const metadata : IKubeObjectMetadataWithoutPodSpec = {
2627 kind : WorkloadKind . Deployment ,
2728 objectMeta : deployment . metadata ,
2829 specMeta : deployment . spec . template . metadata ,
2930 ownerRefs : deployment . metadata . ownerReferences ,
3031 revision : deployment . status . observedGeneration ,
31- podSpec : deployment . spec . template . spec ,
3232 } ;
33+ return metadata ;
3334} ;
3435
3536const replicaSetReader : IWorkloadReaderFunc = async ( workloadName , namespace ) => {
@@ -44,14 +45,14 @@ const replicaSetReader: IWorkloadReaderFunc = async (workloadName, namespace) =>
4445 return undefined ;
4546 }
4647
47- return {
48+ const metadata : IKubeObjectMetadataWithoutPodSpec = {
4849 kind : WorkloadKind . ReplicaSet ,
4950 objectMeta : replicaSet . metadata ,
5051 specMeta : replicaSet . spec . template . metadata ,
5152 ownerRefs : replicaSet . metadata . ownerReferences ,
5253 revision : replicaSet . status . observedGeneration ,
53- podSpec : replicaSet . spec . template . spec ,
5454 } ;
55+ return metadata ;
5556} ;
5657
5758const statefulSetReader : IWorkloadReaderFunc = async ( workloadName , namespace ) => {
@@ -66,14 +67,14 @@ const statefulSetReader: IWorkloadReaderFunc = async (workloadName, namespace) =
6667 return undefined ;
6768 }
6869
69- return {
70+ const metadata : IKubeObjectMetadataWithoutPodSpec = {
7071 kind : WorkloadKind . StatefulSet ,
7172 objectMeta : statefulSet . metadata ,
7273 specMeta : statefulSet . spec . template . metadata ,
7374 ownerRefs : statefulSet . metadata . ownerReferences ,
7475 revision : statefulSet . status . observedGeneration ,
75- podSpec : statefulSet . spec . template . spec ,
7676 } ;
77+ return metadata ;
7778} ;
7879
7980const daemonSetReader : IWorkloadReaderFunc = async ( workloadName , namespace ) => {
@@ -88,14 +89,14 @@ const daemonSetReader: IWorkloadReaderFunc = async (workloadName, namespace) =>
8889 return undefined ;
8990 }
9091
91- return {
92+ const metadata : IKubeObjectMetadataWithoutPodSpec = {
9293 kind : WorkloadKind . DaemonSet ,
9394 objectMeta : daemonSet . metadata ,
9495 specMeta : daemonSet . spec . template . metadata ,
9596 ownerRefs : daemonSet . metadata . ownerReferences ,
9697 revision : daemonSet . status . observedGeneration ,
97- podSpec : daemonSet . spec . template . spec ,
9898 } ;
99+ return metadata ;
99100} ;
100101
101102const jobReader : IWorkloadReaderFunc = async ( workloadName , namespace ) => {
@@ -109,13 +110,13 @@ const jobReader: IWorkloadReaderFunc = async (workloadName, namespace) => {
109110 return undefined ;
110111 }
111112
112- return {
113+ const metadata : IKubeObjectMetadataWithoutPodSpec = {
113114 kind : WorkloadKind . Job ,
114115 objectMeta : job . metadata ,
115116 specMeta : job . spec . template . metadata ,
116117 ownerRefs : job . metadata . ownerReferences ,
117- podSpec : job . spec . template . spec ,
118118 } ;
119+ return metadata ;
119120} ;
120121
121122// Keep an eye on this! We need v1beta1 API for CronJobs.
@@ -133,13 +134,13 @@ const cronJobReader: IWorkloadReaderFunc = async (workloadName, namespace) => {
133134 return undefined ;
134135 }
135136
136- return {
137+ const metadata : IKubeObjectMetadataWithoutPodSpec = {
137138 kind : WorkloadKind . CronJob ,
138139 objectMeta : cronJob . metadata ,
139140 specMeta : cronJob . spec . jobTemplate . metadata ,
140141 ownerRefs : cronJob . metadata . ownerReferences ,
141- podSpec : cronJob . spec . jobTemplate . spec . template . spec ,
142142 } ;
143+ return metadata ;
143144} ;
144145
145146const replicationControllerReader : IWorkloadReaderFunc = async ( workloadName , namespace ) => {
@@ -155,14 +156,14 @@ const replicationControllerReader: IWorkloadReaderFunc = async (workloadName, na
155156 return undefined ;
156157 }
157158
158- return {
159+ const metadata : IKubeObjectMetadataWithoutPodSpec = {
159160 kind : WorkloadKind . ReplicationController ,
160161 objectMeta : replicationController . metadata ,
161162 specMeta : replicationController . spec . template . metadata ,
162163 ownerRefs : replicationController . metadata . ownerReferences ,
163164 revision : replicationController . status . observedGeneration ,
164- podSpec : replicationController . spec . template . spec ,
165165 } ;
166+ return metadata ;
166167} ;
167168
168169function logIncompleteWorkload ( workloadName : string , namespace : string ) : void {
0 commit comments