argoproj / argo-events

Event-driven Automation Framework for Kubernetes
https://argoproj.github.io/argo-events/
Apache License 2.0
2.37k stars 738 forks source link

Github Gateway #95

Closed iterion closed 5 years ago

iterion commented 6 years ago

The hooks gateway already provides a decent way to pipe events from GitHub into argo-events. However, it would either require manual setup for each repo or an organization-wide rule to receive GitHub hooks. For some, the organization-wide rule might not be tenable, even though it's the easiest option. Additionally, the hooks gateway would just send along the hook payload, but we could do some deeper introspection on the hook to better fill out the metadata on the events that are generated.

Instead, it might be nice to have a custom gateway specifically focused on GitHub. It would do two primary things. Support an easy way to configure hooks for a repo through the GitHub API. And, provide a GitHub specific transformation from GitHub events to the CloudEvents specification.

This could be implemented via a separate controller that configures hooks and the appropriate argo-events webhook gateways. But, I think a tighter integration as a gateway would offer a better experience for users.

Proposed config:

type githubConfig struct {
    // GitHub owner name i.e. argoproj
    Owner string

    // GitHub repo name i.e. argo-events
    Repo string

    // Github events to subscribe to which the gateway will subscribe
    Events []string

    // Hostname for hooks
    Hostname string
}
VaibhavPage commented 6 years ago

Can we add a field for github api token for authentication,


type githubConfig struct {
    // GitHub owner name i.e. argoproj
    Owner string

    // GitHub repo name i.e. argo-events
    Repo string

    // Github events to subscribe to which the gateway will subscribe
    Events []string

    // Hostname for hooks
    Hostname string

       // K8 secret containing github api token
       APIToken  GithubToken
}

type GithubToken struct {
  // Name of k8 secret containing api token
   Name  string
   // Key for api token
   Key string
}
iterion commented 6 years ago

Yep, agree, we also need the APIToken.