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

Add RunningDeploymentSource and TargetDeploymentSource to ExecuteStageRequest #5606

Merged
merged 2 commits into from
Feb 26, 2025
Merged
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
36 changes: 34 additions & 2 deletions pkg/plugin/sdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

config "github.com/pipe-cd/pipecd/pkg/configv1"
"github.com/pipe-cd/pipecd/pkg/model"
"github.com/pipe-cd/pipecd/pkg/plugin/api/v1alpha1/common"
"github.com/pipe-cd/pipecd/pkg/plugin/api/v1alpha1/deployment"
"github.com/pipe-cd/pipecd/pkg/plugin/logpersister"
"github.com/pipe-cd/pipecd/pkg/plugin/pipedapi"
Expand Down Expand Up @@ -309,8 +310,10 @@ func executeStage[Config, DeployTargetConfig any](
) (*deployment.ExecuteStageResponse, error) {
in := &ExecuteStageInput{
Request: ExecuteStageRequest{
StageName: request.GetInput().GetStage().GetName(),
StageConfig: request.GetInput().GetStageConfig(),
StageName: request.GetInput().GetStage().GetName(),
StageConfig: request.GetInput().GetStageConfig(),
RunningDeploymentSource: newDeploymentSource(request.GetInput().GetRunningDeploymentSource()),
TargetDeploymentSource: newDeploymentSource(request.GetInput().GetTargetDeploymentSource()),
},
Client: client,
Logger: logger,
Expand Down Expand Up @@ -551,6 +554,35 @@ type ExecuteStageRequest struct {
StageName string
// Json encoded configuration of the stage.
StageConfig []byte

// RunningDeploymentSource is the source of the running deployment.
RunningDeploymentSource DeploymentSource

// TargetDeploymentSource is the source of the target deployment.
TargetDeploymentSource DeploymentSource
}

// DeploymentSource represents the source of the deployment.
type DeploymentSource struct {
// ApplicationDirectory is the directory where the source code is located.
ApplicationDirectory string
// CommitHash is the git commit hash of the source code.
CommitHash string
// ApplicationConfig is the configuration of the application.
ApplicationConfig []byte
// ApplicationConfigFilename is the name of the file that contains the application configuration.
// The plugins can use this to avoid mistakenly reading this file as a manifest to deploy.
ApplicationConfigFilename string
}

// newDeploymentSource converts the common.DeploymentSource to the internal representation.
func newDeploymentSource(source *common.DeploymentSource) DeploymentSource {
return DeploymentSource{
ApplicationDirectory: source.GetApplicationDirectory(),
CommitHash: source.GetCommitHash(),
ApplicationConfig: source.GetApplicationConfig(),
ApplicationConfigFilename: source.GetApplicationConfigFilename(),
}
}

// ExecuteStageResponse is the response of the request to execute a stage.
Expand Down