Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pipe-cd/pipecd into deplo…
Browse files Browse the repository at this point in the history
…y-target-prepare

Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
  • Loading branch information
Warashi committed Mar 5, 2025
2 parents 7761719 + a64d83d commit f2e1ff1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/plugin/sdk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/pipe-cd/pipecd/pkg/plugin/pipedapi"
"github.com/pipe-cd/pipecd/pkg/plugin/pipedservice"
"github.com/pipe-cd/pipecd/pkg/plugin/toolregistry"
)

// Client is a toolkit for interacting with the piped service.
Expand All @@ -42,6 +43,10 @@ type Client struct {
// logPersister is used to persist the stage logs.
// This field exists only when the client is working with a specific stage; for example, when this client is passed as the ExecuteStage method's argument.
logPersister StageLogPersister

// toolRegistry is used to install and get the path of the tools used in the plugin.
// TODO: We should consider installing the tools in other way.
toolRegistry *toolregistry.ToolRegistry
}

// StageLogPersister is a interface for persisting the stage logs.
Expand Down Expand Up @@ -139,3 +144,9 @@ func (c *Client) GetDeploymentSharedMetadata(ctx context.Context, key string) (s
func (c *Client) LogPersister() StageLogPersister {
return c.logPersister
}

// ToolRegistry returns the tool registry.
// Use this to install and get the path of the tools used in the plugin.
func (c *Client) ToolRegistry() *toolregistry.ToolRegistry {
return c.toolRegistry
}
4 changes: 4 additions & 0 deletions pkg/plugin/sdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/pipe-cd/pipecd/pkg/plugin/logpersister"
"github.com/pipe-cd/pipecd/pkg/plugin/pipedapi"
"github.com/pipe-cd/pipecd/pkg/plugin/signalhandler"
"github.com/pipe-cd/pipecd/pkg/plugin/toolregistry"
)

var (
Expand Down Expand Up @@ -114,6 +115,7 @@ type commonFields struct {
logger *zap.Logger
logPersister logPersister
client *pipedapi.PipedServiceClient
toolRegistry *toolregistry.ToolRegistry
}

// DeploymentPluginServiceServer is the gRPC server that handles requests from the piped.
Expand Down Expand Up @@ -221,6 +223,7 @@ func (s *DeploymentPluginServiceServer[Config, DeployTargetConfig]) ExecuteStage
deploymentID: request.GetInput().GetDeployment().GetId(),
stageID: request.GetInput().GetStage().GetId(),
logPersister: lp,
toolRegistry: s.toolRegistry,
}

// Get the deploy targets set on the deployment from the piped plugin config.
Expand Down Expand Up @@ -315,6 +318,7 @@ func (s *StagePluginServiceServer[Config, DeployTargetConfig]) ExecuteStage(ctx
deploymentID: request.GetInput().GetDeployment().GetId(),
stageID: request.GetInput().GetStage().GetId(),
logPersister: lp,
toolRegistry: s.toolRegistry,
}

return executeStage(ctx, s.base, &s.config, nil, client, request, s.logger) // TODO: pass the deployTargets
Expand Down
2 changes: 2 additions & 0 deletions pkg/plugin/sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
config "github.com/pipe-cd/pipecd/pkg/configv1"
"github.com/pipe-cd/pipecd/pkg/plugin/logpersister"
"github.com/pipe-cd/pipecd/pkg/plugin/pipedapi"
"github.com/pipe-cd/pipecd/pkg/plugin/toolregistry"
"github.com/pipe-cd/pipecd/pkg/rpc"
)

Expand Down Expand Up @@ -161,6 +162,7 @@ func (s *plugin) run(ctx context.Context, input cli.Input) (runErr error) {
logger: input.Logger.Named("deployment-service"),
logPersister: persister,
client: pipedapiClient,
toolRegistry: toolregistry.NewToolRegistry(pipedapiClient),
}); err != nil {
input.Logger.Error("failed to set fields", zap.Error(err))

Check warning on line 167 in pkg/plugin/sdk/sdk.go

View check run for this annotation

Codecov / codecov/patch

pkg/plugin/sdk/sdk.go#L166-L167

Added lines #L166 - L167 were not covered by tests
return err
Expand Down

0 comments on commit f2e1ff1

Please sign in to comment.