-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathprovider.go
78 lines (73 loc) · 2.03 KB
/
provider.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
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"log"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform/helper/schema"
)
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"s3_server": {
Type: schema.TypeString,
Required: true,
Description: "S3 Server",
},
"s3_region": {
Type: schema.TypeString,
Optional: true,
Default: "us-east-1",
Description: "S3 Server region (default: us-east-1)",
},
"s3_access_key": {
Type: schema.TypeString,
Required: true,
Description: "S3 Server Access Key",
},
"s3_secret_key": {
Type: schema.TypeString,
Required: true,
Description: "S3 Server Secret Key",
},
"s3_api_signature": {
Type: schema.TypeString,
Optional: true,
Default: "v4",
Description: "S3 Server API Signature (type: string, options: v2 or v4, default: v4)",
},
"s3_ssl": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Use SSL to connect to the S3 Server? (default: false)",
},
"s3_debug": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Print debugging informatioin (default: false)",
},
},
ResourcesMap: map[string]*schema.Resource{
"s3_bucket": resourceS3Bucket(),
"s3_object": resourceS3Object(),
"s3_file": resourceS3File(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
debug := d.Get("s3_debug").(bool)
if debug {
log.Printf("[DEBUG] Initializing the S3 Provider")
}
config := Config{
s3_server: d.Get("s3_server").(string),
s3_region: d.Get("s3_region").(string),
s3_access_key: d.Get("s3_access_key").(string),
s3_secret_key: d.Get("s3_secret_key").(string),
api_signature: d.Get("s3_api_signature").(string),
ssl: d.Get("s3_ssl").(bool),
debug: d.Get("s3_debug").(bool),
}
return config.NewClient()
}