-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api,worker,contrib): add example of plugin in nodejs
Signed-off-by: Benjamin Coenen <benjamin.coenen@corp.ovh.com>
- Loading branch information
Showing
17 changed files
with
1,802 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
.PHONY: clean | ||
|
||
VERSION := $(if ${CDS_SEMVER},${CDS_SEMVER},snapshot) | ||
|
||
TARGET_DIR = dist | ||
TARGET_NAME = nodejs | ||
|
||
define PLUGIN_MANIFEST_BINARY | ||
os: %os% | ||
arch: %arch% | ||
cmd: node | ||
entrypoints: | ||
- index.js | ||
requirements: | ||
- name: node | ||
type: binary | ||
value: node | ||
endef | ||
export PLUGIN_MANIFEST_BINARY | ||
|
||
TARGET_OS = $(if ${OS},${OS},windows darwin linux freebsd) | ||
TARGET_ARCH = $(if ${ARCH},${ARCH},amd64 arm 386) | ||
TARGET_TAR = plugin-$(TARGET_NAME).tar.gz | ||
|
||
build: | ||
@mkdir -p $(TARGET_DIR) | ||
@cp $(TARGET_NAME).yml $(TARGET_DIR)/plugin.yml | ||
@npm install | ||
@tar -czvf $(TARGET_DIR)/$(TARGET_TAR) node_modules *.js *.json | ||
@for OS in $(TARGET_OS); do \ | ||
for ARCH in $(TARGET_ARCH); do \ | ||
echo "$$PLUGIN_MANIFEST_BINARY" > $(TARGET_DIR)/plugin-$$OS-$$ARCH.yml; \ | ||
perl -pi -e s,%os%,$$OS,g $(TARGET_DIR)/plugin-$$OS-$$ARCH.yml; \ | ||
perl -pi -e s,%arch%,$$ARCH,g $(TARGET_DIR)/plugin-$$OS-$$ARCH.yml; \ | ||
done; \ | ||
done; | ||
|
||
publish: | ||
@echo "Updating plugin $(TARGET_NAME)..." | ||
cdsctl admin plugins import $(TARGET_DIR)/plugin.yml | ||
@for OS in $(TARGET_OS); do \ | ||
for ARCH in $(TARGET_ARCH); do \ | ||
echo "Updating plugin binary $(TARGET_NAME)-$$OS-$$ARCH"; \ | ||
cdsctl admin plugins binary-add plugin-$(TARGET_NAME) $(TARGET_DIR)/plugin-$$OS-$$ARCH.yml $(TARGET_DIR)/$(TARGET_TAR); \ | ||
done; \ | ||
done |
100 changes: 100 additions & 0 deletions
100
contrib/grpcplugins/action/examples/nodejs/actionplugin_grpc_pb.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// GENERATED CODE -- DO NOT EDIT! | ||
|
||
'use strict'; | ||
var grpc = require('grpc'); | ||
var actionplugin_pb = require('./actionplugin_pb.js'); | ||
var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js'); | ||
|
||
function serialize_actionplugin_ActionPluginManifest(arg) { | ||
if (!(arg instanceof actionplugin_pb.ActionPluginManifest)) { | ||
throw new Error('Expected argument of type actionplugin.ActionPluginManifest'); | ||
} | ||
return new Buffer(arg.serializeBinary()); | ||
} | ||
|
||
function deserialize_actionplugin_ActionPluginManifest(buffer_arg) { | ||
return actionplugin_pb.ActionPluginManifest.deserializeBinary(new Uint8Array(buffer_arg)); | ||
} | ||
|
||
function serialize_actionplugin_ActionQuery(arg) { | ||
if (!(arg instanceof actionplugin_pb.ActionQuery)) { | ||
throw new Error('Expected argument of type actionplugin.ActionQuery'); | ||
} | ||
return new Buffer(arg.serializeBinary()); | ||
} | ||
|
||
function deserialize_actionplugin_ActionQuery(buffer_arg) { | ||
return actionplugin_pb.ActionQuery.deserializeBinary(new Uint8Array(buffer_arg)); | ||
} | ||
|
||
function serialize_actionplugin_ActionResult(arg) { | ||
if (!(arg instanceof actionplugin_pb.ActionResult)) { | ||
throw new Error('Expected argument of type actionplugin.ActionResult'); | ||
} | ||
return new Buffer(arg.serializeBinary()); | ||
} | ||
|
||
function deserialize_actionplugin_ActionResult(buffer_arg) { | ||
return actionplugin_pb.ActionResult.deserializeBinary(new Uint8Array(buffer_arg)); | ||
} | ||
|
||
function serialize_actionplugin_WorkerHTTPPortQuery(arg) { | ||
if (!(arg instanceof actionplugin_pb.WorkerHTTPPortQuery)) { | ||
throw new Error('Expected argument of type actionplugin.WorkerHTTPPortQuery'); | ||
} | ||
return new Buffer(arg.serializeBinary()); | ||
} | ||
|
||
function deserialize_actionplugin_WorkerHTTPPortQuery(buffer_arg) { | ||
return actionplugin_pb.WorkerHTTPPortQuery.deserializeBinary(new Uint8Array(buffer_arg)); | ||
} | ||
|
||
function serialize_google_protobuf_Empty(arg) { | ||
if (!(arg instanceof google_protobuf_empty_pb.Empty)) { | ||
throw new Error('Expected argument of type google.protobuf.Empty'); | ||
} | ||
return new Buffer(arg.serializeBinary()); | ||
} | ||
|
||
function deserialize_google_protobuf_Empty(buffer_arg) { | ||
return google_protobuf_empty_pb.Empty.deserializeBinary(new Uint8Array(buffer_arg)); | ||
} | ||
|
||
|
||
var ActionPluginService = exports.ActionPluginService = { | ||
manifest: { | ||
path: '/actionplugin.ActionPlugin/Manifest', | ||
requestStream: false, | ||
responseStream: false, | ||
requestType: google_protobuf_empty_pb.Empty, | ||
responseType: actionplugin_pb.ActionPluginManifest, | ||
requestSerialize: serialize_google_protobuf_Empty, | ||
requestDeserialize: deserialize_google_protobuf_Empty, | ||
responseSerialize: serialize_actionplugin_ActionPluginManifest, | ||
responseDeserialize: deserialize_actionplugin_ActionPluginManifest, | ||
}, | ||
run: { | ||
path: '/actionplugin.ActionPlugin/Run', | ||
requestStream: false, | ||
responseStream: false, | ||
requestType: actionplugin_pb.ActionQuery, | ||
responseType: actionplugin_pb.ActionResult, | ||
requestSerialize: serialize_actionplugin_ActionQuery, | ||
requestDeserialize: deserialize_actionplugin_ActionQuery, | ||
responseSerialize: serialize_actionplugin_ActionResult, | ||
responseDeserialize: deserialize_actionplugin_ActionResult, | ||
}, | ||
workerHTTPPort: { | ||
path: '/actionplugin.ActionPlugin/WorkerHTTPPort', | ||
requestStream: false, | ||
responseStream: false, | ||
requestType: actionplugin_pb.WorkerHTTPPortQuery, | ||
responseType: google_protobuf_empty_pb.Empty, | ||
requestSerialize: serialize_actionplugin_WorkerHTTPPortQuery, | ||
requestDeserialize: deserialize_actionplugin_WorkerHTTPPortQuery, | ||
responseSerialize: serialize_google_protobuf_Empty, | ||
responseDeserialize: deserialize_google_protobuf_Empty, | ||
}, | ||
}; | ||
|
||
exports.ActionPluginClient = grpc.makeGenericClientConstructor(ActionPluginService); |
Oops, something went wrong.