-
Notifications
You must be signed in to change notification settings - Fork 20
/
sos_create.go
43 lines (35 loc) · 927 Bytes
/
sos_create.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cmd
import (
minio "github.com/minio/minio-go"
"github.com/spf13/cobra"
)
// createCmd represents the create command
var sosCreateCmd = &cobra.Command{
Use: "create <name>",
Short: "create bucket",
Aliases: gCreateAlias,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return cmd.Usage()
}
zone, err := cmd.Flags().GetString("zone")
if err != nil {
return err
}
if zone != "" {
gCurrentAccount.DefaultZone = zone
}
minioClient, err := newMinioClient(gCurrentAccount.DefaultZone)
if err != nil {
return err
}
return createBucket(minioClient, args[0], gCurrentAccount.DefaultZone)
},
}
func createBucket(minioClient *minio.Client, bucketName, zone string) error {
return minioClient.MakeBucket(bucketName, zone)
}
func init() {
sosCmd.AddCommand(sosCreateCmd)
sosCreateCmd.Flags().StringP("zone", "z", "", "Simple object storage zone")
}