pipe-cd / pipecd

The One CD for All {applications, platforms, operations}
https://pipecd.dev
Apache License 2.0
997 stars 142 forks source link

Piped plugin architecture #4980

Open khanhtc1202 opened 1 week ago

khanhtc1202 commented 1 week ago

What would you like to be added:

This issue is for managing the process of adopting plugin architecture to piped. The ideal result is to make all platform providers' logic independent from the piped core logic (the controller package).

Why is this needed:

khanhtc1202 commented 1 week ago

As the current stage, the interface for the plugin of the piped as below We have 2 services: The PlannerService

// PlannerService defines the public APIs for remote planners.
service PlannerService {
    // BuildPlan builds plan for the given deployment.
    rpc BuildPlan(BuildPlanRequest) returns (BuildPlanResponse) {}
}

message BuildPlanRequest {
    string working_dir = 1 [(validate.rules).string.min_len = 1];
    // Last successful commit hash and config file name.
    // Use to build deployment source object for last successful deployment.
    string last_successful_commit_hash = 2;
    string last_successful_config_file_name = 3;
    // The configuration of the piped that handles the deployment.
    bytes piped_config = 4 [(validate.rules).bytes.min_len = 1];
    // The deployment to build a plan for.
    model.Deployment deployment = 5 [(validate.rules).message.required = true];
}

message BuildPlanResponse {
    // The built deployment plan.
    DeploymentPlan plan = 1;
}

message DeploymentPlan {
    model.SyncStrategy sync_strategy = 1;
    // Text summary of planned deployment.
    string summary = 2;
    repeated model.ArtifactVersion versions = 3;
    repeated model.PipelineStage stages = 4;
}

And, the ExecutorService

service ExecutorService {
    // Execute executes the given stage of the deployment plan.
    rpc ExecuteStage(ExecuteStageRequest) returns (stream ExecuteStageResponse) {}
}

message ExecuteStageRequest {
    model.PipelineStage stage = 1 [(validate.rules).message.required = true];
    bytes stage_config = 2 [(validate.rules).bytes.min_len = 1];
    bytes piped_config = 3 [(validate.rules).bytes.min_len = 1];
    model.Deployment deployment = 4 [(validate.rules).message.required = true];
}

message ExecuteStageResponse {
    model.StageStatus status = 1;
    string log = 2;
}

ref: https://github.com/pipe-cd/pipecd/blob/master/pkg/plugin/api/v1alpha1/platform/api.proto