From 9014794ab584e7f485dac133d41ac7f9bfa38006 Mon Sep 17 00:00:00 2001 From: Tristan Date: Wed, 31 Aug 2022 13:32:59 -0400 Subject: [PATCH 1/3] Disable slack in RateLimiter just saw it pass 20r/s... --- internal/cloudns/provider.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/cloudns/provider.go b/internal/cloudns/provider.go index 4eb2621..866f4d2 100644 --- a/internal/cloudns/provider.go +++ b/internal/cloudns/provider.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/sta-travel/cloudns-go" "go.uber.org/ratelimit" + "time" ) const EnvVarAuthId = "CLOUDNS_AUTH_ID" @@ -88,7 +89,12 @@ func configure() func(context.Context, *schema.ResourceData) (interface{}, diag. return nil, diag.Errorf("Exactly one of auth_id or sub_auth_id must be set, but both were %s", golangSucks) } - rateLimit := d.Get("rate_limit").(int) + rateLimiter := ratelimit.New( + d.Get("rate_limit").(int), + // while slack is a thing, we can't reliably assume it's impactful + ratelimit.WithoutSlack, + ratelimit.Per(time.Second), + ) if authId != 0 { return ClientConfig{ @@ -96,7 +102,7 @@ func configure() func(context.Context, *schema.ResourceData) (interface{}, diag. Authid: authId, Authpassword: password, }, - rateLimiter: ratelimit.New(rateLimit), + rateLimiter: rateLimiter, }, nil } else { return ClientConfig{ @@ -104,7 +110,7 @@ func configure() func(context.Context, *schema.ResourceData) (interface{}, diag. Subauthid: subAuthId, Authpassword: password, }, - rateLimiter: ratelimit.New(rateLimit), + rateLimiter: rateLimiter, }, nil } From 646b9816e2ffb64dc689832c0380b7b3ff6dd649 Mon Sep 17 00:00:00 2001 From: Tristan Date: Wed, 31 Aug 2022 13:33:10 -0400 Subject: [PATCH 2/3] Build with Go 1.19 --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07323e2..0b0f5a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3.3.0 with: - go-version: '1.18' + go-version: '1.19' - name: Import GPG key id: import_gpg uses: crazy-max/ghaction-import-gpg@v5 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d557b2a..62f0ab8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3.3.0 with: - go-version: '1.18' + go-version: '1.19' id: go - name: Check out code into the Go module directory From fd94523404f073ae0e58314db60c3549848dd8f2 Mon Sep 17 00:00:00 2001 From: Tristan Date: Wed, 31 Aug 2022 13:33:30 -0400 Subject: [PATCH 3/3] Set module to 1.19 and force update gjson See: https://github.com/mangadex-pub/terraform-provider-cloudns/security/dependabot/5 --- go.mod | 8 ++++---- go.sum | 9 ++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index a665e9b..0b3b70b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/mangadex-pub/terraform-provider-cloudns -go 1.18 +go 1.19 require ( github.com/google/uuid v1.3.0 @@ -58,9 +58,9 @@ require ( github.com/russross/blackfriday v1.6.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect - github.com/tidwall/gjson v1.4.0 // indirect - github.com/tidwall/match v1.0.1 // indirect - github.com/tidwall/pretty v1.0.0 // indirect + github.com/tidwall/gjson v1.14.3 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect diff --git a/go.sum b/go.sum index f4b38a8..801af66 100644 --- a/go.sum +++ b/go.sum @@ -240,12 +240,15 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/tidwall/gjson v1.4.0 h1:w6iOJZt9BJOzz4VD9CSnRCX/oleCsAZWi+1FFzZA+SA= github.com/tidwall/gjson v1.4.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls= -github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc= +github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= +github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=