]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/commitdiff
Merge pull request #36 from nauxliu/importer
authorMat Schaffer <mat@schaffer.me>
Sat, 22 Jun 2019 02:53:00 +0000 (11:53 +0900)
committerGitHub <noreply@github.com>
Sat, 22 Jun 2019 02:53:00 +0000 (11:53 +0900)
Add importer

15 files changed:
go.mod
go.sum
statuscake/resource_statuscaketest.go
statuscake/resource_statuscaketest_test.go
vendor/github.com/DreamItGetIT/statuscake/.gitignore [new file with mode: 0644]
vendor/github.com/DreamItGetIT/statuscake/.travis.yml [new file with mode: 0644]
vendor/github.com/DreamItGetIT/statuscake/Gopkg.lock [new file with mode: 0644]
vendor/github.com/DreamItGetIT/statuscake/Gopkg.toml [new file with mode: 0644]
vendor/github.com/DreamItGetIT/statuscake/README.md
vendor/github.com/DreamItGetIT/statuscake/doc.go
vendor/github.com/DreamItGetIT/statuscake/makefile
vendor/github.com/DreamItGetIT/statuscake/responses.go
vendor/github.com/DreamItGetIT/statuscake/tests.go
vendor/modules.txt
website/docs/r/test.html.markdown

diff --git a/go.mod b/go.mod
index 5374fe21b934fe29489fd10d8820ef101fe7cdcc..d9992469d3071ec6bfa2409dd77e37fe253659da 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/terraform-providers/terraform-provider-statuscake
 
 require (
-       github.com/DreamItGetIT/statuscake v0.0.0-20180728152938-85edefcbdaa3
+       github.com/DreamItGetIT/statuscake v0.0.0-20190218105717-471b24d8edfb
        github.com/hashicorp/terraform v0.12.0
 )
diff --git a/go.sum b/go.sum
index 769c88e74f7293ff714608df6b5587b0e862909a..cc8f846a576f52a7718e2373a055b978471381e8 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -17,8 +17,8 @@ github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4/go.mod h1:chxPXzS
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022 h1:y8Gs8CzNfDF5AZvjr+5UyGQvQEBL7pwo+v+wX6q9JI8=
 github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4=
-github.com/DreamItGetIT/statuscake v0.0.0-20180728152938-85edefcbdaa3 h1:BmnYSwnNifByVfy5Yp3AxiEWAS4EkzK0Cu6/Rh/7mu4=
-github.com/DreamItGetIT/statuscake v0.0.0-20180728152938-85edefcbdaa3/go.mod h1:OclNh7ZacJo61GDJablmsOZ7l8/AVtzGqP8G7baOdAs=
+github.com/DreamItGetIT/statuscake v0.0.0-20190218105717-471b24d8edfb h1:vJ3lnCyZNmSV/OKyw4d7GuZHFrUaa3FY6/NqtvRE0lw=
+github.com/DreamItGetIT/statuscake v0.0.0-20190218105717-471b24d8edfb/go.mod h1:OclNh7ZacJo61GDJablmsOZ7l8/AVtzGqP8G7baOdAs=
 github.com/Unknwon/com v0.0.0-20151008135407-28b053d5a292 h1:tuQ7w+my8a8mkwN7x2TSd7OzTjkZ7rAeSyH4xncuAMI=
 github.com/Unknwon/com v0.0.0-20151008135407-28b053d5a292/go.mod h1:KYCjqMOeHpNuTOiFQU6WEcTG7poCJrUs0YgyHNtn1no=
 github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw=
index d8604e6fa88764d97e66dcac81001fc990ebff0f..5af5b8fafa35283df6c81af2af4c54158f1952c2 100644 (file)
@@ -218,6 +218,12 @@ func resourceStatusCakeTest() *schema.Resource {
                                Optional: true,
                        },
 
