Skip to content
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
5 changes: 5 additions & 0 deletions pkg/app/pipedv1/cmd/piped/grpcapi/plugin_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (

"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

type PluginAPI struct {
Expand Down Expand Up @@ -164,6 +166,9 @@ func (a *PluginAPI) GetApplicationSharedObject(ctx context.Context, req *service
PluginName: req.PluginName,
Key: req.Key,
})
if status.Code(err) == codes.NotFound {
return nil, status.Error(codes.NotFound, "the requested application shared object was not found")
}
if err != nil {
a.Logger.Error("failed to get application shared object",
zap.String("applicationID", req.ApplicationId),
Expand Down
11 changes: 8 additions & 3 deletions pkg/plugin/sdk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (

"github.com/pipe-cd/piped-plugin-sdk-go/toolregistry"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/pipe-cd/pipecd/pkg/model"
"github.com/pipe-cd/pipecd/pkg/plugin/pipedservice"
Expand Down Expand Up @@ -204,16 +206,19 @@ func (c *Client) GetDeploymentSharedMetadata(ctx context.Context, key string) (s
}

// GetApplicationSharedObject gets the application object which is shared across deployments.
func (c *Client) GetApplicationSharedObject(ctx context.Context, key string) ([]byte, error) {
func (c *Client) GetApplicationSharedObject(ctx context.Context, key string) (obj []byte, found bool, err error) {
resp, err := c.base.GetApplicationSharedObject(ctx, &pipedservice.GetApplicationSharedObjectRequest{
ApplicationId: c.applicationID,
PluginName: c.pluginName,
Key: key,
})
if status.Code(err) == codes.NotFound {
return nil, false, nil
}
if err != nil {
return nil, err
return nil, false, err
}
return resp.Object, nil
return resp.Object, true, nil
}

// PutApplicationSharedObject stores the application object which is shared across deployments.
Expand Down