eventing-dockerhub

module
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2021 License: Apache-2.0

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 repository.

If you are interested in contributing, see CONTRIBUTING.md and DEVELOPMENT.md.

The initial idea comes from JBoss community.
This is a part of Google Summer of Code 2020 project.
The demonstration video is here.

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

Installation

Install DockerHubSource from the source:

ko apply -f config

DockerHubSource usage example

Applying example(autoCallback enabled)

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://<your-endpoint-for-DockerHubSource>   17s

Copy http://<your-endpoint-for-DockerHubSource> to configure dockerhub webhook. See DockerHub Reference.

API Reference

v1alpha1
Field Description
apiVersion
string
sources.knative.dev/v1alpha1
kind
string
DockerHubSource
metadata
Kubernetes
meta/v1.metadata
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.

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"
    }
  }

Directories

Path Synopsis
cmd
example
pkg
apis/sources/v1alpha1
Package v1alpha1 contains API Schema definitions for the sources v1alpha1 API group +k8s:conversion-gen=github.com/tom24d/eventing-dockerhub/pkg/apis/sources +k8s:openapi-gen=true +k8s:deepcopy-gen=package,register +k8s:defaulter-gen=TypeMeta +groupName=sources.knative.dev
Package v1alpha1 contains API Schema definitions for the sources v1alpha1 API group +k8s:conversion-gen=github.com/tom24d/eventing-dockerhub/pkg/apis/sources +k8s:openapi-gen=true +k8s:deepcopy-gen=package,register +k8s:defaulter-gen=TypeMeta +groupName=sources.knative.dev
client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/versioned/typed/sources/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/sources/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL