Skip to content

Commit

Permalink
chore: split plugin interface (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
nanjingfm authored Feb 4, 2024
1 parent 1c4b863 commit 6a3fc54
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
18 changes: 18 additions & 0 deletions plugin/types/pull_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,30 @@ type GitPullRequestCommentLister interface {

// GitPullRequestHandler list, get and create pr function
type GitPullRequestHandler interface {
Interface
GitPullRequestLister
GitPullRequestGetter
GitPullRequestCreator
}

// GitPullRequestLister list pull requests
type GitPullRequestLister interface {
Interface
ListGitPullRequest(
ctx context.Context,
option metav1alpha1.GitPullRequestListOption,
listOption metav1alpha1.ListOptions,
) (metav1alpha1.GitPullRequestList, error)
}

// GitPullRequestGetter get a pull request
type GitPullRequestGetter interface {
Interface
GetGitPullRequest(ctx context.Context, option metav1alpha1.GitPullRequestOption) (metav1alpha1.GitPullRequest, error)
}

// GitPullRequestCreator create a new pull request
type GitPullRequestCreator interface {
Interface
CreatePullRequest(ctx context.Context, payload metav1alpha1.CreatePullRequestPayload) (metav1alpha1.GitPullRequest, error)
}
21 changes: 20 additions & 1 deletion plugin/types/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,29 @@ import (

// WebhookRegister used to register and manage webhooks
type WebhookRegister interface {
// Use the methods below to manage webhooks in the target platform
WebhookCreator
WebhookUpdater
WebhookDeleter
WebhookLister
}

// WebhookCreator create a new webhook
type WebhookCreator interface {
CreateWebhook(ctx context.Context, spec metav1alpha1.WebhookRegisterSpec, secret corev1.Secret) (metav1alpha1.WebhookRegisterStatus, error)
}

// WebhookUpdater update a webhook
type WebhookUpdater interface {
UpdateWebhook(ctx context.Context, spec metav1alpha1.WebhookRegisterSpec, secret corev1.Secret) (metav1alpha1.WebhookRegisterStatus, error)
}

// WebhookDeleter delete a webhook
type WebhookDeleter interface {
DeleteWebhook(ctx context.Context, spec metav1alpha1.WebhookRegisterSpec, secret corev1.Secret) error
}

// WebhookLister list webhooks
type WebhookLister interface {
ListWebhooks(ctx context.Context, uri apis.URL, secret corev1.Secret) ([]metav1alpha1.WebhookRegisterStatus, error)
}

Expand Down

0 comments on commit 6a3fc54

Please sign in to comment.