+                       "enable_ssl_alert": {
+                               Type:     schema.TypeBool,
+                               Optional: true,
+                               Default:  false,
+                       },
+
                        "follow_redirect": {
                                Type:     schema.TypeBool,
                                Optional: true,
@@ -260,6 +266,7 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error {
                UseJar:         d.Get("use_jar").(int),
                PostRaw:        d.Get("post_raw").(string),
                FinalEndpoint:  d.Get("final_endpoint").(string),
+               EnableSSLAlert: d.Get("enable_ssl_alert").(bool),
                FollowRedirect: d.Get("follow_redirect").(bool),
        }
 
@@ -357,6 +364,7 @@ func ReadTest(d *schema.ResourceData, meta interface{}) error {
        d.Set("use_jar", testResp.UseJar)
        d.Set("post_raw", testResp.PostRaw)
        d.Set("final_endpoint", testResp.FinalEndpoint)
+       d.Set("enable_ssl_alert", testResp.EnableSSLAlert)
        d.Set("follow_redirect", testResp.FollowRedirect)
 
        return nil
@@ -459,6 +467,9 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
        if v, ok := d.GetOk("final_endpoint"); ok {
                test.FinalEndpoint = v.(string)
        }
+       if v, ok := d.GetOk("enable_ssl_alert"); ok {
+               test.EnableSSLAlert = v.(bool)
+       }
        if v, ok := d.GetOk("follow_redirect"); ok {
                test.FollowRedirect = v.(bool)
        }
index bd609d84038a681dd7235b0d01c516189f843438..71362f7d67aae42d9527cb90354961697bfb8f95 100644 (file)
@@ -114,6 +114,7 @@ func TestAccStatusCake_withUpdate(t *testing.T) {
                                        resource.TestCheckResourceAttr("statuscake_test.google", "use_jar", "1"),
                                        resource.TestCheckResourceAttr("statuscake_test.google", "post_raw", "string32096"),
                                        resource.TestCheckResourceAttr("statuscake_test.google", "final_endpoint", "string10781"),
+                                       resource.TestCheckResourceAttr("statuscake_test.google", "enable_ssl_alert", "false"),
                                        resource.TestCheckResourceAttr("statuscake_test.google", "follow_redirect", "true"),
                                ),
                        },
@@ -213,6 +214,8 @@ func testAccTestCheckAttributes(rn string, test *statuscake.Test) resource.TestC
                                err = check(key, value, test.PostRaw)
                        case "final_endpoint":
                                err = check(key, value, test.FinalEndpoint)
+                       case "enable_ssl_alert":
+                               err = check(key, value, strconv.FormatBool(test.EnableSSLAlert))
                        case "follow_redirect":
                                err = check(key, value, strconv.FormatBool(test.FollowRedirect))
                        }
