-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.application.go
58 lines (45 loc) · 1.17 KB
/
sample.application.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
package main
import (
"log"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/markdicksonjr/nibbler"
"github.com/markdicksonjr/nibbler/storage/s3"
)
func main() {
// allocate logger and configuration
var logger nibbler.Logger = nibbler.DefaultLogger{}
// allocate configuration (from env vars, files, etc)
config, err := nibbler.LoadConfiguration(nil)
if err != nil {
log.Fatal(err)
}
// allocate the S3 extension
s3Extension := s3.Extension{}
// prepare extensions for initialization
extensions := []nibbler.Extension{
&s3Extension,
}
// create and initialize the application
app := nibbler.Application{}
err = app.Init(config, &logger, &extensions)
if err != nil {
log.Fatal(err.Error())
}
// list the buckets for the S3 connection we've made
result, err := s3Extension.S3.ListBuckets(nil)
if err != nil {
log.Fatal("Unable to list buckets, " + err.Error())
}
// print buckets to the console, with creation time
fmt.Println("Buckets:")
for _, b := range result.Buckets {
fmt.Printf("* %s created on %s\n",
aws.StringValue(b.Name), aws.TimeValue(b.CreationDate))
}
// start the app
err = app.Run()
if err != nil {
log.Fatal(err.Error())
}
}