-
Notifications
You must be signed in to change notification settings - Fork 20
/
sos_create.go
49 lines (40 loc) · 937 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
44
45
46
47
48
49
package cmd
import (
"github.com/spf13/cobra"
)
var sosCreateCmd = &cobra.Command{
Use: "create NAME",
Short: "Create a bucket",
Aliases: gCreateAlias,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return cmd.Usage()
}
bucket := args[0]
zone, err := cmd.Flags().GetString("zone")
if err != nil {
return err
}
certsFile, err := cmd.Parent().Flags().GetString("certs-file")
if err != nil {
return err
}
sosClient, err := newSOSClient(certsFile)
if err != nil {
return err
}
if zone != "" {
if err := sosClient.setZone(zone); err != nil {
return err
}
}
return createBucket(sosClient, bucket, zone)
},
}
func createBucket(sosClient *sosClient, name, zone string) error {
return sosClient.MakeBucket(name, zone)
}
func init() {
sosCmd.AddCommand(sosCreateCmd)
sosCreateCmd.Flags().StringP("zone", "z", "", "Simple object storage zone")
}