-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.go
More file actions
94 lines (88 loc) · 3.44 KB
/
plugin.go
File metadata and controls
94 lines (88 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Package gitlab provides an EnginePlugin that registers GitLab CI integration:
// - Module types: gitlab.webhook, gitlab.client
// - Step types: step.gitlab_trigger_pipeline, step.gitlab_pipeline_status,
// step.gitlab_create_mr, step.gitlab_mr_comment, step.gitlab_parse_webhook
package gitlab
import (
"github.com/GoCodeAlone/modular"
"github.com/GoCodeAlone/workflow/capability"
"github.com/GoCodeAlone/workflow/module"
"github.com/GoCodeAlone/workflow/plugin"
)
// Plugin registers GitLab CI module types and pipeline step types.
type Plugin struct {
plugin.BaseEnginePlugin
}
// New creates a new GitLab plugin.
func New() *Plugin {
return &Plugin{
BaseEnginePlugin: plugin.BaseEnginePlugin{
BaseNativePlugin: plugin.BaseNativePlugin{
PluginName: "gitlab",
PluginVersion: "1.0.0",
PluginDescription: "GitLab CI integration: webhook receiver, API client, and pipeline steps",
},
Manifest: plugin.PluginManifest{
Name: "gitlab",
Version: "1.0.0",
Author: "GoCodeAlone",
Description: "GitLab CI integration: webhook receiver (gitlab.webhook), API client (gitlab.client), pipeline trigger/status steps, and MR management steps.",
Tier: plugin.TierCore,
ModuleTypes: []string{
"gitlab.webhook",
"gitlab.client",
},
StepTypes: []string{
"step.gitlab_trigger_pipeline",
"step.gitlab_pipeline_status",
"step.gitlab_create_mr",
"step.gitlab_mr_comment",
"step.gitlab_parse_webhook",
},
Capabilities: []plugin.CapabilityDecl{
{Name: "gitlab-ci", Role: "provider", Priority: 50},
},
},
},
}
}
// Capabilities returns the capability contracts defined by this plugin.
func (p *Plugin) Capabilities() []capability.Contract {
return []capability.Contract{
{
Name: "gitlab-ci",
Description: "GitLab CI integration: webhooks, pipeline triggers, pipeline status, merge request management",
},
}
}
// ModuleFactories returns factories for gitlab.webhook and gitlab.client module types.
func (p *Plugin) ModuleFactories() map[string]plugin.ModuleFactory {
return map[string]plugin.ModuleFactory{
"gitlab.webhook": func(name string, cfg map[string]any) modular.Module {
return module.NewGitLabWebhookModule(name, cfg)
},
"gitlab.client": func(name string, cfg map[string]any) modular.Module {
return module.NewGitLabClientModule(name, cfg)
},
}
}
// StepFactories returns factories for the GitLab pipeline step types.
func (p *Plugin) StepFactories() map[string]plugin.StepFactory {
return map[string]plugin.StepFactory{
"step.gitlab_trigger_pipeline": func(name string, cfg map[string]any, app modular.Application) (any, error) {
return module.NewGitLabTriggerPipelineStepFactory()(name, cfg, app)
},
"step.gitlab_pipeline_status": func(name string, cfg map[string]any, app modular.Application) (any, error) {
return module.NewGitLabPipelineStatusStepFactory()(name, cfg, app)
},
"step.gitlab_create_mr": func(name string, cfg map[string]any, app modular.Application) (any, error) {
return module.NewGitLabCreateMRStepFactory()(name, cfg, app)
},
"step.gitlab_mr_comment": func(name string, cfg map[string]any, app modular.Application) (any, error) {
return module.NewGitLabMRCommentStepFactory()(name, cfg, app)
},
"step.gitlab_parse_webhook": func(name string, cfg map[string]any, app modular.Application) (any, error) {
return module.NewGitLabWebhookParseStepFactory()(name, cfg, app)
},
}
}