-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathplugin.go
More file actions
68 lines (59 loc) · 2.45 KB
/
Copy pathplugin.go
File metadata and controls
68 lines (59 loc) · 2.45 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
package deployment
import (
"context"
"github.com/pipe-cd/community-plugins/plugins/sqldef/config"
sdk "github.com/pipe-cd/piped-plugin-sdk-go"
)
type Plugin struct{}
type toolRegistry interface {
Mysqldef(ctx context.Context, version string) (string, error)
}
// FetchDefinedStages returns the defined stages for this plugin.
func (p *Plugin) FetchDefinedStages() []string {
return allStages
}
// BuildPipelineSyncStages returns the stages for the pipeline sync strategy.
func (p *Plugin) BuildPipelineSyncStages(ctx context.Context, _ *sdk.ConfigNone, input *sdk.BuildPipelineSyncStagesInput) (*sdk.BuildPipelineSyncStagesResponse, error) {
// MOCK first, TODO
return &sdk.BuildPipelineSyncStagesResponse{
Stages: buildPipelineStages(input.Request.Stages, input.Request.Rollback),
}, nil
}
// ExecuteStage executes the stage.
func (p *Plugin) ExecuteStage(ctx context.Context, _ *sdk.ConfigNone, dts []*sdk.DeployTarget[config.SqldefDeployTargetConfig], input *sdk.ExecuteStageInput[config.SqldefApplicationSpec]) (*sdk.ExecuteStageResponse, error) {
switch input.Request.StageName {
case SqldefFuncSync:
return &sdk.ExecuteStageResponse{
Status: p.executeSqldefSyncStage(ctx, dts, input),
}, nil
default:
panic("unimplemented stage: " + input.Request.StageName)
}
}
// DetermineVersions determines the versions of the application.
func (p *Plugin) DetermineVersions(ctx context.Context, _ *sdk.ConfigNone, input *sdk.DetermineVersionsInput[config.SqldefApplicationSpec]) (*sdk.DetermineVersionsResponse, error) {
// MOCK first, TODO
return &sdk.DetermineVersionsResponse{
Versions: []sdk.ArtifactVersion{
{
Name: "DetermineVersionsResponse",
Version: "DetermineVersionsResponse",
URL: "DetermineVersionsResponse",
},
},
}, nil
}
// DetermineStrategy determines the strategy for the deployment.
func (p *Plugin) DetermineStrategy(ctx context.Context, _ *sdk.ConfigNone, input *sdk.DetermineStrategyInput[config.SqldefApplicationSpec]) (*sdk.DetermineStrategyResponse, error) {
// MOCK first, TODO
return &sdk.DetermineStrategyResponse{
Strategy: sdk.SyncStrategyPipelineSync,
}, nil
}
// BuildQuickSyncStages returns the stages for the quick sync strategy.
func (p *Plugin) BuildQuickSyncStages(ctx context.Context, _ *sdk.ConfigNone, input *sdk.BuildQuickSyncStagesInput) (*sdk.BuildQuickSyncStagesResponse, error) {
// MOCK first, TODO
return &sdk.BuildQuickSyncStagesResponse{
Stages: buildQuickSync(input.Request.Rollback),
}, nil
}