-
Notifications
You must be signed in to change notification settings - Fork 0
/
ensure.go
50 lines (42 loc) · 1.21 KB
/
ensure.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
50
package cliaws
import (
"context"
"github.com/alexflint/go-arg"
"github.com/nathants/cli-aws/lib"
)
func init() {
lib.Commands["s3-ensure"] = s3Ensure
lib.Args["s3-ensure"] = s3EnsureArgs{}
}
type s3EnsureArgs struct {
Name string `arg:"positional,required"`
Attrs []string `arg:"positional"`
Preview bool `arg:"-p,--preview"`
}
func (s3EnsureArgs) Description() string {
return `
ensure a s3 bucket
example:
- cli-aws s3-ensure test-bucket acl=PUBLIC versioning=TRUE
optional attrs:
- acl=VALUE (values = "public" | "private", default = "private")
- versioning=VALUE (values = "true" | "false", default = "false")
- encryption=VALUE (values = "true" | "false", default = "true")
- metrics=VALUE (values = "true" | "false", default = "true")
- cors=VALUE (values = "true" | "false", default = "true")
- ttldays=VALUE (values = "0" | "n", default = "0")
`
}
func s3Ensure() {
var args s3EnsureArgs
arg.MustParse(&args)
ctx := context.Background()
input, err := lib.S3EnsureInput(args.Name, args.Attrs)
if err != nil {
lib.Logger.Fatal("error: ", err)
}
err = lib.S3Ensure(ctx, input, args.Preview)
if err != nil {
lib.Logger.Fatal("error: ", err)
}
}