Skip to content

Commit f2e1ff1

Browse files
committed
Merge branch 'master' of https://github.com/pipe-cd/pipecd into deploy-target-prepare
Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
2 parents 7761719 + a64d83d commit f2e1ff1

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

pkg/plugin/sdk/client.go

+11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
"github.com/pipe-cd/pipecd/pkg/plugin/pipedapi"
2121
"github.com/pipe-cd/pipecd/pkg/plugin/pipedservice"
22+
"github.com/pipe-cd/pipecd/pkg/plugin/toolregistry"
2223
)
2324

2425
// Client is a toolkit for interacting with the piped service.
@@ -42,6 +43,10 @@ type Client struct {
4243
// logPersister is used to persist the stage logs.
4344
// 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.
4445
logPersister StageLogPersister
46+
47+
// toolRegistry is used to install and get the path of the tools used in the plugin.
48+
// TODO: We should consider installing the tools in other way.
49+
toolRegistry *toolregistry.ToolRegistry
4550
}
4651

4752
// StageLogPersister is a interface for persisting the stage logs.
@@ -139,3 +144,9 @@ func (c *Client) GetDeploymentSharedMetadata(ctx context.Context, key string) (s
139144
func (c *Client) LogPersister() StageLogPersister {
140145
return c.logPersister
141146
}
147+
148+
// ToolRegistry returns the tool registry.
149+
// Use this to install and get the path of the tools used in the plugin.
150+
func (c *Client) ToolRegistry() *toolregistry.ToolRegistry {
151+
return c.toolRegistry
152+
}

pkg/plugin/sdk/deployment.go

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/pipe-cd/pipecd/pkg/plugin/logpersister"
3333
"github.com/pipe-cd/pipecd/pkg/plugin/pipedapi"
3434
"github.com/pipe-cd/pipecd/pkg/plugin/signalhandler"
35+
"github.com/pipe-cd/pipecd/pkg/plugin/toolregistry"
3536
)
3637

3738
var (
@@ -114,6 +115,7 @@ type commonFields struct {
114115
logger *zap.Logger
115116
logPersister logPersister
116117
client *pipedapi.PipedServiceClient
118+
toolRegistry *toolregistry.ToolRegistry
117119
}
118120

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

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

320324
return executeStage(ctx, s.base, &s.config, nil, client, request, s.logger) // TODO: pass the deployTargets

pkg/plugin/sdk/sdk.go

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
config "github.com/pipe-cd/pipecd/pkg/configv1"
3232
"github.com/pipe-cd/pipecd/pkg/plugin/logpersister"
3333
"github.com/pipe-cd/pipecd/pkg/plugin/pipedapi"
34+
"github.com/pipe-cd/pipecd/pkg/plugin/toolregistry"
3435
"github.com/pipe-cd/pipecd/pkg/rpc"
3536
)
3637

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

0 commit comments

Comments
 (0)