-
Notifications
You must be signed in to change notification settings - Fork 16.4k
KPO: Add Typing on Security Context #31275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit is to add appropriate k8s typing on KubernetesPodOperator's security_context and container_security_context field.
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
|
hussein-awala
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although providing a dictionary for these variables is acceptable in most cases, it is not recommended. +1 for changing the types to align with the Kubernetes client types.
Please remember to update the tests and replace the dictionary values with the appropriate objects. For ex:
airflow/tests/providers/cncf/kubernetes/operators/test_pod.py
Lines 214 to 232 in 3193857
| def test_security_context(self): | |
| security_context = { | |
| "runAsUser": 1245, | |
| } | |
| k = KubernetesPodOperator( | |
| security_context=security_context, | |
| task_id="task", | |
| ) | |
| pod = k.build_pod_request_obj(create_context(k)) | |
| assert pod.spec.security_context == security_context | |
| def test_container_security_context(self): | |
| container_security_context = {"allowPrivilegeEscalation": False} | |
| k = KubernetesPodOperator( | |
| container_security_context=container_security_context, | |
| task_id="task", | |
| ) | |
| pod = k.build_pod_request_obj(create_context(k)) | |
| assert pod.spec.containers[0].security_context == container_security_context |
hussein-awala
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although providing a dictionary for these variables is acceptable in most cases, it is not recommended. +1 for changing the types to align with the Kubernetes client types.
Please remember to update the tests and replace the dictionary values with the appropriate objects. For ex:
airflow/tests/providers/cncf/kubernetes/operators/test_pod.py
Lines 214 to 232 in 3193857
| def test_security_context(self): | |
| security_context = { | |
| "runAsUser": 1245, | |
| } | |
| k = KubernetesPodOperator( | |
| security_context=security_context, | |
| task_id="task", | |
| ) | |
| pod = k.build_pod_request_obj(create_context(k)) | |
| assert pod.spec.security_context == security_context | |
| def test_container_security_context(self): | |
| container_security_context = {"allowPrivilegeEscalation": False} | |
| k = KubernetesPodOperator( | |
| container_security_context=container_security_context, | |
| task_id="task", | |
| ) | |
| pod = k.build_pod_request_obj(create_context(k)) | |
| assert pod.spec.containers[0].security_context == container_security_context |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
|
This PR seems to have gone stale. I will lead it to completion. Good find @kbumsik! |
This commit is to add appropriate k8s typing on KubernetesPodOperator's security_context and container_security_context field.