@@ -3,20 +3,22 @@ package webhook_creator
3
3
import (
4
4
context2 "context"
5
5
"errors"
6
+ "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
6
7
"github.com/quickube/piper/pkg/git_provider"
7
8
"golang.org/x/net/context"
8
9
"net/http"
9
10
)
10
11
11
12
type MockGitProviderClient struct {
12
- ListFilesFunc func (ctx context.Context , repo string , branch string , path string ) ([]string , error )
13
- GetFileFunc func (ctx context.Context , repo string , branch string , path string ) (* git_provider.CommitFile , error )
14
- GetFilesFunc func (ctx context.Context , repo string , branch string , paths []string ) ([]* git_provider.CommitFile , error )
15
- SetWebhookFunc func (ctx context.Context , repo * string ) (* git_provider.HookWithStatus , error )
16
- UnsetWebhookFunc func (ctx context.Context , hook * git_provider.HookWithStatus ) error
17
- HandlePayloadFunc func (request * http.Request , secret []byte ) (* git_provider.WebhookPayload , error )
18
- SetStatusFunc func (ctx context.Context , repo * string , commit * string , linkURL * string , status * string , message * string ) error
19
- PingHookFunc func (ctx context.Context , hook * git_provider.HookWithStatus ) error
13
+ ListFilesFunc func (ctx context.Context , repo string , branch string , path string ) ([]string , error )
14
+ GetFileFunc func (ctx context.Context , repo string , branch string , path string ) (* git_provider.CommitFile , error )
15
+ GetFilesFunc func (ctx context.Context , repo string , branch string , paths []string ) ([]* git_provider.CommitFile , error )
16
+ SetWebhookFunc func (ctx context.Context , repo * string ) (* git_provider.HookWithStatus , error )
17
+ UnsetWebhookFunc func (ctx context.Context , hook * git_provider.HookWithStatus ) error
18
+ HandlePayloadFunc func (request * http.Request , secret []byte ) (* git_provider.WebhookPayload , error )
19
+ SetStatusFunc func (ctx context.Context , repo * string , commit * string , linkURL * string , status * string , message * string ) error
20
+ PingHookFunc func (ctx context.Context , hook * git_provider.HookWithStatus ) error
21
+ GetCorrelatingEventFunc func (ctx context.Context , workflowEvent * v1alpha1.WorkflowPhase ) (string , error )
20
22
}
21
23
22
24
func (m * MockGitProviderClient ) ListFiles (ctx context2.Context , repo string , branch string , path string ) ([]string , error ) {
@@ -67,6 +69,12 @@ func (m *MockGitProviderClient) SetStatus(ctx context2.Context, repo *string, co
67
69
}
68
70
return errors .New ("unimplemented" )
69
71
}
72
+ func (m * MockGitProviderClient ) GetCorrelatingEvent (ctx context.Context , workflowEvent * v1alpha1.WorkflowPhase ) (string , error ) {
73
+ if m .GetCorrelatingEventFunc != nil {
74
+ return m .GetCorrelatingEventFunc (ctx , workflowEvent )
75
+ }
76
+ return "" , errors .New ("unimplemented" )
77
+ }
70
78
71
79
func (m * MockGitProviderClient ) PingHook (ctx context2.Context , hook * git_provider.HookWithStatus ) error {
72
80
if m .PingHookFunc != nil {
0 commit comments