Skip to content

Commit 4a5be81

Browse files
authored
update minio-operator version (#199)
1 parent e6a3bd5 commit 4a5be81

12 files changed

+205
-120
lines changed

go.mod

+8-7
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@ require (
1515
github.com/go-openapi/validate v0.19.10
1616
github.com/gorilla/websocket v1.4.2
1717
github.com/jessevdk/go-flags v1.4.0
18-
github.com/json-iterator/go v1.1.9
18+
github.com/json-iterator/go v1.1.10
1919
github.com/minio/cli v1.22.0
20-
github.com/minio/mc v0.0.0-20200515235434-3b479cf92ed6
21-
github.com/minio/minio v0.0.0-20200603201854-5686a7e27319
22-
github.com/minio/minio-go/v6 v6.0.56
23-
github.com/minio/minio-operator v0.0.0-20200520220606-60eca6e7beab
20+
github.com/minio/mc v0.0.0-20200719194630-c8a3b7bff08c
21+
github.com/minio/minio v0.0.0-20200714163805-778e9c864f67
22+
github.com/minio/minio-go/v6 v6.0.58-0.20200612001654-a57fec8037ec
23+
github.com/minio/minio-go/v7 v7.0.2-0.20200718235721-f0e2f3ae3678
24+
github.com/minio/minio-operator v0.0.0-20200713191021-de7c5283f7e5
2425
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect
2526
github.com/satori/go.uuid v1.2.0
2627
github.com/stretchr/testify v1.6.1
2728
github.com/unrolled/secure v1.0.7
28-
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975
29-
golang.org/x/net v0.0.0-20200602114024-627f9648deb9
29+
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
30+
golang.org/x/net v0.0.0-20200707034311-ab3426394381
3031
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
3132
k8s.io/api v0.18.0
3233
k8s.io/apimachinery v0.18.0

go.sum

+132-61
Large diffs are not rendered by default.

k8s/console/base/minio-operator.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ spec:
195195
serviceAccountName: minio-operator
196196
containers:
197197
- name: minio-operator
198-
image: minio/k8s-operator:2.0.8
198+
image: minio/k8s-operator:2.0.9
199199
imagePullPolicy: IfNotPresent
200200
# To specify cluster domain, un comment the following:
201201
# env:

k8s/getoperator.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22
# Get's the latest deployment file from MinIO Operator
3-
curl https://raw.githubusercontent.com/minio/minio-operator/master/minio-operator.yaml > base/minio-operator.yaml
3+
curl https://raw.githubusercontent.com/minio/minio-operator/master/minio-operator.yaml > operator-console/base/minio-operator.yaml

k8s/operator-console/base/minio-operator.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ spec:
195195
serviceAccountName: minio-operator
196196
containers:
197197
- name: minio-operator
198-
image: minio/k8s-operator:2.0.8
198+
image: minio/k8s-operator:2.0.9
199199
imagePullPolicy: IfNotPresent
200200
# To specify cluster domain, un comment the following:
201201
# env:

restapi/admin_tenants.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ func getDeleteTenantResponse(session *models.Principal, params admin_api.DeleteT
134134
return deleteTenantAction(context.Background(), opClient, params.Namespace, params.Tenant)
135135
}
136136

137-
func identifyMinioInstanceScheme(mi *operator.MinIOInstance) string {
137+
func getMinioInstanceScheme(mi *operator.MinIOInstance) string {
138138
scheme := "http"
139-
if mi.RequiresAutoCertSetup() || mi.RequiresExternalCertSetup() {
139+
if mi.AutoCert() || mi.ExternalCert() {
140140
scheme = "https"
141141
}
142142
return scheme
@@ -239,7 +239,7 @@ func getTenantInfoResponse(session *models.Principal, params admin_api.TenantInf
239239
log.Println("error getting minioInstance:", err)
240240
return nil, err
241241
}
242-
minioInstanceScheme := identifyMinioInstanceScheme(minInst)
242+
minioInstanceScheme := getMinioInstanceScheme(minInst)
243243
mAdmin, err := getTenantAdminClient(ctx, k8sClient, params.Namespace, params.Tenant, minInst.Spec.ServiceName, minioInstanceScheme)
244244
if err != nil {
245245
log.Println("error getting tenant's admin client:", err)

restapi/client-admin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
mcCmd "github.com/minio/mc/cmd"
2626
"github.com/minio/mc/pkg/probe"
2727
"github.com/minio/mcs/models"
28-
"github.com/minio/minio-go/v6/pkg/credentials"
28+
"github.com/minio/minio-go/v7/pkg/credentials"
2929
mauth "github.com/minio/minio/pkg/auth"
3030
iampolicy "github.com/minio/minio/pkg/iam/policy"
3131
"github.com/minio/minio/pkg/madmin"

restapi/client.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ func (c minioClient) getBucketPolicy(bucketName string) (string, error) {
9494
// by mock when testing, it should include all mc/S3Client respective api calls
9595
// that are used within this project.
9696
type MCS3Client interface {
97-
addNotificationConfig(arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error
98-
removeNotificationConfig(arn string, event string, prefix string, suffix string) *probe.Error
99-
watch(options mc.WatchOptions) (*mc.WatchObject, *probe.Error)
97+
addNotificationConfig(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error
98+
removeNotificationConfig(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error
99+
watch(ctx context.Context, options mc.WatchOptions) (*mc.WatchObject, *probe.Error)
100100
}
101101

102102
// Interface implementation
@@ -108,17 +108,17 @@ type mcS3Client struct {
108108
}
109109

110110
// implements S3Client.AddNotificationConfig()
111-
func (c mcS3Client) addNotificationConfig(arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
112-
return c.client.AddNotificationConfig(arn, events, prefix, suffix, ignoreExisting)
111+
func (c mcS3Client) addNotificationConfig(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
112+
return c.client.AddNotificationConfig(ctx, arn, events, prefix, suffix, ignoreExisting)
113113
}
114114

115115
// implements S3Client.RemoveNotificationConfig()
116-
func (c mcS3Client) removeNotificationConfig(arn string, event string, prefix string, suffix string) *probe.Error {
117-
return c.client.RemoveNotificationConfig(arn, event, prefix, suffix)
116+
func (c mcS3Client) removeNotificationConfig(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error {
117+
return c.client.RemoveNotificationConfig(ctx, arn, event, prefix, suffix)
118118
}
119119

120-
func (c mcS3Client) watch(options mc.WatchOptions) (*mc.WatchObject, *probe.Error) {
121-
return c.client.Watch(options)
120+
func (c mcS3Client) watch(ctx context.Context, options mc.WatchOptions) (*mc.WatchObject, *probe.Error) {
121+
return c.client.Watch(ctx, options)
122122
}
123123

124124
// MCSCredentials interface with all functions to be implemented

restapi/user_buckets_events.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package restapi
1818

1919
import (
20+
"context"
2021
"log"
2122
"strings"
2223

@@ -152,7 +153,7 @@ func getListBucketEventsResponse(session *models.Principal, params user_api.List
152153
// If notificationEvents is empty, by default will set [get, put, delete], else the provided
153154
// ones will be set.
154155
// this function follows same behavior as minio/mc for adding a bucket event
155-
func createBucketEvent(client MCS3Client, arn string, notificationEvents []models.NotificationEventType, prefix, suffix string, ignoreExisting bool) error {
156+
func createBucketEvent(ctx context.Context, client MCS3Client, arn string, notificationEvents []models.NotificationEventType, prefix, suffix string, ignoreExisting bool) error {
156157
var events []string
157158
if len(notificationEvents) == 0 {
158159
// default event values are [get, put, delete]
@@ -169,7 +170,7 @@ func createBucketEvent(client MCS3Client, arn string, notificationEvents []model
169170
}
170171
}
171172

172-
perr := client.addNotificationConfig(arn, events, prefix, suffix, ignoreExisting)
173+
perr := client.addNotificationConfig(ctx, arn, events, prefix, suffix, ignoreExisting)
173174
if perr != nil {
174175
return perr.Cause
175176
}
@@ -178,6 +179,7 @@ func createBucketEvent(client MCS3Client, arn string, notificationEvents []model
178179

179180
// getCreateBucketEventsResponse calls createBucketEvent to add a bucket event notification
180181
func getCreateBucketEventsResponse(session *models.Principal, bucketName string, eventReq *models.BucketEventRequest) error {
182+
ctx := context.Background()
181183
s3Client, err := newS3BucketClient(session, bucketName)
182184
if err != nil {
183185
log.Println("error creating S3Client:", err)
@@ -186,7 +188,7 @@ func getCreateBucketEventsResponse(session *models.Principal, bucketName string,
186188
// create a mc S3Client interface implementation
187189
// defining the client to be used
188190
mcS3Client := mcS3Client{client: s3Client}
189-
err = createBucketEvent(mcS3Client, *eventReq.Configuration.Arn, eventReq.Configuration.Events, eventReq.Configuration.Prefix, eventReq.Configuration.Suffix, eventReq.IgnoreExisting)
191+
err = createBucketEvent(ctx, mcS3Client, *eventReq.Configuration.Arn, eventReq.Configuration.Events, eventReq.Configuration.Prefix, eventReq.Configuration.Suffix, eventReq.IgnoreExisting)
190192
if err != nil {
191193
log.Println("error creating bucket event:", err)
192194
return err
@@ -195,9 +197,9 @@ func getCreateBucketEventsResponse(session *models.Principal, bucketName string,
195197
}
196198

197199
// deleteBucketEventNotification calls S3Client.RemoveNotificationConfig to remove a bucket event notification
198-
func deleteBucketEventNotification(client MCS3Client, arn string, events []models.NotificationEventType, prefix, suffix *string) error {
200+
func deleteBucketEventNotification(ctx context.Context, client MCS3Client, arn string, events []models.NotificationEventType, prefix, suffix *string) error {
199201
eventSingleString := joinNotificationEvents(events)
200-
perr := client.removeNotificationConfig(arn, eventSingleString, *prefix, *suffix)
202+
perr := client.removeNotificationConfig(ctx, arn, eventSingleString, *prefix, *suffix)
201203
if perr != nil {
202204
return perr.Cause
203205
}
@@ -214,6 +216,7 @@ func joinNotificationEvents(events []models.NotificationEventType) string {
214216

215217
// getDeleteBucketEventsResponse calls deleteBucketEventNotification() to delete a bucket event notification
216218
func getDeleteBucketEventsResponse(session *models.Principal, bucketName string, arn string, events []models.NotificationEventType, prefix, suffix *string) error {
219+
ctx := context.Background()
217220
s3Client, err := newS3BucketClient(session, bucketName)
218221
if err != nil {
219222
log.Println("error creating S3Client:", err)
@@ -222,7 +225,7 @@ func getDeleteBucketEventsResponse(session *models.Principal, bucketName string,
222225
// create a mc S3Client interface implementation
223226
// defining the client to be used
224227
mcS3Client := mcS3Client{client: s3Client}
225-
err = deleteBucketEventNotification(mcS3Client, arn, events, prefix, suffix)
228+
err = deleteBucketEventNotification(ctx, mcS3Client, arn, events, prefix, suffix)
226229
if err != nil {
227230
log.Println("error deleting bucket event:", err)
228231
return err

restapi/user_buckets_events_test.go

+19-16
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package restapi
1818

1919
import (
20+
"context"
2021
"fmt"
2122
"testing"
2223

@@ -38,26 +39,27 @@ func (mc minioClientMock) getBucketNotification(bucketName string) (bucketNotifi
3839
}
3940

4041
//// Mock mc S3Client functions ////
41-
var mcAddNotificationConfigMock func(arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error
42-
var mcRemoveNotificationConfigMock func(arn string, event string, prefix string, suffix string) *probe.Error
42+
var mcAddNotificationConfigMock func(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error
43+
var mcRemoveNotificationConfigMock func(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error
4344

4445
// Define a mock struct of mc S3Client interface implementation
4546
type s3ClientMock struct {
4647
}
4748

4849
// implements mc.S3Client.AddNotificationConfigMock()
49-
func (c s3ClientMock) addNotificationConfig(arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
50-
return mcAddNotificationConfigMock(arn, events, prefix, suffix, ignoreExisting)
50+
func (c s3ClientMock) addNotificationConfig(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
51+
return mcAddNotificationConfigMock(ctx, arn, events, prefix, suffix, ignoreExisting)
5152
}
5253

5354
// implements mc.S3Client.DeleteBucketEventNotification()
54-
func (c s3ClientMock) removeNotificationConfig(arn string, event string, prefix string, suffix string) *probe.Error {
55-
return mcRemoveNotificationConfigMock(arn, event, prefix, suffix)
55+
func (c s3ClientMock) removeNotificationConfig(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error {
56+
return mcRemoveNotificationConfigMock(ctx, arn, event, prefix, suffix)
5657
}
5758

5859
func TestAddBucketNotification(t *testing.T) {
5960
assert := assert.New(t)
6061
// mock minIO client
62+
ctx := context.Background()
6163
client := s3ClientMock{}
6264
function := "createBucketEvent()"
6365
// Test-1: createBucketEvent() set an event with empty parameters and events, should set default values with no error
@@ -66,10 +68,10 @@ func TestAddBucketNotification(t *testing.T) {
6668
testPrefix := ""
6769
testSuffix := ""
6870
testIgnoreExisting := false
69-
mcAddNotificationConfigMock = func(arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
71+
mcAddNotificationConfigMock = func(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
7072
return nil
7173
}
72-
if err := createBucketEvent(client, testArn, testNotificationEvents, testPrefix, testSuffix, testIgnoreExisting); err != nil {
74+
if err := createBucketEvent(ctx, client, testArn, testNotificationEvents, testPrefix, testSuffix, testIgnoreExisting); err != nil {
7375
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
7476
}
7577

@@ -82,23 +84,24 @@ func TestAddBucketNotification(t *testing.T) {
8284
testPrefix = "photos/"
8385
testSuffix = ".jpg"
8486
testIgnoreExisting = true
85-
mcAddNotificationConfigMock = func(arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
87+
mcAddNotificationConfigMock = func(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
8688
return nil
8789
}
88-
if err := createBucketEvent(client, testArn, testNotificationEvents, testPrefix, testSuffix, testIgnoreExisting); err != nil {
90+
if err := createBucketEvent(ctx, client, testArn, testNotificationEvents, testPrefix, testSuffix, testIgnoreExisting); err != nil {
8991
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
9092
}
9193

9294
// Test-3 createBucketEvent() S3Client.AddNotificationConfig returns an error and is handled correctly
93-
mcAddNotificationConfigMock = func(arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
95+
mcAddNotificationConfigMock = func(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
9496
return probe.NewError(errors.New("error"))
9597
}
96-
if err := createBucketEvent(client, testArn, testNotificationEvents, testPrefix, testSuffix, testIgnoreExisting); assert.Error(err) {
98+
if err := createBucketEvent(ctx, client, testArn, testNotificationEvents, testPrefix, testSuffix, testIgnoreExisting); assert.Error(err) {
9799
assert.Equal("error", err.Error())
98100
}
99101
}
100102

101103
func TestDeleteBucketNotification(t *testing.T) {
104+
ctx := context.Background()
102105
assert := assert.New(t)
103106
// mock minIO client
104107
client := s3ClientMock{}
@@ -112,18 +115,18 @@ func TestDeleteBucketNotification(t *testing.T) {
112115
models.NotificationEventTypePut}
113116
prefix := "/photos"
114117
suffix := ".jpg"
115-
mcRemoveNotificationConfigMock = func(arn string, event string, prefix string, suffix string) *probe.Error {
118+
mcRemoveNotificationConfigMock = func(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error {
116119
return nil
117120
}
118-
if err := deleteBucketEventNotification(client, testArn, events, swag.String(prefix), swag.String(suffix)); err != nil {
121+
if err := deleteBucketEventNotification(ctx, client, testArn, events, swag.String(prefix), swag.String(suffix)); err != nil {
119122
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
120123
}
121124

122125
// Test-2 deleteBucketEventNotification() S3Client.DeleteBucketEventNotification returns an error and is handled correctly
123-
mcRemoveNotificationConfigMock = func(arn string, event string, prefix string, suffix string) *probe.Error {
126+
mcRemoveNotificationConfigMock = func(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error {
124127
return probe.NewError(errors.New("error"))
125128
}
126-
if err := deleteBucketEventNotification(client, testArn, events, swag.String(prefix), swag.String(suffix)); assert.Error(err) {
129+
if err := deleteBucketEventNotification(ctx, client, testArn, events, swag.String(prefix), swag.String(suffix)); assert.Error(err) {
127130
assert.Equal("error", err.Error())
128131
}
129132

restapi/user_watch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type watchOptions struct {
3535
}
3636

3737
func startWatch(ctx context.Context, conn WSConn, wsc MCS3Client, options watchOptions) error {
38-
wo, pErr := wsc.watch(options.WatchOptions)
38+
wo, pErr := wsc.watch(ctx, options.WatchOptions)
3939
if pErr != nil {
4040
fmt.Println("error initializing watch:", pErr.Cause)
4141
return pErr.Cause

0 commit comments

Comments
 (0)