Skip to content

Commit

Permalink
change the request type from string to bytes in the proto file
Browse files Browse the repository at this point in the history
Signed-off-by: Shinya Hayashi <[email protected]>
  • Loading branch information
peng225 committed Oct 28, 2024
1 parent f78824d commit 780cd60
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 45 deletions.
4 changes: 2 additions & 2 deletions docs/controller-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CreateOrUpdateMantleBackupRequest is a request message for CreateOrUpdateMantleB

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| mantleBackup | [string](#string) | | |
| mantleBackup | [bytes](#bytes) | | |



Expand All @@ -59,7 +59,7 @@ CreateOrUpdatePVCRequest is a request message for CreateOrUpdatePVC RPC.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| pvc | [string](#string) | | |
| pvc | [bytes](#bytes) | | |



Expand Down
4 changes: 2 additions & 2 deletions internal/controller/mantlebackup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ func (r *MantleBackupReconciler) replicateManifests(
resp, err := client.CreateOrUpdatePVC(
ctx,
&proto.CreateOrUpdatePVCRequest{
Pvc: string(pvcSentJson),
Pvc: pvcSentJson,
},
)
if err != nil {
Expand Down Expand Up @@ -553,7 +553,7 @@ func (r *MantleBackupReconciler) replicateManifests(
if _, err := client.CreateOrUpdateMantleBackup(
ctx,
&proto.CreateOrUpdateMantleBackupRequest{
MantleBackup: string(backupSentJson),
MantleBackup: backupSentJson,
},
); err != nil {
return ctrl.Result{}, err
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/mantlebackup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ var _ = Describe("MantleBackup controller", func() {
req *proto.CreateOrUpdateMantleBackupRequest,
opts ...grpc.CallOption,
) (*proto.CreateOrUpdateMantleBackupResponse, error) {
err := json.Unmarshal([]byte(req.GetMantleBackup()), &targetBackup)
err := json.Unmarshal(req.GetMantleBackup(), &targetBackup)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (s *SecondaryServer) CreateOrUpdatePVC(
) (*proto.CreateOrUpdatePVCResponse, error) {
// Unmarshal the request
var pvcReceived corev1.PersistentVolumeClaim
if err := json.Unmarshal([]byte(req.Pvc), &pvcReceived); err != nil {
if err := json.Unmarshal(req.Pvc, &pvcReceived); err != nil {
return nil, fmt.Errorf("failed to unmarshal the requested PVC: %w", err)
}

Expand Down Expand Up @@ -104,7 +104,7 @@ func (s *SecondaryServer) CreateOrUpdateMantleBackup(
req *proto.CreateOrUpdateMantleBackupRequest,
) (*proto.CreateOrUpdateMantleBackupResponse, error) {
var backupReceived mantlev1.MantleBackup
if err := json.Unmarshal([]byte(req.MantleBackup), &backupReceived); err != nil {
if err := json.Unmarshal(req.MantleBackup, &backupReceived); err != nil {
return nil, err
}

Expand Down
156 changes: 121 additions & 35 deletions pkg/controller/proto/controller.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/controller/proto/controller.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option go_package = "github.com/cybozu-go/mantle/pkg/controller/proto";

// CreateOrUpdatePVCRequest is a request message for CreateOrUpdatePVC RPC.
message CreateOrUpdatePVCRequest {
string pvc = 1;
bytes pvc = 1;
}

// CreateOrUpdatePVCResponse is a response message for CreateOrUpdatePVC RPC.
Expand All @@ -16,7 +16,7 @@ message CreateOrUpdatePVCResponse {

// CreateOrUpdateMantleBackupRequest is a request message for CreateOrUpdateMantleBackup RPC.
message CreateOrUpdateMantleBackupRequest {
string mantleBackup = 1;
bytes mantleBackup = 1;
}

// CreateOrUpdateMantleBackupResponse is a response message for CreateOrUpdateMantleBackup RPC.
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/proto/controller_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 780cd60

Please sign in to comment.