aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorstack72 <public@paulstack.co.uk>2015-09-28 11:39:32 +0100
committerstack72 <public@paulstack.co.uk>2015-11-27 15:03:13 +0000
commit478e133852c1c49f98c0388920142dc507479487 (patch)
tree535ff9156c6b84c45cb1c603889e4c64f94f3e30
downloadterraform-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.go39
-rw-r--r--provider_test.go38
-rw-r--r--resource_statuscaketest.go28
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 @@
1package statuscake
2
3import (
4 "github.com/DreamItGetIT/statuscake"
5 "github.com/hashicorp/terraform/helper/schema"
6 "github.com/hashicorp/terraform/terraform"
7)
8
9func 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
34func 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 @@
1package statuscake
2
3import (
4 "os"
5 "testing"
6
7 "github.com/hashicorp/terraform/helper/schema"
8 "github.com/hashicorp/terraform/terraform"
9)
10
11var testAccProviders map[string]terraform.ResourceProvider
12var testAccProvider *schema.Provider
13
14func init() {
15 testAccProvider = Provider().(*schema.Provider)
16 testAccProviders = map[string]terraform.ResourceProvider{
17 "statuscake": testAccProvider,
18 }
19}
20
21func TestProvider(t *testing.T) {
22 if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
23 t.Fatalf("err: %s", err)
24 }
25}
26
27func TestProvider_impl(t *testing.T) {
28 var _ terraform.ResourceProvider = Provider()
29}
30
31func 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 @@
1package statuscake
2
3import "github.com/hashicorp/terraform/helper/schema"
4
5func resourceStatusCakeTest() *schema.Resource {
6 return &schema.Resource{
7 Create: CreateTest,
8 Update: UpdateTest,
9 Delete: DeleteTest,
10 Read: ReadTest,
11 }
12}
13
14func CreateTest(d *schema.ResourceData, meta interface{}) error {
15 return nil
16}
17
18func UpdateTest(d *schema.ResourceData, meta interface{}) error {
19 return nil
20}
21
22func DeleteTest(d *schema.ResourceData, meta interface{}) error {
23 return nil
24}
25
26func ReadTest(d *schema.ResourceData, meta interface{}) error {
27 return nil
28}