|
| 1 | +package internal |
| 2 | + |
| 3 | +import sdk "github.com/GoCodeAlone/workflow/plugin/external/sdk" |
| 4 | + |
| 5 | +// Ensure githubPlugin satisfies sdk.SchemaProvider at compile time. |
| 6 | +var _ sdk.SchemaProvider = (*githubPlugin)(nil) |
| 7 | + |
| 8 | +// ModuleSchemas returns schema descriptors for all module types provided by |
| 9 | +// this plugin. Implementing sdk.SchemaProvider allows the engine to surface |
| 10 | +// module configuration fields and I/O contracts at startup and in the UI. |
| 11 | +func (p *githubPlugin) ModuleSchemas() []sdk.ModuleSchemaData { |
| 12 | + return []sdk.ModuleSchemaData{ |
| 13 | + { |
| 14 | + Type: "git.webhook", |
| 15 | + Label: "GitHub Webhook", |
| 16 | + Category: "github", |
| 17 | + Description: "Receives GitHub webhook events via HTTP, verifies HMAC-SHA256 signatures, and publishes normalised GitEvent messages to a configurable topic.", |
| 18 | + ConfigFields: []sdk.ConfigField{ |
| 19 | + { |
| 20 | + Name: "provider", |
| 21 | + Type: "string", |
| 22 | + Description: "Webhook provider identifier. Accepted for backward compatibility; the module always publishes events with provider 'github'.", |
| 23 | + DefaultValue: "github", |
| 24 | + Required: false, |
| 25 | + }, |
| 26 | + { |
| 27 | + Name: "secret", |
| 28 | + Type: "string", |
| 29 | + Description: "Webhook secret used to verify the X-Hub-Signature-256 header. Leave empty to skip signature verification.", |
| 30 | + Required: false, |
| 31 | + }, |
| 32 | + { |
| 33 | + Name: "events", |
| 34 | + Type: "array", |
| 35 | + Description: "Event types to accept (e.g. push, pull_request). An empty list accepts all event types.", |
| 36 | + Required: false, |
| 37 | + }, |
| 38 | + { |
| 39 | + Name: "topic", |
| 40 | + Type: "string", |
| 41 | + Description: "Message-bus topic to which normalised GitEvent payloads are published.", |
| 42 | + DefaultValue: "git.events", |
| 43 | + Required: false, |
| 44 | + }, |
| 45 | + }, |
| 46 | + Outputs: []sdk.ServiceIO{ |
| 47 | + {Name: "provider", Type: "string", Description: "Webhook provider (always 'github')"}, |
| 48 | + {Name: "event_type", Type: "string", Description: "GitHub event type (e.g. push, pull_request)"}, |
| 49 | + {Name: "repository", Type: "string", Description: "Repository full name (owner/repo)"}, |
| 50 | + {Name: "branch", Type: "string", Description: "Branch or ref name"}, |
| 51 | + {Name: "commit", Type: "string", Description: "Commit SHA"}, |
| 52 | + {Name: "author", Type: "string", Description: "Event author username"}, |
| 53 | + {Name: "message", Type: "string", Description: "Commit message or PR title"}, |
| 54 | + {Name: "url", Type: "string", Description: "URL to the commit or PR"}, |
| 55 | + {Name: "raw_payload", Type: "object", Description: "Raw JSON webhook payload"}, |
| 56 | + {Name: "timestamp", Type: "string", Description: "Event timestamp in RFC3339 format"}, |
| 57 | + }, |
| 58 | + }, |
| 59 | + { |
| 60 | + Type: "github.app", |
| 61 | + Label: "GitHub App", |
| 62 | + Category: "github", |
| 63 | + Description: "Authenticates as a GitHub App installation, generating short-lived installation access tokens from an App private key. Tokens are cached and refreshed automatically.", |
| 64 | + ConfigFields: []sdk.ConfigField{ |
| 65 | + { |
| 66 | + Name: "app_id", |
| 67 | + Type: "number", |
| 68 | + Description: "GitHub App ID", |
| 69 | + Required: true, |
| 70 | + }, |
| 71 | + { |
| 72 | + Name: "installation_id", |
| 73 | + Type: "number", |
| 74 | + Description: "GitHub App installation ID", |
| 75 | + Required: true, |
| 76 | + }, |
| 77 | + { |
| 78 | + Name: "private_key", |
| 79 | + Type: "string", |
| 80 | + Description: "PEM-encoded RSA private key for the GitHub App (supports env var references e.g. ${GITHUB_APP_PRIVATE_KEY})", |
| 81 | + Required: true, |
| 82 | + }, |
| 83 | + }, |
| 84 | + }, |
| 85 | + } |
| 86 | +} |
0 commit comments