From 8ab0fdf56353de085536ed0495a14a9b58cf533a Mon Sep 17 00:00:00 2001 From: Douglas Harcourt Parsons Date: Wed, 1 May 2024 14:55:22 +0100 Subject: [PATCH] Fix some linting errors --- Taskfile.yml | 2 +- client/must_marshal.go | 6 +++++- client/project_protection_bypass_for_automation_update.go | 2 -- sweep/main.go | 6 ++++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 3416a047..4ff0fbf3 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -73,7 +73,7 @@ tasks: - install-providerlint cmds: - staticcheck -tags it ./... - - tfproviderlint -R018=false -R009=false ./... + - tfproviderlint -R018=false ./... - cmd: | export BADFMT=$(gofmt -s -l .) test -z "$BADFMT" || (echo -e "invalid gofmt: $BADFMT"; exit 1) diff --git a/client/must_marshal.go b/client/must_marshal.go index d4989fd5..53d2f2e9 100644 --- a/client/must_marshal.go +++ b/client/must_marshal.go @@ -22,6 +22,10 @@ func (v *VercelAuthentication) MarshalJSON() ([]byte, error) { // be marshaled. As our structs are known ahead of time and are all safe to marshal, // this simplifies the error checking process. func mustMarshal(v interface{}) []byte { - res, _ := json.Marshal(v) + res, err := json.Marshal(v) + if err != nil { + //lintignore:R009 // this is okay as we know the shape of the data + panic(err) + } return res } diff --git a/client/project_protection_bypass_for_automation_update.go b/client/project_protection_bypass_for_automation_update.go index 25759723..d721539f 100644 --- a/client/project_protection_bypass_for_automation_update.go +++ b/client/project_protection_bypass_for_automation_update.go @@ -3,7 +3,6 @@ package client import ( "context" "fmt" - "time" "github.com/hashicorp/terraform-plugin-log/tflog" ) @@ -50,7 +49,6 @@ func (c *Client) UpdateProtectionBypassForAutomation(ctx context.Context, reques response := struct { ProtectionBypass map[string]ProtectionBypass `json:"protectionBypass"` }{} - time.Sleep(1 * time.Second) err = c.doRequest(clientRequest{ ctx: ctx, method: "PATCH", diff --git a/sweep/main.go b/sweep/main.go index e181a50c..377ce671 100644 --- a/sweep/main.go +++ b/sweep/main.go @@ -18,10 +18,12 @@ func main() { c := client.New(os.Getenv("VERCEL_API_TOKEN")) teamID := os.Getenv("VERCEL_TERRAFORM_TESTING_TEAM") if teamID == "" { + //lintignore:R009 panic("VERCEL_TERRAFORM_TESTING_TEAM environment variable not set") } domain := os.Getenv("VERCEL_TERRAFORM_TESTING_DOMAIN") if domain == "" { + //lintignore:R009 panic("VERCEL_TERRAFORM_TESTING_DOMAIN environment variable not set") } ctx := context.Background() @@ -29,18 +31,22 @@ func main() { // delete both for the testing team, and for without a team err := deleteAllProjects(ctx, c, teamID) if err != nil { + //lintignore:R009 panic(err) } err = deleteAllDNSRecords(ctx, c, domain, teamID) if err != nil { + //lintignore:R009 panic(err) } err = deleteAllSharedEnvironmentVariables(ctx, c, teamID) if err != nil { + //lintignore:R009 panic(err) } err = deleteAllEdgeConfigs(ctx, c, teamID) if err != nil { + //lintignore:R009 panic(err) } }