From b67ea0eb662bec63d349e07b4f0ab752b28e7714 Mon Sep 17 00:00:00 2001 From: Geri Jennings Date: Mon, 30 Dec 2019 13:29:22 -0500 Subject: [PATCH] Update connector templates to default external The connector templates were originally written for internal connectors, but will be used as a guide by people building external connectors. This commit revises the languages in the README to default to an external-connector building audience, but maintains the guidelines for building internal connectors. --- examples/connector_templates/README.md | 53 +++++++++++++------ .../http/template/connector.go | 4 +- .../http/template/plugin.go | 4 +- .../tcp/template/connector.go | 4 +- .../tcp/template/plugin.go | 4 +- .../docker-compose.yml | 3 ++ 6 files changed, 52 insertions(+), 20 deletions(-) diff --git a/examples/connector_templates/README.md b/examples/connector_templates/README.md index ad1e99c71..ed013ef5a 100644 --- a/examples/connector_templates/README.md +++ b/examples/connector_templates/README.md @@ -1,16 +1,37 @@ -# Using templates to implement Secretless Connector Plugins - -We created connector templates to ease the process of adding new connectors to secretless. -Before using the templates to add new connector plugins, be sure to read the [Secretless Connector Plugins README](https://github.com/cyberark/secretless-broker/blob/master/pkg/secretless/plugin/connector/README.md) - -To add a new connector do the following: - -1. Copy the relevant template directory (HTTP/TCP) into `internal/plugin/connectors/`. -If you're not sure which connector type is suitable, please refer to the [connector technical overview](https://github.com/cyberark/secretless-broker/tree/master/pkg/secretless/plugin/connector#technical-overview). - 1. Inside each template directory you will find the required files & structs implemented, - with instructions in the form of TODOs to fill them with the content of the new connector. -1. Add an entry to the `Plugins` map defined in GetInternalPluginsFunc() of - [`internal_plugins.go`](../../pkg/secretless/plugin/sharedobj/internal_plugins.go), according to their type (HTTP/TCP) -1. Copy the [`template_connector_test`](template_connector_test) directory into `test/connector//` and rename it to ``. - 1. This directory will help you write integration tests for your connector. It contains test scripts & files to help you stand up networked containers with docker-compose. The files give instructions on the steps to set up your test suite in the form of TODOs. - The [`Jenkinsfile`](../../Jenkinsfile) is set up to automatically run the integration tests with each project build. +# Using templates to create Secretless Connector Plugins + +We created the templates in this directory to make it easier to add new +connectors to Secretless. + +Before using the templates, be sure to read the [Secretless Connector Plugins +README](https://github.com/cyberark/secretless-broker/blob/master/pkg/secretless/plugin/connector/README.md) + +To create a new Secretless connector plugin, follow these instructions: + +1. Copy the relevant template directory (HTTP/TCP) into a folder on your local + machine (or to `internal/plugin/connectors/` if you are building + an internal connector). + + If you're not sure which connector type is appropriate for your target service, + please refer to the [connector technical overview](https://github.com/cyberark/secretless-broker/tree/master/pkg/secretless/plugin/connector#technical-overview) for guidelines. + +1. Update the copied files to implement your connector. Each file includes + instructions in the form of `TODO`s. + +1. (**Internal Connectors Only**) Add an entry to the `Plugins` map defined in + `GetInternalPluginsFunc()` of + [`internal_plugins.go`](../../pkg/secretless/plugin/sharedobj/internal_plugins.go), + according to your connector type (HTTP/TCP) + +1. To test your connector, copy the [`template_connector_test`](template_connector_test) + directory onto your local machine. + + If you follow the `TODO`-based instructions included in the files in this directory, + you will be able to write integration tests for your connector using `docker-compose`. + The included test scripts & files will help you stand up networked containers with + `docker-compose`. + + **Note for internal connectors:** The the test directory should be copied + into `test/connector//` and renamed to ``. + The [`Jenkinsfile`](../../Jenkinsfile) is set up to automatically run the + integration tests from this directory with each project build. diff --git a/examples/connector_templates/http/template/connector.go b/examples/connector_templates/http/template/connector.go index 1d6e18b14..61f7975c5 100644 --- a/examples/connector_templates/http/template/connector.go +++ b/examples/connector_templates/http/template/connector.go @@ -1,4 +1,6 @@ -package template +package main + +// TODO: change the package name to your plugin name if this will be an internal connector import ( gohttp "net/http" diff --git a/examples/connector_templates/http/template/plugin.go b/examples/connector_templates/http/template/plugin.go index 1d11735a5..6712976a0 100644 --- a/examples/connector_templates/http/template/plugin.go +++ b/examples/connector_templates/http/template/plugin.go @@ -1,4 +1,6 @@ -package template +package main + +// TODO: change the package name to your plugin name if this will be an internal connector import ( "github.com/cyberark/secretless-broker/pkg/secretless/plugin/connector" diff --git a/examples/connector_templates/tcp/template/connector.go b/examples/connector_templates/tcp/template/connector.go index febabf6e3..85ab104c8 100644 --- a/examples/connector_templates/tcp/template/connector.go +++ b/examples/connector_templates/tcp/template/connector.go @@ -1,4 +1,6 @@ -package template +package main + +// TODO: change the package name to your plugin name if this will be an internal connector import ( "net" diff --git a/examples/connector_templates/tcp/template/plugin.go b/examples/connector_templates/tcp/template/plugin.go index 3f0b4b595..b14c46266 100644 --- a/examples/connector_templates/tcp/template/plugin.go +++ b/examples/connector_templates/tcp/template/plugin.go @@ -1,4 +1,6 @@ -package template +package main + +// TODO: change the package name to your plugin name if this will be an internal connector import ( "net" diff --git a/examples/connector_templates/template_connector_test/docker-compose.yml b/examples/connector_templates/template_connector_test/docker-compose.yml index 07e819d8b..9b0e0cb4b 100644 --- a/examples/connector_templates/template_connector_test/docker-compose.yml +++ b/examples/connector_templates/template_connector_test/docker-compose.yml @@ -3,6 +3,9 @@ version: '3.0' services: # TODO: add a service for the platform you want secretless to connect with + # TODO: make sure Secretless runs with your plugin + # which may mean adding the `.so` file as a volume + # and revising the command to pass in the `.so` using the `-p` flag secretless: image: secretless-broker # this image is built by bin/build volumes: