fix: rename mcS3Client to mcClient (#214)
Co-authored-by: Minio Trusted <trusted@minio.io>
This commit is contained in:
@@ -93,10 +93,10 @@ func (c minioClient) getBucketPolicy(ctx context.Context, bucketName string) (st
|
|||||||
return c.client.GetBucketPolicy(ctx, bucketName)
|
return c.client.GetBucketPolicy(ctx, bucketName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MCS3Client interface with all functions to be implemented
|
// MCClient interface with all functions to be implemented
|
||||||
// by mock when testing, it should include all mc/S3Client respective api calls
|
// by mock when testing, it should include all mc/S3Client respective api calls
|
||||||
// that are used within this project.
|
// that are used within this project.
|
||||||
type MCS3Client interface {
|
type MCClient interface {
|
||||||
addNotificationConfig(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error
|
addNotificationConfig(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error
|
||||||
removeNotificationConfig(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error
|
removeNotificationConfig(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error
|
||||||
watch(ctx context.Context, options mc.WatchOptions) (*mc.WatchObject, *probe.Error)
|
watch(ctx context.Context, options mc.WatchOptions) (*mc.WatchObject, *probe.Error)
|
||||||
@@ -106,21 +106,21 @@ type MCS3Client interface {
|
|||||||
//
|
//
|
||||||
// Define the structure of a mc S3Client and define the functions that are actually used
|
// Define the structure of a mc S3Client and define the functions that are actually used
|
||||||
// from mcS3client api.
|
// from mcS3client api.
|
||||||
type mcS3Client struct {
|
type mcClient struct {
|
||||||
client *mc.S3Client
|
client *mc.S3Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// implements S3Client.AddNotificationConfig()
|
// implements S3Client.AddNotificationConfig()
|
||||||
func (c mcS3Client) addNotificationConfig(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
|
func (c mcClient) addNotificationConfig(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
|
||||||
return c.client.AddNotificationConfig(ctx, arn, events, prefix, suffix, ignoreExisting)
|
return c.client.AddNotificationConfig(ctx, arn, events, prefix, suffix, ignoreExisting)
|
||||||
}
|
}
|
||||||
|
|
||||||
// implements S3Client.RemoveNotificationConfig()
|
// implements S3Client.RemoveNotificationConfig()
|
||||||
func (c mcS3Client) removeNotificationConfig(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error {
|
func (c mcClient) removeNotificationConfig(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error {
|
||||||
return c.client.RemoveNotificationConfig(ctx, arn, event, prefix, suffix)
|
return c.client.RemoveNotificationConfig(ctx, arn, event, prefix, suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c mcS3Client) watch(ctx context.Context, options mc.WatchOptions) (*mc.WatchObject, *probe.Error) {
|
func (c mcClient) watch(ctx context.Context, options mc.WatchOptions) (*mc.WatchObject, *probe.Error) {
|
||||||
return c.client.Watch(ctx, options)
|
return c.client.Watch(ctx, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ func getListBucketEventsResponse(session *models.Principal, params user_api.List
|
|||||||
// If notificationEvents is empty, by default will set [get, put, delete], else the provided
|
// If notificationEvents is empty, by default will set [get, put, delete], else the provided
|
||||||
// ones will be set.
|
// ones will be set.
|
||||||
// this function follows same behavior as minio/mc for adding a bucket event
|
// this function follows same behavior as minio/mc for adding a bucket event
|
||||||
func createBucketEvent(ctx context.Context, client MCS3Client, arn string, notificationEvents []models.NotificationEventType, prefix, suffix string, ignoreExisting bool) error {
|
func createBucketEvent(ctx context.Context, client MCClient, arn string, notificationEvents []models.NotificationEventType, prefix, suffix string, ignoreExisting bool) error {
|
||||||
var events []string
|
var events []string
|
||||||
if len(notificationEvents) == 0 {
|
if len(notificationEvents) == 0 {
|
||||||
// default event values are [get, put, delete]
|
// default event values are [get, put, delete]
|
||||||
@@ -187,8 +187,8 @@ func getCreateBucketEventsResponse(session *models.Principal, bucketName string,
|
|||||||
}
|
}
|
||||||
// create a mc S3Client interface implementation
|
// create a mc S3Client interface implementation
|
||||||
// defining the client to be used
|
// defining the client to be used
|
||||||
mcS3Client := mcS3Client{client: s3Client}
|
mcClient := mcClient{client: s3Client}
|
||||||
err = createBucketEvent(ctx, mcS3Client, *eventReq.Configuration.Arn, eventReq.Configuration.Events, eventReq.Configuration.Prefix, eventReq.Configuration.Suffix, eventReq.IgnoreExisting)
|
err = createBucketEvent(ctx, mcClient, *eventReq.Configuration.Arn, eventReq.Configuration.Events, eventReq.Configuration.Prefix, eventReq.Configuration.Suffix, eventReq.IgnoreExisting)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error creating bucket event:", err)
|
log.Println("error creating bucket event:", err)
|
||||||
return err
|
return err
|
||||||
@@ -197,7 +197,7 @@ func getCreateBucketEventsResponse(session *models.Principal, bucketName string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// deleteBucketEventNotification calls S3Client.RemoveNotificationConfig to remove a bucket event notification
|
// deleteBucketEventNotification calls S3Client.RemoveNotificationConfig to remove a bucket event notification
|
||||||
func deleteBucketEventNotification(ctx context.Context, client MCS3Client, arn string, events []models.NotificationEventType, prefix, suffix *string) error {
|
func deleteBucketEventNotification(ctx context.Context, client MCClient, arn string, events []models.NotificationEventType, prefix, suffix *string) error {
|
||||||
eventSingleString := joinNotificationEvents(events)
|
eventSingleString := joinNotificationEvents(events)
|
||||||
perr := client.removeNotificationConfig(ctx, arn, eventSingleString, *prefix, *suffix)
|
perr := client.removeNotificationConfig(ctx, arn, eventSingleString, *prefix, *suffix)
|
||||||
if perr != nil {
|
if perr != nil {
|
||||||
@@ -224,8 +224,8 @@ func getDeleteBucketEventsResponse(session *models.Principal, bucketName string,
|
|||||||
}
|
}
|
||||||
// create a mc S3Client interface implementation
|
// create a mc S3Client interface implementation
|
||||||
// defining the client to be used
|
// defining the client to be used
|
||||||
mcS3Client := mcS3Client{client: s3Client}
|
mcClient := mcClient{client: s3Client}
|
||||||
err = deleteBucketEventNotification(ctx, mcS3Client, arn, events, prefix, suffix)
|
err = deleteBucketEventNotification(ctx, mcClient, arn, events, prefix, suffix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error deleting bucket event:", err)
|
log.Println("error deleting bucket event:", err)
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ type watchOptions struct {
|
|||||||
mc.WatchOptions
|
mc.WatchOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
func startWatch(ctx context.Context, conn WSConn, wsc MCS3Client, options watchOptions) error {
|
func startWatch(ctx context.Context, conn WSConn, wsc MCClient, options watchOptions) error {
|
||||||
wo, pErr := wsc.watch(ctx, options.WatchOptions)
|
wo, pErr := wsc.watch(ctx, options.WatchOptions)
|
||||||
if pErr != nil {
|
if pErr != nil {
|
||||||
fmt.Println("error initializing watch:", pErr.Cause)
|
fmt.Println("error initializing watch:", pErr.Cause)
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ type ConsoleWebsocket interface {
|
|||||||
type wsS3Client struct {
|
type wsS3Client struct {
|
||||||
// websocket connection.
|
// websocket connection.
|
||||||
conn wsConn
|
conn wsConn
|
||||||
// mcS3Client
|
// mcClient
|
||||||
client MCS3Client
|
client MCClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// WSConn interface with all functions to be implemented
|
// WSConn interface with all functions to be implemented
|
||||||
@@ -197,7 +197,7 @@ func newWebSocketS3Client(conn *websocket.Conn, claims *models.Principal, bucket
|
|||||||
wsConnection := wsConn{conn: conn}
|
wsConnection := wsConn{conn: conn}
|
||||||
// create a s3Client interface implementation
|
// create a s3Client interface implementation
|
||||||
// defining the client to be used
|
// defining the client to be used
|
||||||
mcS3C := mcS3Client{client: s3Client}
|
mcS3C := mcClient{client: s3Client}
|
||||||
// create websocket client and handle request
|
// create websocket client and handle request
|
||||||
wsS3Client := &wsS3Client{conn: wsConnection, client: mcS3C}
|
wsS3Client := &wsS3Client{conn: wsConnection, client: mcS3C}
|
||||||
return wsS3Client, nil
|
return wsS3Client, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user