zymap commented on a change in pull request #8988:
URL: https://github.com/apache/pulsar/pull/8988#discussion_r549259967



##########
File path: 
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SourcesImpl.java
##########
@@ -719,4 +728,14 @@ public SourceConfig getSourceInfo(final String tenant,
                 worker().getWorkerConfig().getValidateConnectorConfig());
         return SourceConfigUtils.convert(sourceConfig, sourceDetails);
     }
+
+    private static boolean hasPackageTypePrefix(String destPkgUrl) {
+        return Arrays.stream(PackageType.values()).anyMatch(type -> 
destPkgUrl.startsWith(type.toString()));
+    }
+
+    private File downloadPackageFile(String packageName) throws IOException, 
PulsarAdminException {

Review comment:
       Ideally, we validate the existence is enough. But that depends on we do 
the packages format check or function check when uploading a package to the 
package management service. Then we can remove the checks for the functions 
which are using the package name to register. But for now, we still need to 
rely on those checks in the function's code.
   
   I looked into the creation of the function. I saw if a function provided 
with a packageUrl, it will [download the package and save it as a temp file 
](https://github.com/apache/pulsar/blob/1c7ca159d402dcf1a9865410f4872a5741630609/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SourcesImpl.java#L156)
 and do some checks with it. And also it always passes a `File` as the 
parameter for the method call.
   
https://github.com/apache/pulsar/blob/1c7ca159d402dcf1a9865410f4872a5741630609/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SourcesImpl.java#L160
   
https://github.com/apache/pulsar/blob/1c7ca159d402dcf1a9865410f4872a5741630609/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/SourceConfigUtils.java#L244
   
   If we don't download the packages files, we may need to change the existing 
register function logic.
   




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

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


Reply via email to