Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions api/v1alpha1/taskspawner_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ type When struct {
// Jira discovers issues from a Jira project.
// +optional
Jira *Jira `json:"jira,omitempty"`

// GitHubWebhook configures webhook-driven task spawning from GitHub events.
// A global webhook server watches TaskSpawners with this field set and
// creates Tasks when incoming webhooks match the configured filters.
// +optional
GitHubWebhook *GitHubWebhook `json:"githubWebhook,omitempty"`

// LinearWebhook configures webhook-driven task spawning from Linear events.
// A global webhook server watches TaskSpawners with this field set and
// creates Tasks when incoming webhooks match the configured filters.
// +optional
LinearWebhook *LinearWebhook `json:"linearWebhook,omitempty"`
}

// Cron triggers task spawning on a cron schedule.
Expand Down Expand Up @@ -295,6 +307,93 @@ type Jira struct {
PollInterval string `json:"pollInterval,omitempty"`
}

// GitHubWebhook configures webhook-driven task spawning from GitHub events.
type GitHubWebhook struct {
// Events is the list of GitHub event types to listen for.
// e.g., "issue_comment", "pull_request_review", "push", "issues", "pull_request"
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
Events []string `json:"events"`

// Filters refine which events trigger tasks. If multiple filters are
// defined, any match triggers a task (OR semantics). If empty, all
// events in the Events list trigger tasks.
// +optional
Filters []GitHubWebhookFilter `json:"filters,omitempty"`
}

// GitHubWebhookFilter defines criteria for matching a GitHub webhook event.
type GitHubWebhookFilter struct {
// Event is the GitHub event type this filter applies to.
// +kubebuilder:validation:Required
Event string `json:"event"`

// Action filters by webhook action (e.g., "created", "opened", "submitted").
// +optional
Action string `json:"action,omitempty"`

// BodyContains filters by substring match on the comment or review body.
// +optional
BodyContains string `json:"bodyContains,omitempty"`

// Labels requires the issue or PR to have all of these labels.
// +optional
Labels []string `json:"labels,omitempty"`

// State filters by issue or PR state ("open", "closed").
// +optional
State string `json:"state,omitempty"`

// Branch filters push events by branch name (supports glob patterns).
// +optional
Branch string `json:"branch,omitempty"`

// Draft filters pull requests by draft status. nil means no filtering.
// +optional
Draft *bool `json:"draft,omitempty"`

// Author filters by the event sender's username.
// +optional
Author string `json:"author,omitempty"`
}

// LinearWebhook configures webhook-driven task spawning from Linear events.
type LinearWebhook struct {
// Types is the list of Linear resource types to listen for.
// e.g., "Issue", "Comment", "Project"
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
Types []string `json:"types"`

// Filters refine which events trigger tasks (OR semantics).
// If empty, all events matching the Types list trigger tasks.
// +optional
Filters []LinearWebhookFilter `json:"filters,omitempty"`
}

// LinearWebhookFilter defines criteria for matching a Linear webhook event.
type LinearWebhookFilter struct {
// Type is the Linear resource type this filter applies to.
// +kubebuilder:validation:Required
Type string `json:"type"`

// Action filters by webhook action ("create", "update", "remove").
// +optional
Action string `json:"action,omitempty"`

// States filters by Linear workflow state names (e.g., "Todo", "In Progress").
// +optional
States []string `json:"states,omitempty"`

// Labels requires the issue to have all of these labels.
// +optional
Labels []string `json:"labels,omitempty"`

// ExcludeLabels excludes issues with any of these labels.
// +optional
ExcludeLabels []string `json:"excludeLabels,omitempty"`
}

// TaskTemplateMetadata holds optional labels and annotations for spawned Tasks.
type TaskTemplateMetadata struct {
// Labels are merged into the spawned Task's labels. Values support Go
Expand Down
119 changes: 119 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.25.0

require (
github.com/go-logr/logr v1.4.3
github.com/google/go-github/v66 v66.0.0
github.com/google/uuid v1.6.0
github.com/google/yamlfmt v0.21.0
github.com/onsi/ginkgo/v2 v2.27.2
Expand Down Expand Up @@ -54,6 +55,7 @@ require (
github.com/google/btree v1.1.3 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
github.com/google/renameio/v2 v2.0.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,13 @@ github.com/google/cel-go v0.26.0 h1:DPGjXackMpJWH680oGY4lZhYjIameYmR+/6RBdDGmaI=
github.com/google/cel-go v0.26.0/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM=
github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo=
github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/go-github/v66 v66.0.0 h1:ADJsaXj9UotwdgK8/iFZtv7MLc8E8WBl62WLd/D/9+M=
github.com/google/go-github/v66 v66.0.0/go.mod h1:+4SO9Zkuyf8ytMj0csN1NR/5OTR+MfqPp8P8dVlcvY4=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down Expand Up @@ -274,6 +279,7 @@ golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnps
golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY=
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM=
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw=
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 h1:ToEetK57OidYuqD4Q5w+vfEnPvPpuTwedCNVohYJfNk=
Expand Down
Loading
Loading