Skip to content

Commit

Permalink
add function package-url into function-get api response (apache#2354)
Browse files Browse the repository at this point in the history
### Motivation

Right now, we mostly use function by submitting function with url and many times, we want to verify function package-url to confirm the package-version. So, function-admin api should return packageurl along with function metadata.

### Modifications

return function pacakge-url along with function-metadata on get-function api call.
  • Loading branch information
rdhabalia authored and sijie committed Aug 13, 2018
1 parent 0d2154e commit cb2f4ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions pulsar-functions/proto/src/main/proto/Function.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,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;
}

Expand Down Expand Up @@ -789,7 +788,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");
}
Expand All @@ -806,7 +805,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<>();
Expand Down

0 comments on commit cb2f4ee

Please sign in to comment.