sijie closed pull request #2354: add function package-url into function-get api
response
URL: https://github.com/apache/incubator-pulsar/pull/2354
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/pulsar-functions/proto/src/main/proto/Function.proto
b/pulsar-functions/proto/src/main/proto/Function.proto
index 92f14f6f19..77a9c2c0b6 100644
--- a/pulsar-functions/proto/src/main/proto/Function.proto
+++ b/pulsar-functions/proto/src/main/proto/Function.proto
@@ -58,6 +58,7 @@ message FunctionDetails {
SourceSpec source = 11;
SinkSpec sink = 12;
Resources resources = 13;
+ string packageUrl = 14; //present only if function submitted with
package-url
}
message SourceSpec {
diff --git
a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java
b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java
index c35dd52e80..a697363719 100644
---
a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java
+++
b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java
@@ -732,9 +732,8 @@ private FunctionDetails
validateUpdateRequestParamsWithPkgUrl(String tenant, Str
throw new IllegalArgumentException("Function Package url is not
valid. supported url (http/https/file)");
}
Utils.validateFileUrl(functionPkgUrl,
workerServiceSupplier.get().getWorkerConfig().getDownloadDirectory());
- File jarWithFileUrl = functionPkgUrl.startsWith(FILE) ? (new File((new
URL(functionPkgUrl)).toURI())) : null;
FunctionDetails functionDetails = validateUpdateRequestParams(tenant,
namespace, functionName,
- functionDetailsJson, jarWithFileUrl);
+ functionDetailsJson, functionPkgUrl);
return functionDetails;
}
@@ -788,7 +787,7 @@ private String getFunctionCodeBuiltin(FunctionDetails
functionDetails) {
}
private FunctionDetails validateUpdateRequestParams(String tenant, String
namespace, String functionName,
- String functionDetailsJson, File jarWithFileUrl) throws
IllegalArgumentException {
+ String functionDetailsJson, String functionPkgUrl) throws
IllegalArgumentException {
if (tenant == null) {
throw new IllegalArgumentException("Tenant is not provided");
}
@@ -805,7 +804,14 @@ private FunctionDetails validateUpdateRequestParams(String
tenant, String namesp
try {
FunctionDetails.Builder functionDetailsBuilder =
FunctionDetails.newBuilder();
org.apache.pulsar.functions.utils.Utils.mergeJson(functionDetailsJson,
functionDetailsBuilder);
- validateFunctionClassTypes(jarWithFileUrl, functionDetailsBuilder);
+ if (isNotBlank(functionPkgUrl)) {
+ // validate function details by loading function-jar from
local file-system
+ File jarWithFileUrl = functionPkgUrl.startsWith(FILE) ? (new
File((new URL(functionPkgUrl)).toURI()))
+ : null;
+ validateFunctionClassTypes(jarWithFileUrl,
functionDetailsBuilder);
+ // set package-url if present
+ functionDetailsBuilder.setPackageUrl(functionPkgUrl);
+ }
FunctionDetails functionDetails = functionDetailsBuilder.build();
List<String> missingFields = new LinkedList<>();
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services