diff options
author | stack72 <public@paulstack.co.uk> | 2015-09-28 11:39:32 +0100 |
---|---|---|
committer | stack72 <public@paulstack.co.uk> | 2015-11-27 15:03:13 +0000 |
commit | 478e133852c1c49f98c0388920142dc507479487 (patch) | |
tree | 535ff9156c6b84c45cb1c603889e4c64f94f3e30 | |
download | terraform-provider-statuscake-478e133852c1c49f98c0388920142dc507479487.tar.gz terraform-provider-statuscake-478e133852c1c49f98c0388920142dc507479487.tar.zst terraform-provider-statuscake-478e133852c1c49f98c0388920142dc507479487.zip |
Created the initial scaffolding for the statuscake provider
-rw-r--r-- | provider.go | 39 | ||||
-rw-r--r-- | provider_test.go | 38 | ||||
-rw-r--r-- | resource_statuscaketest.go | 28 |
3 files changed, 105 insertions, 0 deletions
diff --git a/provider.go b/provider.go new file mode 100644 index 0000000..7402e80 --- /dev/null +++ b/provider.go | |||
@@ -0,0 +1,39 @@ | |||
1 | package statuscake | ||
2 | |||
3 | import ( | ||
4 | "github.com/DreamItGetIT/statuscake" | ||
5 | "github.com/hashicorp/terraform/helper/schema" | ||
6 | "github.com/hashicorp/terraform/terraform" | ||
7 | ) | ||
8 | |||
9 | func Provider() terraform.ResourceProvider { | ||
10 | return &schema.Provider{ | ||
11 | Schema: map[string]*schema.Schema{ | ||
12 | "username": &schema.Schema{ | ||
13 | Type: schema.TypeString, | ||
14 | Required: true, | ||
15 | DefaultFunc: schema.EnvDefaultFunc("STATUSCAKE_USERNAME", nil), | ||
16 | Description: "Username for StatusCake Account.", | ||
17 | }, | ||
18 | "apikey": &schema.Schema{ | ||
19 | Type: schema.TypeString, | ||
20 | Required: true, | ||
21 | DefaultFunc: schema.EnvDefaultFunc("STATUSCAKE_APIKEY", nil), | ||
22 | Description: "API Key for StatusCake", | ||
23 | }, | ||
24 | }, | ||
25 | |||
26 | ResourcesMap: map[string]*schema.Resource{ | ||
27 | "statuscake_test": resourceStatusCakeTest(), | ||
28 | }, | ||
29 | |||
30 | ConfigureFunc: providerConfigure, | ||
31 | } | ||
32 | } | ||
33 | |||
34 | func providerConfigure(d *schema.ResourceData) (interface{}, error) { | ||
35 | username := d.Get("username").(string) | ||
36 | apiKey := d.Get("apikey").(string) | ||
37 | |||
38 | return statuscake.New(apiKey, username), nil | ||
39 | } | ||
diff --git a/provider_test.go b/provider_test.go new file mode 100644 index 0000000..83045d0 --- /dev/null +++ b/provider_test.go | |||
@@ -0,0 +1,38 @@ | |||
1 | package statuscake | ||
2 | |||
3 | import ( | ||
4 | "os" | ||
5 | "testing" | ||
6 | |||
7 | "github.com/hashicorp/terraform/helper/schema" | ||
8 | "github.com/hashicorp/terraform/terraform" | ||
9 | ) | ||
10 | |||
11 | var testAccProviders map[string]terraform.ResourceProvider | ||
12 | var testAccProvider *schema.Provider | ||
13 | |||
14 | func init() { | ||
15 | testAccProvider = Provider().(*schema.Provider) | ||
16 | testAccProviders = map[string]terraform.ResourceProvider{ | ||
17 | "statuscake": testAccProvider, | ||
18 | } | ||
19 | } | ||
20 | |||
21 | func TestProvider(t *testing.T) { | ||
22 | if err := Provider().(*schema.Provider).InternalValidate(); err != nil { | ||
23 | t.Fatalf("err: %s", err) | ||
24 | } | ||
25 | } | ||
26 | |||
27 | func TestProvider_impl(t *testing.T) { | ||
28 | var _ terraform.ResourceProvider = Provider() | ||
29 | } | ||
30 | |||
31 | func testAccPreCheck(t *testing.T) { | ||
32 | if v := os.Getenv("STATUSCAKE_USERNAME"); v == "" { | ||
33 | t.Fatal("STATUSCAKE_USERNAME must be set for acceptance tests") | ||
34 | } | ||
35 | if v := os.Getenv("STATUSCAKE_APIKEY"); v == "" { | ||
36 | t.Fatal("STATUSCAKE_APIKEY must be set for acceptance tests") | ||
37 | } | ||
38 | } | ||
diff --git a/resource_statuscaketest.go b/resource_statuscaketest.go new file mode 100644 index 0000000..f34a97a --- /dev/null +++ b/resource_statuscaketest.go | |||
@@ -0,0 +1,28 @@ | |||
1 | package statuscake | ||
2 | |||
3 | import "github.com/hashicorp/terraform/helper/schema" | ||
4 | |||
5 | func resourceStatusCakeTest() *schema.Resource { | ||
6 | return &schema.Resource{ | ||
7 | Create: CreateTest, | ||
8 | Update: UpdateTest, | ||
9 | Delete: DeleteTest, | ||
10 | Read: ReadTest, | ||
11 | } | ||
12 | } | ||
13 | |||
14 | func CreateTest(d *schema.ResourceData, meta interface{}) error { | ||
15 | return nil | ||
16 | } | ||
17 | |||
18 | func UpdateTest(d *schema.ResourceData, meta interface{}) error { | ||
19 | return nil | ||
20 | } | ||
21 | |||
22 | func DeleteTest(d *schema.ResourceData, meta interface{}) error { | ||
23 | return nil | ||
24 | } | ||
25 | |||
26 | func ReadTest(d *schema.ResourceData, meta interface{}) error { | ||
27 | return nil | ||
28 | } | ||