Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WAIT,SDK] Implemented Wait stage with SDK #5586

Merged
merged 17 commits into from
Feb 19, 2025
Merged
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
2 changes: 1 addition & 1 deletion pkg/app/pipedv1/controller/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ func (s *scheduler) executeStage(sig StopSignal, ps *model.PipelineStage) (final
}

// Load the stage configuration.
stageConfig, stageConfigFound := s.genericApplicationConfig.GetStageByte(ps.Index)
stageConfig, stageConfigFound := s.genericApplicationConfig.GetStageConfigByte(ps.Index)
if !stageConfigFound {
s.logger.Error("Unable to find the stage configuration", zap.String("stage-name", ps.Name))
if err := s.reportStageStatus(ctx, ps.Id, model.StageStatus_STAGE_FAILURE, ps.Requires); err != nil {
Expand Down
7 changes: 3 additions & 4 deletions pkg/app/pipedv1/plugin/example/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import (
"context"

"github.com/pipe-cd/pipecd/pkg/plugin/logpersister"
"github.com/pipe-cd/pipecd/pkg/plugin/sdk"
)

Expand All @@ -36,13 +35,13 @@
}

// BuildPipelineSyncStages implements sdk.PipelineSyncPlugin.
func (p *plugin) BuildPipelineSyncStages(context.Context, *config, *sdk.Client, *sdk.BuildPipelineSyncStagesRequest) (*sdk.BuildPipelineSyncStagesResponse, error) {
func (p *plugin) BuildPipelineSyncStages(context.Context, *config, *sdk.BuildPipelineSyncStagesInput) (*sdk.BuildPipelineSyncStagesResponse, error) {

Check warning on line 38 in pkg/app/pipedv1/plugin/example/plugin.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/pipedv1/plugin/example/plugin.go#L38

Added line #L38 was not covered by tests
return &sdk.BuildPipelineSyncStagesResponse{}, nil
}

// ExecuteStage implements sdk.PipelineSyncPlugin.
func (p *plugin) ExecuteStage(context.Context, *config, sdk.DeployTargetsNone, *sdk.Client, logpersister.StageLogPersister, sdk.TODO) (sdk.TODO, error) {
return sdk.TODO{}, nil
func (p *plugin) ExecuteStage(context.Context, *config, sdk.DeployTargetsNone, *sdk.ExecuteStageInput) (*sdk.ExecuteStageResponse, error) {
return &sdk.ExecuteStageResponse{}, nil

Check warning on line 44 in pkg/app/pipedv1/plugin/example/plugin.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/pipedv1/plugin/example/plugin.go#L43-L44

Added lines #L43 - L44 were not covered by tests
}

// FetchDefinedStages implements sdk.PipelineSyncPlugin.
Expand Down
117 changes: 0 additions & 117 deletions pkg/app/pipedv1/plugin/wait/deployment/server.go

This file was deleted.

120 changes: 0 additions & 120 deletions pkg/app/pipedv1/plugin/wait/deployment/wait.go

This file was deleted.

17 changes: 6 additions & 11 deletions pkg/app/pipedv1/plugin/wait/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 The PipeCD Authors.
// Copyright 2025 The PipeCD Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,18 +17,13 @@
import (
"log"

"github.com/pipe-cd/pipecd/pkg/cli"
"github.com/pipe-cd/pipecd/pkg/plugin/sdk"
)

func main() {
app := cli.NewApp(
"pipecd-plugin-stage-wait",
"Plugin component to execute Wait Stage.",
)
app.AddCommands(
newPluginCommand(),
)
if err := app.Run(); err != nil {
log.Fatal(err)
sdk.RegisterPipelineSyncPlugin(&plugin{})

if err := sdk.Run(); err != nil {
log.Fatalln(err)

Check warning on line 27 in pkg/app/pipedv1/plugin/wait/main.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/pipedv1/plugin/wait/main.go#L24-L27

Added lines #L24 - L27 were not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package main

import (
"encoding/json"
Expand All @@ -24,8 +24,6 @@ import (
// WaitStageOptions contains configurable values for a WAIT stage.
type WaitStageOptions struct {
Duration config.Duration `json:"duration,omitempty"`
// TODO: Handle SkipOn options.
// SkipOn config.SkipOptions `json:"skipOn,omitempty"`
}

func (o WaitStageOptions) validate() error {
Expand All @@ -35,8 +33,8 @@ func (o WaitStageOptions) validate() error {
return nil
}

// Decode decodes the raw JSON data and validates it.
func Decode(data json.RawMessage) (WaitStageOptions, error) {
// decode decodes the raw JSON data and validates it.
func decode(data json.RawMessage) (WaitStageOptions, error) {
var opts WaitStageOptions
if err := json.Unmarshal(data, &opts); err != nil {
return WaitStageOptions{}, fmt.Errorf("failed to unmarshal the config: %w", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package main

import (
"encoding/json"
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestDecode(t *testing.T) {
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
got, err := Decode(tc.data)
got, err := decode(tc.data)
assert.Equal(t, tc.wantErr, err != nil)
assert.Equal(t, tc.expected, got)
})
Expand Down
Loading