hussein-awala commented on code in PR #29930:
URL: https://github.com/apache/airflow/pull/29930#discussion_r1206346858


##########
airflow/providers/cncf/kubernetes/operators/resource.py:
##########
@@ -0,0 +1,113 @@
+# 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
+
+__all__ = ["KubernetesCreateResourceOperator", 
"KubernetesDeleteResourceOperator"]
+
+
+class KubernetesResourceBaseOperator(BaseOperator):
+    """
+    Abstract base class for all Kubernetes Resource operators.
+
+    :param yaml_conf: string. Contains the kubernetes resources to Create or 
Delete
+    :param 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 then
+        this parameter has no effect.
+    :param kubernetes_conn_id: The :ref:`kubernetes connection id 
<howto/connection:kubernetes>`
+        for the Kubernetes cluster.
+    :param in_cluster: run kubernetes client with in_cluster configuration.
+    :param cluster_context: context that points to kubernetes cluster.
+        Ignored when in_cluster is True. If None, current-context is used.
+    :param config_file: The path to the Kubernetes config file. (templated)
+        If not specified, default value is ``~/.kube/config``
+    """
+
+    template_fields = ("yaml_conf",)
+    template_fields_renderers = {"yaml_conf": "yaml"}
+
+    def __init__(
+        self,
+        *,
+        yaml_conf: str,
+        namespace: str | None = None,
+        kubernetes_conn_id: str | None = KubernetesHook.default_conn_name,
+        in_cluster: bool | None = None,
+        cluster_context: str | None = None,
+        config_file: str | None = None,

Review Comment:
   Why do we need this arguments? We can specify them in the connection extras:
   - `in_cluster` extra for in_cluster conf
   - `cluster_context` extra for cluster_context
   - `kube_config_path` extra for config file path
   - even `kube_config` extra for the config file content
   
   IMO it's better to keep a single interface to specify these configuration 
which is the Kubernetes connection, wdyt?



-- 
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