sonmezonur commented on code in PR #33174:
URL: https://github.com/apache/airflow/pull/33174#discussion_r1294357934


##########
tests/providers/cncf/kubernetes/operators/test_pod.py:
##########
@@ -920,6 +921,64 @@ def test_pod_template_file_kwargs_override(self, 
randomize_name, pod_template_fi
             "run_id": "test",
         }
 
+    @pytest.mark.parametrize(("randomize_name",), ([True], [False]))
+    def test_pod_template_dict(self, randomize_name):
+        templated_pod = k8s.V1Pod(
+            metadata=k8s.V1ObjectMeta(
+                namespace="templatenamespace",
+                name="hello",
+                labels={"release": "stable"},
+            ),
+            spec=k8s.V1PodSpec(
+                containers=[],
+                init_containers=[
+                    k8s.V1Container(
+                        name="git-clone",
+                        image="registry.k8s.io/git-sync:v3.1.1",
+                        args=[
+                            "[email protected]:airflow/some_repo.git",
+                            "--branch={{ params.get('repo_branch', 'master') 
}}",
+                        ],
+                    ),
+                ],
+            ),
+        )
+        k = KubernetesPodOperator(
+            task_id="task",
+            random_name_suffix=randomize_name,
+            
pod_template_dict=pod_generator.PodGenerator.serialize_pod(templated_pod),

Review Comment:
   My first intention was to make `full_pod_spec` field templated instead of 
adding a new field. But templater does not resolve `V1Pod` as you referred. I 
might have a simple solution, will try once I have some time 🤞 



##########
tests/providers/cncf/kubernetes/operators/test_pod.py:
##########
@@ -920,6 +921,64 @@ def test_pod_template_file_kwargs_override(self, 
randomize_name, pod_template_fi
             "run_id": "test",
         }
 
+    @pytest.mark.parametrize(("randomize_name",), ([True], [False]))
+    def test_pod_template_dict(self, randomize_name):
+        templated_pod = k8s.V1Pod(
+            metadata=k8s.V1ObjectMeta(
+                namespace="templatenamespace",
+                name="hello",
+                labels={"release": "stable"},
+            ),
+            spec=k8s.V1PodSpec(
+                containers=[],
+                init_containers=[
+                    k8s.V1Container(
+                        name="git-clone",
+                        image="registry.k8s.io/git-sync:v3.1.1",
+                        args=[
+                            "[email protected]:airflow/some_repo.git",
+                            "--branch={{ params.get('repo_branch', 'master') 
}}",
+                        ],
+                    ),
+                ],
+            ),
+        )
+        k = KubernetesPodOperator(
+            task_id="task",
+            random_name_suffix=randomize_name,
+            
pod_template_dict=pod_generator.PodGenerator.serialize_pod(templated_pod),

Review Comment:
   My first intention was to make `full_pod_spec` field templated instead of 
adding a new field. But templater does not resolve `V1Pod` as you referred. I 
might have a simple solution, will try once I have some time 🤞 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to