An open API service indexing awesome lists of open source software.

https://github.com/tom24d/eventing-dockerhub

DockerHub as a knative event-source
https://github.com/tom24d/eventing-dockerhub

cloudevents dockerhub golang knative kubernetes

Last synced: 2 months ago
JSON representation

DockerHub as a knative event-source

Awesome Lists containing this project

README

          

# Knative Eventing DockerHub Source

Knative Eventing `DockerHubSource` defines an event source that transforms webhook events
from hub.docker.com into CloudEvents and deliver to the specified sink in the configuration yaml.

To learn more about Knative, please visit
[Knative docs](https://github.com/knative/docs) repository.

If you are interested in contributing, see [CONTRIBUTING.md](./CONTRIBUTING.md)
and [DEVELOPMENT.md](./DEVELOPMENT.md).

The initial idea comes from [JBoss community](https://docs.jboss.org/display/GSOC/Google+Summer+of+Code+2020+ideas#GoogleSummerofCode2020ideas-Knative-Eventsourcesforcontainerregistries,pipelinesandbuilds).
This is a part of [Google Summer of Code 2020 project](https://summerofcode.withgoogle.com/projects/?sp-search=tom24d#5186775800086528).
The demonstration video is [here](https://youtu.be/iU1Jnq0fq8A).

## Before you begin

`DockerHubSource` installation requires two knative component on your kubernetes cluster.
Plus, you need a build tool `ko`.

- Knative Serving core v0.16+
- Knative Eventing core v0.16+
- [ko](https://github.com/google/ko)

## Installation
Install DockerHubSource from the source:

```bash
ko apply -f config
```

## DockerHubSource usage example

Applying example(autoCallback enabled)

```bash
kubectl apply -f ./example/normal-display.yaml
kubectl apply -f ./example/source.yaml
```

The examples also have `callback-display.yaml` to try `disableAutoCallback=true` mode.
Under the circumstance that the appropriate sink is in the `source.yaml`, `callback-display.yaml` needs `ko` in order to apply.

You can see the resource is created via: `kubectl get dockerhubsource`.
```
% kubectl get dockerhubsources.sources.knative.dev
NAME READY REASON URL AGE
dockerhub-source True http:// 17s

```

Copy `http://` to configure dockerhub webhook. See [DockerHub Reference](https://docs.docker.com/docker-hub/webhooks/).

## API Reference

### v1alpha1

|Field|Description|
|:---|:---|
|`apiVersion`
string| `sources.knative.dev/v1alpha1`|
|`kind`
string| `DockerHubSource`|
|`metadata`
[Kubernetes
meta/v1.metadata](https://github.com/knative/docs/blob/master/docs/reference/eventing/eventing-contrib.md#duck.knative.dev/v1.CloudEventOverrides)| Refer to the Kubernetes API documentation for the fields of the `metadata` field.|
|`Spec`
DockerHubSourceSpec| disableAutoCallback
bool (Optional)
DisableAutoCallback configures whether the adapter works with automatic callback feature.
Docker Hub webhook needs validation callback to continually receive its chain. If the field is false, the adapter automatically sends a corresponding callback. Whichever the event gets delivered successfully or not, callback status is always `success`.
If unspecified, this will default to false. SourceSpec
SourceSpec (Members of SourceSpec are embedded into this type.) |
|`Status`
DockerHubSourceStatus| SourceStatus
SourceStatus (Members of SourceStatus are embedded into this type.) AutoCallbackDisabled
bool AutoCallbackDisabled is the status whether automatic callback is disabled. URL
knative.dev/pkg/apis.URL (Optional)
URL is the current active allocated URL that has been configured for the Source endpoint. ReceiveAdapterServiceName
string (Optional)
ReceiveAdapterServiceName holds knative service name to allocate same URL as before when accidentally deleted.
Further context is in [#37](https://github.com/tom24d/eventing-dockerhub/pull/37). |

---
### Example CloudEvent payload

```
Validation: valid
Context Attributes,
specversion: 1.0
type: tom24d.source.dockerhub.push
source: https://hub.docker.com/r/tom24d/postwebhook
subject: tom24d
id: fd4c1670-b126-4289-b025-61579ceeee3d
time: 2020-06-19T05:32:48Z
datacontenttype: application/json
Extensions,
tag: latest
Data,
{
"callback_url": "https://registry.hub.docker.com/u/tom24d/postwebhook/hook/2g51gffa2h1b4eh3ed355je0bc4g0e2h/",
"push_data": {
"images": [],
"pushed_at": 1592544800,
"pusher": "tom24d",
"tag": "latest"
},
"repository": {
"comment_count": 0,
"date_created": 1591154200,
"description": "[test] dockerhub website description.",
"dockerfile": "",
"full_description": "",
"is_official": false,
"is_private": false,
"is_trusted": false,
"name": "postwebhook",
"namespace": "tom24d",
"owner": "tom24d",
"repo_name": "tom24d/postwebhook",
"repo_url": "https://hub.docker.com/r/tom24d/postwebhook",
"star_count": 0,
"status": "Active"
}
}
```