@@ -297,6 +300,7 @@ resource "statuscake_test" "google" {
        use_jar = 1
        post_raw = "string32096"
        final_endpoint = "string10781"
+       enable_ssl_alert = false
        follow_redirect = true
 }
 `
diff --git a/vendor/github.com/DreamItGetIT/statuscake/.gitignore b/vendor/github.com/DreamItGetIT/statuscake/.gitignore
new file mode 100644 (file)
index 0000000..22d0d82
--- /dev/null
@@ -0,0 +1 @@
+vendor
diff --git a/vendor/github.com/DreamItGetIT/statuscake/.travis.yml b/vendor/github.com/DreamItGetIT/statuscake/.travis.yml
new file mode 100644 (file)
index 0000000..c7bad4e
--- /dev/null
@@ -0,0 +1,14 @@
+language: go
+go:
+  - "1.x"
+
+env:
+  - DEP_VERSION="0.5.0"
+
+before_install:
+  # Install dep
+  - curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -o $GOPATH/bin/dep
+  - chmod +x $GOPATH/bin/dep
+
+  # Install golint
+  - go get golang.org/x/lint/golint
diff --git a/vendor/github.com/DreamItGetIT/statuscake/Gopkg.lock b/vendor/github.com/DreamItGetIT/statuscake/Gopkg.lock
new file mode 100644 (file)
index 0000000..c5b189e
--- /dev/null
@@ -0,0 +1,48 @@
+# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
+
+
+[[projects]]
+  branch = "master"
+  digest = "1:27dce89d419e7be582ae735623fb0b538012e62b08a87c0308c3b360de2a74b0"
+  name = "github.com/DreamItGetIT/statuscake"
+  packages = ["."]
+  pruneopts = "UT"
+  revision = "49ae6aae1769b896774d7e860e620f1bd8221355"
+
+[[projects]]
+  digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec"
+  name = "github.com/davecgh/go-spew"
+  packages = ["spew"]
+  pruneopts = "UT"
+  revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73"
+  version = "v1.1.1"
+
+[[projects]]
+  digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe"
+  name = "github.com/pmezard/go-difflib"
+  packages = ["difflib"]
+  pruneopts = "UT"
+  revision = "792786c7400a136282c1664665ae0a8db921c6c2"
+  version = "v1.0.0"
+
+[[projects]]
+  digest = "1:c40d65817cdd41fac9aa7af8bed56927bb2d6d47e4fea566a74880f5c2b1c41e"
+  name = "github.com/stretchr/testify"
+  packages = [
+    "assert",
+    "require",
+  ]
+  pruneopts = "UT"
+  revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686"
+  version = "v1.2.2"
+
+[solve-meta]
+  analyzer-name = "dep"
+  analyzer-version = 1
+  input-imports = [
+    "github.com/DreamItGetIT/statuscake",
+    "github.com/stretchr/testify/assert",
+    "github.com/stretchr/testify/require",
+  ]
+  solver-name = "gps-cdcl"
+  solver-version = 1
diff --git a/vendor/github.com/DreamItGetIT/statuscake/Gopkg.toml b/vendor/github.com/DreamItGetIT/statuscake/Gopkg.toml
new file mode 100644 (file)
index 0000000..b0c1687
--- /dev/null
@@ -0,0 +1,38 @@
+# Gopkg.toml example
+#
+# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
+# for detailed Gopkg.toml documentation.
+#
+# required = ["github.com/user/thing/cmd/thing"]
+# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
+#
+# [[constraint]]
+#   name = "github.com/user/project"
+#   version = "1.0.0"
+#
+# [[constraint]]
+#   name = "github.com/user/project2"
+#   branch = "dev"
+#   source = "github.com/myfork/project2"
+#
+# [[override]]
+#   name = "github.com/x/y"
+#   version = "2.4.0"
+#
+# [prune]
+#   non-go = false
+#   go-tests = true
+#   unused-packages = true
+
+
+[[constraint]]
+  branch = "master"
+  name = "github.com/DreamItGetIT/statuscake"
+
+[[constraint]]
+  name = "github.com/stretchr/testify"
+  version = "1.2.2"
+
+[prune]
+  go-tests = true
+  unused-packages = true
index f1e4eafc7d68e6512f90cff8f686cd63c63442ea..0806028cdae6fc19596c2ff4b5c037de52f2f845 100644 (file)
@@ -1,5 +1,7 @@
 # statuscake
 
+[![Build Status](https://travis-ci.org/DreamItGetIT/statuscake.svg?branch=master)](https://travis-ci.org/DreamItGetIT/statuscake)
+
 `statuscake` is a Go pkg that implements a client for the [statuscake]("https://statuscake.com") API.
 
 More documentation and examples at [http://godoc.org/github.com/DreamItGetIT/statuscake](http://godoc.org/github.com/DreamItGetIT/statuscake).
index fa68d94b8a36a4092df3e26b54a47828bc0a68cf..d45680eb714247c4dde40e9bcddf4ad64bb0f8e7 100644 (file)
 //    log.Fatal(err)
 //  }
 //
+//  v := url.Values{}
+//  v.Set("tags", "test1,test2")
+//  testsWithFilter, err := c.Tests().AllWithFilter(v)
+//  if err != nil {
+//    log.Fatal(err)
+//  }
+//
 //  // delete a `Test`
 //  err = c.Tests().Delete(TestID)
 //
 //    log.Fatal(err)
 //  }
 //
-//  t2 := c.Tests().Update(t)
+//  t2, err := c.Tests().Update(t)
+//  if err != nil {
+//    log.Fatal(err)
+//  }
 //  fmt.Printf("New Test created with id: %d\n", t2.TestID)
 //
 //  // get Tests details
index 946f6d993e5d7026f4c329342481e952284f5e64..6149bbfd5dde678b1d921daf704d0330358ab273 100644 (file)
@@ -1,6 +1,6 @@
-.PHONY: default lint test
+.PHONY: default deps lint test
 
-default: lint test
+default: deps lint test
 
 lint:
        @golint ./...
@@ -9,3 +9,5 @@ lint:
 test:
        go test ${GOTEST_ARGS} ./...
 
+deps:
+       dep ensure
\ No newline at end of file
index e8d4af4a476dab33a68528da936040ddccda1ad8..ec74a63853ce24924bfbee2081d98028053f46cc 100644 (file)
@@ -61,6 +61,7 @@ type detailResponse struct {
        UseJar          int                          `json:"UseJar"`
        PostRaw         string                       `json:"PostRaw"`
        FinalEndpoint   string                       `json:"FinalEndpoint"`
+       EnableSSLWarning  bool                       `json:"EnableSSLWarning"`
        FollowRedirect  bool                         `json:"FollowRedirect"`
        StatusCodes     []string                     `json:"StatusCodes"`
 }
@@ -96,6 +97,7 @@ func (d *detailResponse) test() *Test {
                UseJar:         d.UseJar,
                PostRaw:        d.PostRaw,
                FinalEndpoint:  d.FinalEndpoint,
+               EnableSSLAlert: d.EnableSSLWarning,
                FollowRedirect: d.FollowRedirect,
                StatusCodes:    strings.Join(d.StatusCodes[:], ","),
        }
index c6e6dd2d14f4e1ea309dfecda5bf696403ba177c..2a2383d550be493609a5c9f5d5da0b2177ccdaed 100644 (file)
@@ -42,7 +42,7 @@ type Test struct {
        // Current status at last test
        Status string `json:"Status"`
 
-       // 7 Day Uptime
+       // 1 Day Uptime
        Uptime float64 `json:"Uptime"`
 
        // Any test locations seperated by a comma (using the Node Location IDs)
@@ -75,7 +75,7 @@ type Test struct {
        Branding int `json:"Branding" querystring:"Branding"`
 
        // Used internally by the statuscake API
-       WebsiteHost string `json:"WebsiteHost"`
+       WebsiteHost string `json:"WebsiteHost" querystring:"WebsiteHost"`
 
        // Enable virus checking or not. 1 to enable
        Virus int `json:"Virus" querystring:"Virus"`
@@ -110,6 +110,9 @@ type Test struct {
        // Use to specify the expected Final URL in the testing process
        FinalEndpoint string `json:"FinalEndpoint" querystring:"FinalEndpoint"`
 
+       // Use to enable SSL validation
+       EnableSSLAlert bool `json:"EnableSSLAlert" querystring:"EnableSSLAlert"`
+
        // Use to specify whether redirects should be followed
        FollowRedirect bool `json:"FollowRedirect" querystring:"FollowRedirect"`
 }
@@ -166,9 +169,11 @@ func (t *Test) Validate() error {
                e["FinalEndpoint"] = "must be a Valid URL"
        }
 
-       var jsonVerifiable map[string]interface{}
-       if json.Unmarshal([]byte(t.CustomHeader), &jsonVerifiable) != nil {
-               e["CustomHeader"] = "must be provided as json string"
+       if t.CustomHeader != "" {
+               var jsonVerifiable map[string]interface{}
+               if json.Unmarshal([]byte(t.CustomHeader), &jsonVerifiable) != nil {
+                       e["CustomHeader"] = "must be provided as json string"
+               }
        }
 
        if len(e) > 0 {
@@ -244,6 +249,7 @@ func valueToQueryStringValue(v reflect.Value) string {
 // Tests is a client that implements the `Tests` API.
 type Tests interface {
        All() ([]*Test, error)
+       AllWithFilter(url.Values) ([]*Test, error)
        Detail(int) (*Test, error)
        Update(*Test) (*Test, error)
        Delete(TestID int) error
@@ -272,6 +278,19 @@ func (tt *tests) All() ([]*Test, error) {
        return tests, err
 }
 
+func (tt *tests) AllWithFilter(filterOptions url.Values) ([]*Test, error) {
+       resp, err := tt.client.get("/Tests", filterOptions)
+       if err != nil {
+               return nil, err
+       }
+       defer resp.Body.Close()
+
+       var tests []*Test
+       err = json.NewDecoder(resp.Body).Decode(&tests)
+
+       return tests, err
+}
+
 func (tt *tests) Update(t *Test) (*Test, error) {
        resp, err := tt.client.put("/Tests/Update", t.ToURLValues())
        if err != nil {
index e083517760c4dc07bb9e1b54c9a46dae88445445..b1009a70de7b6e502d9196234bbd775adbb04ba8 100644 (file)
@@ -6,7 +6,7 @@ cloud.google.com/go/internal/optional
 cloud.google.com/go/internal/trace
 cloud.google.com/go/internal/version
 cloud.google.com/go/compute/metadata
-# github.com/DreamItGetIT/statuscake v0.0.0-20180728152938-85edefcbdaa3
+# github.com/DreamItGetIT/statuscake v0.0.0-20190218105717-471b24d8edfb
 github.com/DreamItGetIT/statuscake
 # github.com/agext/levenshtein v1.2.2
 github.com/agext/levenshtein
index 0f99fb4c4ef34ace399cbd8b2f77faae1803fd6a..3513f732bbd5ade26d4247430f301e2e948ef09b 100644 (file)
@@ -29,8 +29,8 @@ The following arguments are supported:
 * `website_name` - (Required) This is the name of the test and the website to be monitored.
 * `website_url` - (Required) The URL of the website to be monitored
 * `check_rate` - (Optional) Test check rate in seconds. Defaults to 300
-* `contact_id` - **Deprecated** (Optional) The id of the contact group to be added to the test. Each test can have only one. 
-* `contact_group` - (Optional) Set test contact groups, must be array of strings. 
+* `contact_id` - **Deprecated** (Optional) The id of the contact group to be added to the test. Each test can have only one.
+* `contact_group` - (Optional) Set test contact groups, must be array of strings.
 * `test_type` - (Required) The type of Test. Either HTTP, TCP, PING, or DNS
 * `paused` - (Optional) Whether or not the test is paused. Defaults to false.
 * `timeout` - (Optional) The timeout of the test in seconds.
@@ -56,6 +56,7 @@ The following arguments are supported:
 * `use_jar` - (Optional) Set to true to enable the Cookie Jar. Required for some redirects. Default is false.
 * `post_raw` - (Optional) Use to populate the RAW POST data field on the test.
 * `final_endpoint` - (Optional) Use to specify the expected Final URL in the testing process.
+* `enable_ssl_alert` - (Optional) HTTP Tests only. If enabled, tests will send warnings if the SSL certificate is about to expire. Paid users only. Default is false
 * `follow_redirect` - (Optional) Use to specify whether redirects should be followed, set to true to enable. Default is false.
 
 ## Attributes Reference