@@ -199,11 +199,7 @@ async Task CreatePod(StartKubernetesScriptCommandV1 command, IScriptWorkspace wo
199199 {
200200 Name = podName ,
201201 NamespaceProperty = KubernetesConfig . Namespace ,
202- Labels = new Dictionary < string , string >
203- {
204- [ "octopus.com/serverTaskId" ] = command . TaskId ,
205- [ "octopus.com/scriptTicketId" ] = command . ScriptTicket . TaskId
206- } ,
202+ Labels = GetScriptPodLabels ( tentacleScriptLog , command ) ,
207203 Annotations = ParseScriptPodAnnotations ( tentacleScriptLog )
208204 } ,
209205 Spec = new V1PodSpec
@@ -419,6 +415,29 @@ V1Affinity ParseScriptPodAffinity(InMemoryTentacleScriptLog tentacleScriptLog)
419415 KubernetesConfig . PodAnnotationsJsonVariableName ,
420416 "pod annotations" ) ;
421417
418+ Dictionary < string , string > ? GetScriptPodLabels ( InMemoryTentacleScriptLog tentacleScriptLog , StartKubernetesScriptCommandV1 command )
419+ {
420+ var labels = new Dictionary < string , string >
421+ {
422+ [ "octopus.com/serverTaskId" ] = command . TaskId ,
423+ [ "octopus.com/scriptTicketId" ] = command . ScriptTicket . TaskId
424+ } ;
425+ var extraLabels = ParseScriptPodJson < Dictionary < string , string > > (
426+ tentacleScriptLog ,
427+ KubernetesConfig . PodLabelsJson ,
428+ KubernetesConfig . PodLabelsJsonVariableName ,
429+ "pod labels" ) ;
430+
431+ if ( extraLabels != null )
432+ {
433+ labels . AddRange ( extraLabels ) ;
434+ }
435+
436+ return labels ;
437+ }
438+
439+
440+
422441 [ return : NotNullIfNotNull ( "defaultValue" ) ]
423442 T ? ParseScriptPodJson < T > ( InMemoryTentacleScriptLog tentacleScriptLog , string ? json , string envVarName , string description , T ? defaultValue = null ) where T : class
424443 {
0 commit comments