Skip to content

Commit fcf5d5c

Browse files
authored
Add delete objects api (#303)
Supports single and multiple objects which needs to be defined by recursive flag. An object to be deleted needs to be defined by a query parameter, path, since it can be an object or a folder.
1 parent a42f1ff commit fcf5d5c

17 files changed

+1129
-48
lines changed

.github/workflows/go.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ name: Go
33
on:
44
pull_request:
55
branches:
6-
- master
6+
- master
77
push:
88
branches:
9-
- master
9+
- master
1010

1111
jobs:
1212
build:
1313
name: Test on Go ${{ matrix.go-version }} and ${{ matrix.os }}
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
go-version: [1.13.x, 1.14.x]
17+
go-version: [1.14.x]
1818
os: [ubuntu-latest]
1919
steps:
2020
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}

cmd/console/main.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,19 @@ func newApp(name string) *cli.App {
7676

7777
findClosestCommands := func(command string) []string {
7878
var closestCommands []string
79-
for _, value := range commandsTree.PrefixMatch(command) {
80-
closestCommands = append(closestCommands, value.(string))
81-
}
79+
closestCommands = append(closestCommands, commandsTree.PrefixMatch(command)...)
8280

8381
sort.Strings(closestCommands)
8482
// Suggest other close commands - allow missed, wrongly added and
8583
// even transposed characters
8684
for _, value := range commandsTree.Walk(commandsTree.Root()) {
87-
if sort.SearchStrings(closestCommands, value.(string)) < len(closestCommands) {
85+
if sort.SearchStrings(closestCommands, value) < len(closestCommands) {
8886
continue
8987
}
9088
// 2 is arbitrary and represents the max
9189
// allowed number of typed errors
92-
if words.DamerauLevenshteinDistance(command, value.(string)) < 2 {
93-
closestCommands = append(closestCommands, value.(string))
90+
if words.DamerauLevenshteinDistance(command, value) < 2 {
91+
closestCommands = append(closestCommands, value)
9492
}
9593
}
9694

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ require (
1616
github.com/jessevdk/go-flags v1.4.0
1717
github.com/minio/cli v1.22.0
1818
github.com/minio/kes v0.11.0
19-
github.com/minio/mc v0.0.0-20200901021141-b55e3e2d2987
20-
github.com/minio/minio v0.0.0-20200901011052-18725679c4f5
21-
github.com/minio/minio-go/v7 v7.0.6-0.20200901014009-5f8d15bbc5fd
19+
github.com/minio/mc v0.0.0-20201001165056-7f2df96e4821
20+
github.com/minio/minio v0.0.0-20200927172404-27d9bd04e544
21+
github.com/minio/minio-go/v7 v7.0.6-0.20200923173112-bc846cb9b089
2222
github.com/minio/operator v0.0.0-20200923155125-e7077234373b
2323
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect
2424
github.com/secure-io/sio-go v0.3.1
2525
github.com/stretchr/testify v1.6.1
2626
github.com/unrolled/secure v1.0.7
27-
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
28-
golang.org/x/net v0.0.0-20200707034311-ab3426394381
27+
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
28+
golang.org/x/net v0.0.0-20200904194848-62affa334b73
2929
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
3030
gopkg.in/yaml.v2 v2.3.0
3131
k8s.io/api v0.18.6

go.sum

Lines changed: 33 additions & 11 deletions
Large diffs are not rendered by default.

restapi/client.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ type MCClient interface {
123123
addNotificationConfig(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error
124124
removeNotificationConfig(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error
125125
watch(ctx context.Context, options mc.WatchOptions) (*mc.WatchObject, *probe.Error)
126+
remove(ctx context.Context, isIncomplete, isRemoveBucket, isBypass bool, contentCh <-chan *mc.ClientContent) <-chan *probe.Error
127+
list(ctx context.Context, opts mc.ListOptions) <-chan *mc.ClientContent
126128
}
127129

128130
// Interface implementation
@@ -151,6 +153,14 @@ func (c mcClient) setReplication(ctx context.Context, cfg *replication.Config, o
151153
return c.client.SetReplication(ctx, cfg, opts)
152154
}
153155

156+
func (c mcClient) remove(ctx context.Context, isIncomplete, isRemoveBucket, isBypass bool, contentCh <-chan *mc.ClientContent) <-chan *probe.Error {
157+
return c.client.Remove(ctx, isIncomplete, isRemoveBucket, isBypass, contentCh)
158+
}
159+
160+
func (c mcClient) list(ctx context.Context, opts mc.ListOptions) <-chan *mc.ClientContent {
161+
return c.client.List(ctx, opts)
162+
}
163+
154164
// ConsoleCredentials interface with all functions to be implemented
155165
// by mock when testing, it should include all needed consoleCredentials.Login api calls
156166
// that are used within this project.
@@ -274,14 +284,18 @@ func newMinioClient(claims *models.Principal) (*minio.Client, error) {
274284
}
275285

276286
// newS3BucketClient creates a new mc S3Client to talk to the server based on a bucket
277-
func newS3BucketClient(claims *models.Principal, bucketName string) (*mc.S3Client, error) {
287+
func newS3BucketClient(claims *models.Principal, bucketName string, prefix string) (*mc.S3Client, error) {
278288
endpoint := getMinIOServer()
279289
useTLS := getMinIOEndpointIsSecure()
280290

281291
if strings.TrimSpace(bucketName) != "" {
282292
endpoint += fmt.Sprintf("/%s", bucketName)
283293
}
284294

295+
if strings.TrimSpace(prefix) != "" {
296+
endpoint += fmt.Sprintf("/%s", prefix)
297+
}
298+
285299
if claims == nil {
286300
return nil, fmt.Errorf("the provided credentials are invalid")
287301
}

restapi/embedded_spec.go

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

restapi/operations/console_api.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

restapi/operations/user_api/delete_object.go

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)