You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/10/10 07:24:10 UTC

[GitHub] [dolphinscheduler] xdu-chenrj commented on a diff in pull request #12025: [DSIP-13][python]Sub problem: gitlab, OSS and S3 resource plug-ins

xdu-chenrj commented on code in PR #12025:
URL: https://github.com/apache/dolphinscheduler/pull/12025#discussion_r990974906


##########
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/resources_plugin/oss.py:
##########
@@ -0,0 +1,77 @@
+# 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.
+
+"""DolphinScheduler oss resource plugin."""
+from typing import Optional
+from urllib.parse import urljoin
+
+import oss2
+
+from pydolphinscheduler.core.resource_plugin import ResourcePlugin
+from pydolphinscheduler.resources_plugin.base.bucket import Bucket, OSSFileInfo
+
+
+class OSS(ResourcePlugin, Bucket):
+    """OSS object, declare OSS resource plugin for task and workflow to dolphinscheduler.
+
+    :param prefix: A string representing the prefix of OSS.
+    :param access_key_id: A string representing the ID of AccessKey for AliCloud OSS
+
+    to access private files.
+
+    :param access_key_secret: A string representing the secret of AccessKey for AliCloud OSS
+
+    to access private files.
+    """
+
+    def __init__(
+        self,
+        prefix: str,
+        access_key_id: Optional[str] = None,
+        access_key_secret: Optional[str] = None,
+        *args,
+        **kwargs
+    ):
+        super().__init__(prefix, *args, **kwargs)
+        self.access_key_id = access_key_id
+        self.access_key_secret = access_key_secret
+
+    _bucket_file_info: Optional[OSSFileInfo] = None
+
+    def get_bucket_file_info(self, path: str):
+        """Get file information from the file url, like repository name, user, branch, and file path."""
+        elements = path.split("/")
+        self.get_index(path, "/", 3)
+        self._bucket_file_info = OSSFileInfo(
+            endpoint="https://" + elements[2].split(".")[1] + ".aliyuncs.com",
+            bucket=elements[2].split(".")[0],
+            file_path="/".join(str(elements[i]) for i in range(3, len(elements))),
+        )

Review Comment:
   > ```diff
   > f"https://{elements[2].split('.')[1]}.aliyuncs.com"
   > ```
   
   thanks



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org