https://github.com/addono/container-registry-proxy-custom-plugin-example
A simple example of a custom plugin implementation for the container-registry-proxy.
https://github.com/addono/container-registry-proxy-custom-plugin-example
container-registry-proxy node plugin typescript
Last synced: 4 months ago
JSON representation
A simple example of a custom plugin implementation for the container-registry-proxy.
- Host: GitHub
- URL: https://github.com/addono/container-registry-proxy-custom-plugin-example
- Owner: Addono
- License: mit
- Created: 2020-05-12T10:21:26.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-01T00:26:41.000Z (over 2 years ago)
- Last Synced: 2024-12-27T00:27:29.519Z (6 months ago)
- Topics: container-registry-proxy, node, plugin, typescript
- Language: TypeScript
- Homepage: https://github.com/Addono/container-registry-proxy
- Size: 262 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Container Registry Proxy - Custom Plugin Example
[](https://github.com/Addono/container-registry-proxy/blob/master/LICENSE)
[](https://www.repostatus.org/#active)

[](#contributors-)## 📝 Table of Contents
- [About](#about)
- [Getting Started](#getting_started)
- [Usage](#usage)
- [Contributors](#contributors)The Container Registry Proxy (CRP) is a small proxy for communicating with a container registry. This proxy can monitor and modify traffic in-transit, as to facilitate additional logging and chaos engineering.
Monitoring and modifying the traffic is delegated to a plugin system. This allows the proxy to be generally reusable and allow anyone to tune it to their needs without having to dive into the source code of the proxy.
This repository is here to give you an example and starting point for creating custom plugins for the CRP. Custom plugins are plugins which are loaded from the file system by the CRP at runtime.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See [usage](#usage) for notes on how to use the plugin in production.
### Prerequisites
You need to have [Yarn](https://yarnpkg.com/en/docs/install) installed to use this repository.
### Installing
First we need to install all dependencies, run:
```bash
yarn install
```### Running Locally
The following command will continuously compile the code of the plugin to plain JavaScript.
```bash
yarn build --watch
```### Editing
To modify the plugin, open `./plugin.ts` and modify the plugin by adding your logic to the `requestPipe` method of the by default exported object.
The `requestPipe` is function, which takes a `Request` object as it's only argument. Its return type is a promise of a (if desired modified) `Request` object, or otherwise `undefined` if the connection should be dropped.
```typescript
type Request = {
host: string
https: boolean
version: string
parameters?: {
repository: string
method: Method
tag: string
}
}interface Plugin {
name: string
description?: string
requestPipe: RequestPipe
}
```
Up to date type definitions can be inferred by your IDE or found [here](https://github.com/Addono/container-registry-proxy/blob/master/src/plugins.ts).First, build the plugin:
```bash
yarn build
```Then you can attach it to the `container-regsitry-proxy` by running:
```bash
container-registry-proxy --customPlugin dist/plugin.js
```Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!