@@ -101,13 +101,46 @@ export async function paginatedClusterArgoRolloutList(): Promise<{
101101export async function argoRolloutWatchHandler (
102102 rollout : V1alpha1Rollout ,
103103) : Promise < void > {
104+ if ( rollout . spec ?. workloadRef && rollout . metadata ?. namespace ) {
105+ // Attempt to load workloadRef if a template is not directly defined
106+ const workloadName = rollout . spec . workloadRef . name ;
107+ const namespace = rollout . metadata . namespace ;
108+ switch ( rollout . spec . workloadRef . kind ) {
109+ // Perform lookup for known supported kinds: https://github.com/argoproj/argo-rollouts/blob/master/rollout/templateref.go#L40-L52
110+ case 'Deployment' : {
111+ const deployResult = await retryKubernetesApiRequest ( ( ) =>
112+ k8sApi . appsClient . readNamespacedDeployment ( workloadName , namespace ) ,
113+ ) ;
114+ rollout . spec . template = deployResult . body . spec ?. template ;
115+ break ;
116+ }
117+ case 'ReplicaSet' : {
118+ const replicaSetResult = await retryKubernetesApiRequest ( ( ) =>
119+ k8sApi . appsClient . readNamespacedReplicaSet ( workloadName , namespace ) ,
120+ ) ;
121+ rollout . spec . template = replicaSetResult . body . spec ?. template ;
122+ break ;
123+ }
124+ case 'PodTemplate' : {
125+ const podTemplateResult = await retryKubernetesApiRequest ( ( ) =>
126+ k8sApi . coreClient . readNamespacedPodTemplate ( workloadName , namespace ) ,
127+ ) ;
128+ rollout . spec . template = podTemplateResult . body . template ;
129+ break ;
130+ }
131+ default :
132+ logger . debug (
133+ { workloadKind : WorkloadKind . ArgoRollout } ,
134+ 'Unsupported workloadRef kind specified' ,
135+ ) ;
136+ }
137+ }
104138 rollout = trimWorkload ( rollout ) ;
105139
106140 if (
107141 ! rollout . metadata ||
108- ! rollout . spec ||
109- ! rollout . spec . template . metadata ||
110- ! rollout . spec . template . spec ||
142+ ! rollout . spec ?. template ?. metadata ||
143+ ! rollout . spec ?. template ?. spec ||
111144 ! rollout . status
112145 ) {
113146 return ;
0 commit comments