Skip to content

Commit

Permalink
added the new payload
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveromahony committed Nov 13, 2024
1 parent af04540 commit 283b7ae
Show file tree
Hide file tree
Showing 7 changed files with 308 additions and 237 deletions.
478 changes: 246 additions & 232 deletions api/grpc/mpi/v1/files.pb.go

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions api/grpc/mpi/v1/files.pb.validate.go

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

7 changes: 5 additions & 2 deletions api/grpc/mpi/v1/files.proto
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ message UpdateOverviewRequest {
FileOverview overview = 2;
}

// Represents a the response from an UpdateOverviewRequest - intentionally left empty
message UpdateOverviewResponse {}
// Represents a the response from an UpdateOverviewRequest
message UpdateOverviewResponse {
// The file overview with the list of files that were uploaded
FileOverview overview = 1;
}

// Represents a specific configuration version associated with an instance
message ConfigVersion {
Expand Down
7 changes: 6 additions & 1 deletion docs/proto/protos.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,12 @@ Represents a list of logically grouped files that have changed e.g. configuratio
<a name="mpi-v1-UpdateOverviewResponse"></a>

### UpdateOverviewResponse
Represents a the response from an UpdateOverviewRequest - intentionally left empty
Represents a the response from an UpdateOverviewRequest


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| overview | [FileOverview](#mpi-v1-FileOverview) | | The file overview with the list of files that were uploaded |



Expand Down
8 changes: 8 additions & 0 deletions internal/file/file_manager_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ func (fms *FileManagerService) UpdateOverview(
return nil, validatedError
}

response.Overview = &mpi.FileOverview{
Files: filesToUpdate,
ConfigVersion: &mpi.ConfigVersion{
InstanceId: instanceID,
Version: files.GenerateConfigVersion(filesToUpdate),
},
}

return response, nil
}

Expand Down
12 changes: 11 additions & 1 deletion internal/file/file_manager_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,19 @@ import (
func TestFileManagerService_UpdateOverview(t *testing.T) {
ctx := context.Background()

fileMeta := protos.FileMeta("/etc/nginx/nginx.conf", "")
filePath := filepath.Join(t.TempDir(), "nginx.conf")
fileMeta := protos.FileMeta(filePath, "")

fileContent := []byte("location /test {\n return 200 \"Test location\\n\";\n}")
fileHash := files.GenerateHash(fileContent)

overview := protos.FileOverview(filePath, fileHash)

fakeFileServiceClient := &v1fakes.FakeFileServiceClient{}
fakeFileServiceClient.UpdateOverviewReturns(&mpi.UpdateOverviewResponse{
Overview: overview,
}, nil)

fileManagerService := NewFileManagerService(fakeFileServiceClient, types.AgentConfig())
fileManagerService.SetIsConnected(true)

Expand Down
4 changes: 3 additions & 1 deletion test/mock/grpc/mock_management_file_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ func (mgs *FileService) UpdateOverview(
}
mgs.requestChan <- configUploadRequest

return &v1.UpdateOverviewResponse{}, nil
return &v1.UpdateOverviewResponse{
Overview: request.GetOverview(),
}, nil
}

func (mgs *FileService) GetFile(
Expand Down

0 comments on commit 283b7ae

Please sign in to comment.