-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudfront.go
67 lines (52 loc) · 1.32 KB
/
cloudfront.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"flag"
"fmt"
"os"
"strings"
"github.com/mitchellh/cli"
"github.com/pr8kerl/organizer/aws"
)
// List Account
type ListCloudfrontsCommand struct {
All bool
Ui cli.Ui
}
func listCloudfrontsCmdFactory() (cli.Command, error) {
ui := &cli.BasicUi{
Reader: os.Stdin,
Writer: os.Stdout,
ErrorWriter: os.Stderr,
}
return &ListCloudfrontsCommand{
Ui: ui,
}, nil
}
func (c *ListCloudfrontsCommand) Run(args []string) int {
cmdFlags := flag.NewFlagSet("list cloudfront", flag.ContinueOnError)
cmdFlags.BoolVar(&c.All, "all", false, "show all cloudfront distributions")
cmdFlags.Usage = func() { c.Ui.Output(c.Help()); os.Exit(1) }
if err := cmdFlags.Parse(args); err != nil {
return 1
}
org, err := aws.NewOrganization()
if err != nil {
fmt.Printf("error: could not initialize organization: %s\n", err)
return 1
}
err = org.PrintCloudfronts()
if err != nil {
fmt.Printf("error: could not list cloudfront distributions: %s\n", err)
return 1
}
return 0
}
func (c *ListCloudfrontsCommand) Help() string {
helpText := `usage: organizer list cloudfront [<args>]
List cloudfront distributions per account
`
return strings.TrimSpace(helpText)
}
func (c *ListCloudfrontsCommand) Synopsis() string {
return "list all cloudfront distributions for a organizational accounts"
}