hussein-awala commented on code in PR #29930: URL: https://github.com/apache/airflow/pull/29930#discussion_r1205654949
########## airflow/providers/cncf/kubernetes/operators/resource.py: ########## @@ -0,0 +1,96 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Manage a Kubernetes Resource""" + +from __future__ import annotations + +import yaml +from kubernetes.client import ApiClient +from kubernetes.utils import create_from_yaml + +from airflow.compat.functools import cached_property +from airflow.models import BaseOperator +from airflow.providers.cncf.kubernetes.hooks.kubernetes import KubernetesHook +from airflow.providers.cncf.kubernetes.utils.delete_from import delete_from_yaml + Review Comment: ```suggestion __all__ = ["KubernetesCreateResourceOperator", "KubernetesDeleteResourceOperator"] ``` ########## airflow/providers/cncf/kubernetes/operators/resource.py: ########## @@ -0,0 +1,96 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Manage a Kubernetes Resource""" + +from __future__ import annotations + +import yaml +from kubernetes.client import ApiClient +from kubernetes.utils import create_from_yaml + +from airflow.compat.functools import cached_property +from airflow.models import BaseOperator +from airflow.providers.cncf.kubernetes.hooks.kubernetes import KubernetesHook +from airflow.providers.cncf.kubernetes.utils.delete_from import delete_from_yaml + + +class KubernetesResourceBaseOperator(BaseOperator): + """Abstract base class for all Kubernetes Resource operators.""" + + template_fields = ("yaml_conf",) + template_fields_renderers = {"yaml_conf": "yaml"} + + def __init__( + self, + *, + yaml_conf: str, + namespace: str | None = None, Review Comment: Can you add a docstring for these parameters especially for `namespace`? ``` namespace: string. Contains the namespace to create all resources inside. The namespace must preexist otherwise the resource creation will fail. If the API object in the yaml file already contains a namespace definition this parameter has no effect. ``` -- 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]
