-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Terrarium - Providers]: Implementation of Storage Feature - 1 (#70)
* protobuff definitions for consumer service * updated gen_proto.sh * removed ConsumerService as not required * format * [Terrarium - Providers]: Implementation of Storage Feature - 2 (#71) * implementation of consumer service * update in functions as we remove consumer service * go fmt * Update internal/provider/services/storage/storage.go Co-authored-by: Adam Charrett <[email protected]> * updated storage.go * enhance error logs * updated storage_test * fix * fix * updated storage_test and mock server * [Terrarium - Providers]: Implementation of Storage Feature - 3 (#72) --------- Co-authored-by: Anjani Kumar Srivastava <[email protected]> Co-authored-by: Adam Charrett <[email protected]> --------- Co-authored-by: Anjani Kumar Srivastava <[email protected]> Co-authored-by: Adam Charrett <[email protected]>
- Loading branch information
1 parent
d8616d2
commit 7c5a688
Showing
19 changed files
with
1,975 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package cmd | ||
|
||
import ( | ||
providerStorage "github.com/terrariumcloud/terrarium/internal/provider/services/storage" | ||
"github.com/terrariumcloud/terrarium/internal/storage" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var providerStorageServiceCmd = &cobra.Command{ | ||
Use: "provider-storage", | ||
Short: "Starts the Terrarium GRPC Provider Storage service", | ||
Long: "Runs the Terrarium GRPC Provider Storage server.", | ||
Run: runProviderStorageService, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(providerStorageServiceCmd) | ||
providerStorageServiceCmd.Flags().StringVarP(&providerStorage.BucketName, "bucket", "b", providerStorage.DefaultBucketName, "Provider bucket name") | ||
} | ||
|
||
func runProviderStorageService(cmd *cobra.Command, args []string) { | ||
|
||
storageServiceServer := &providerStorage.StorageService{ | ||
Client: storage.NewS3Client(awsSessionConfig), | ||
BucketName: providerStorage.BucketName, | ||
Region: awsSessionConfig.Region, | ||
} | ||
|
||
startGRPCService("provider-storage-s3", storageServiceServer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package mocks | ||
|
||
import ( | ||
"context" | ||
|
||
providerServices "github.com/terrariumcloud/terrarium/internal/provider/services" | ||
|
||
"google.golang.org/grpc" | ||
) | ||
|
||
type MockProviderStorageClient struct { | ||
providerServices.StorageClient | ||
DownloadSourceZipInvocations int | ||
DownloadSourceZipClient providerServices.Storage_DownloadProviderSourceZipClient | ||
DownloadSourceZipError error | ||
DownloadShasumInvocations int | ||
DownloadShasumClient providerServices.Storage_DownloadShasumClient | ||
DownloadShasumError error | ||
DownloadShasumSignatureInvocations int | ||
DownloadShasumSignatureClient providerServices.Storage_DownloadShasumSignatureClient | ||
DownloadShasumSignatureError error | ||
} | ||
|
||
func (m *MockProviderStorageClient) DownloadProviderSourceZip(ctx context.Context, in *providerServices.DownloadSourceZipRequest, opts ...grpc.CallOption) (providerServices.Storage_DownloadProviderSourceZipClient, error) { | ||
m.DownloadSourceZipInvocations++ | ||
return m.DownloadSourceZipClient, m.DownloadSourceZipError | ||
} | ||
|
||
func (m *MockProviderStorageClient) DownloadShasum(ctx context.Context, in *providerServices.DownloadShasumRequest, opts ...grpc.CallOption) (providerServices.Storage_DownloadShasumClient, error) { | ||
m.DownloadShasumInvocations++ | ||
return m.DownloadShasumClient, m.DownloadShasumError | ||
} | ||
|
||
func (m *MockProviderStorageClient) DownloadShasumSignature(ctx context.Context, in *providerServices.DownloadShasumRequest, opts ...grpc.CallOption) (providerServices.Storage_DownloadShasumSignatureClient, error) { | ||
m.DownloadShasumSignatureInvocations++ | ||
return m.DownloadShasumSignatureClient, m.DownloadShasumSignatureError | ||
} | ||
|
||
type MockStorage_DownloadProviderSourceZipClient struct { | ||
providerServices.Storage_DownloadProviderSourceZipClient | ||
RecvInvocations int | ||
RecvResponse *providerServices.SourceZipResponse | ||
RecvError error | ||
CloseSendInvocations int | ||
CloseSendError error | ||
} | ||
|
||
func (m *MockStorage_DownloadProviderSourceZipClient) Recv() (*providerServices.SourceZipResponse, error) { | ||
m.RecvInvocations++ | ||
return m.RecvResponse, m.RecvError | ||
} | ||
|
||
func (m *MockStorage_DownloadProviderSourceZipClient) CloseSend() error { | ||
m.CloseSendInvocations++ | ||
return m.CloseSendError | ||
} | ||
|
||
type MockStorage_DownloadProviderShasumClient struct { | ||
providerServices.Storage_DownloadShasumClient | ||
RecvInvocations int | ||
RecvResponse *providerServices.DownloadShasumResponse | ||
RecvError error | ||
CloseSendInvocations int | ||
CloseSendError error | ||
} | ||
|
||
func (m *MockStorage_DownloadProviderShasumClient) Recv() (*providerServices.DownloadShasumResponse, error) { | ||
m.RecvInvocations++ | ||
return m.RecvResponse, m.RecvError | ||
} | ||
|
||
func (m *MockStorage_DownloadProviderShasumClient) CloseSend() error { | ||
m.CloseSendInvocations++ | ||
return m.CloseSendError | ||
} | ||
|
||
type MockStorage_DownloadProviderShasumSignatureClient struct { | ||
providerServices.Storage_DownloadShasumSignatureClient | ||
RecvInvocations int | ||
RecvResponse *providerServices.DownloadShasumResponse | ||
RecvError error | ||
CloseSendInvocations int | ||
CloseSendError error | ||
} | ||
|
||
func (m *MockStorage_DownloadProviderShasumSignatureClient) Recv() (*providerServices.DownloadShasumResponse, error) { | ||
m.RecvInvocations++ | ||
return m.RecvResponse, m.RecvError | ||
} | ||
|
||
func (m *MockStorage_DownloadProviderShasumSignatureClient) CloseSend() error { | ||
m.CloseSendInvocations++ | ||
return m.CloseSendError | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package mocks | ||
|
||
import ( | ||
"context" | ||
|
||
providerServices "github.com/terrariumcloud/terrarium/internal/provider/services" | ||
) | ||
|
||
type MockDownloadProviderSourceZipServer struct { | ||
providerServices.Storage_DownloadProviderSourceZipServer | ||
SendInvocations int | ||
SendResponse *providerServices.SourceZipResponse | ||
SendError error | ||
TotalReceived []byte | ||
} | ||
|
||
func (mds *MockDownloadProviderSourceZipServer) Context() context.Context { | ||
return context.TODO() | ||
} | ||
|
||
func (mds *MockDownloadProviderSourceZipServer) Send(res *providerServices.SourceZipResponse) error { | ||
mds.SendInvocations++ | ||
mds.SendResponse = res | ||
mds.TotalReceived = append(mds.TotalReceived, mds.SendResponse.ZipDataChunk...) | ||
return mds.SendError | ||
} | ||
|
||
type MockDownloadProviderShasumServer struct { | ||
providerServices.Storage_DownloadShasumServer | ||
SendInvocations int | ||
SendResponse *providerServices.DownloadShasumResponse | ||
SendError error | ||
TotalReceived []byte | ||
} | ||
|
||
func (mds *MockDownloadProviderShasumServer) Context() context.Context { | ||
return context.TODO() | ||
} | ||
|
||
func (mds *MockDownloadProviderShasumServer) Send(res *providerServices.DownloadShasumResponse) error { | ||
mds.SendInvocations++ | ||
mds.SendResponse = res | ||
mds.TotalReceived = append(mds.TotalReceived, mds.SendResponse.ShasumDataChunk...) | ||
return mds.SendError | ||
} | ||
|
||
type MockDownloadProviderShasumSignatureServer struct { | ||
providerServices.Storage_DownloadShasumSignatureServer | ||
SendInvocations int | ||
SendResponse *providerServices.DownloadShasumResponse | ||
SendError error | ||
TotalReceived []byte | ||
} | ||
|
||
func (mds *MockDownloadProviderShasumSignatureServer) Context() context.Context { | ||
return context.TODO() | ||
} | ||
|
||
func (mds *MockDownloadProviderShasumSignatureServer) Send(res *providerServices.DownloadShasumResponse) error { | ||
mds.SendInvocations++ | ||
mds.SendResponse = res | ||
mds.TotalReceived = append(mds.TotalReceived, mds.SendResponse.ShasumDataChunk...) | ||
return mds.SendError | ||
} |
Oops, something went wrong.