From a8b2397631278c63959da53b9914f453d393104b Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 16 Feb 2019 14:56:15 +0100 Subject: [PATCH 1/3] chore: update golangci-lint. --- .travis.yml | 2 +- cmd/cmd_run.go | 2 +- providers/dns/sakuracloud/sakuracloud.go | 9 +++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3e5f26a6..cbef55ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ before_install: - go get -u github.com/letsencrypt/pebble/... # Install linters and misspell - - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.13.2 + - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.14.0 - golangci-lint --version install: diff --git a/cmd/cmd_run.go b/cmd/cmd_run.go index 82c5cced..a47d5097 100644 --- a/cmd/cmd_run.go +++ b/cmd/cmd_run.go @@ -106,7 +106,7 @@ func handleTOS(ctx *cli.Context, client *lego.Client) bool { case "", "y", "Y": return true case "n", "N": - log.Fatal("You did not accept the TOS. Unable to proceed.") + return false default: fmt.Println("Your input was invalid. Please answer with one of Y/y, n/N or by pressing enter.") } diff --git a/providers/dns/sakuracloud/sakuracloud.go b/providers/dns/sakuracloud/sakuracloud.go index 54c92a9f..ea2d4600 100644 --- a/providers/dns/sakuracloud/sakuracloud.go +++ b/providers/dns/sakuracloud/sakuracloud.go @@ -101,10 +101,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { return fmt.Errorf("sakuracloud: %v", err) } - records, err := d.findTxtRecords(fqdn, zone) - if err != nil { - return fmt.Errorf("sakuracloud: %v", err) - } + records := d.findTxtRecords(fqdn, zone) for _, record := range records { var updRecords []sacloud.DNSRecordSet @@ -155,7 +152,7 @@ func (d *DNSProvider) getHostedZone(domain string) (*sacloud.DNS, error) { return nil, fmt.Errorf("zone %s not found", zoneName) } -func (d *DNSProvider) findTxtRecords(fqdn string, zone *sacloud.DNS) ([]sacloud.DNSRecordSet, error) { +func (d *DNSProvider) findTxtRecords(fqdn string, zone *sacloud.DNS) []sacloud.DNSRecordSet { recordName := d.extractRecordName(fqdn, zone.Name) var res []sacloud.DNSRecordSet @@ -164,7 +161,7 @@ func (d *DNSProvider) findTxtRecords(fqdn string, zone *sacloud.DNS) ([]sacloud. res = append(res, record) } } - return res, nil + return res } func (d *DNSProvider) extractRecordName(fqdn, domain string) string { From 931ab3d8bfa8ae0306dceb0295269e228bff1606 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 18 Feb 2019 13:28:19 +0100 Subject: [PATCH 2/3] chore: update to golangci-lint v1.15.0 --- .golangci.toml | 55 ++++++++++++++++++++++++++++++++++++-------------- .travis.yml | 2 +- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/.golangci.toml b/.golangci.toml index 498387ec..52a165a2 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -36,20 +36,45 @@ max-per-linter = 0 max-same = 0 exclude = [ - "Error return value of (.+) is not checked", + "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked", "exported (type|method|function) (.+) should have comment or be unexported", - "cyclomatic complexity (.+) of func `NewDNSChallengeProviderByName` is high (.+)", # providers/dns/dns_providers.go - "string `(lego\\.wtf|manhattan)` has (\\d+) occurrences, make it a constant", #providers/dns/gcloud/googlecloud_test.go - - "(dnsHelp|createRenew\\$1|createRun\\$1|run) - result 0 \\(error\\) is always nil", # cmd/ - "`(tlsFeatureExtensionOID|ocspMustStapleFeature)` is a global variable", # certcrypto/crypto.go - "`(defaultNameservers|recursiveNameservers|dnsTimeout|fqdnToZone|muFqdnToZone)` is a global variable", # challenge/dns01/nameserver.go - "`idPeAcmeIdentifierV1` is a global variable", # challenge/tlsalpn01/tls_alpn_challenge.go - "`Logger` is a global variable", # log/logger.go - "`version` is a global variable", # cli.go - "`load` is a global variable", # e2e/challenges_test.go - "`envTest` is a global variable", # providers/dns/**/*_test.go - "`(tldsMock|testCases)` is a global variable", # providers/dns/namecheap/namecheap_test.go - "`(errorClientErr|errorStorageErr|egTestAccount)` is a global variable", # providers/dns/acmedns/acmedns_test.go - "`memcachedHosts` is a global variable", # providers/http/memcached/memcached_test.go ] + [[issues.exclude-rules]] + path = "providers/dns/dns_providers.go" + linters = ["gocyclo"] + [[issues.exclude-rules]] + path = "providers/dns/gcloud/googlecloud_test.go" + text = "string `(lego\\.wtf|manhattan)` has (\\d+) occurrences, make it a constant" + [[issues.exclude-rules]] + path = "providers/dns/zoneee/zoneee_test.go" + text = "string `(bar|foo)` has (\\d+) occurrences, make it a constant" + [[issues.exclude-rules]] + path = "certcrypto/crypto.go" + text = "`(tlsFeatureExtensionOID|ocspMustStapleFeature)` is a global variable" + [[issues.exclude-rules]] + path = "challenge/dns01/nameserver.go" + text = "`(defaultNameservers|recursiveNameservers|dnsTimeout|fqdnToZone|muFqdnToZone)` is a global variable" + [[issues.exclude-rules]] + path = "challenge/tlsalpn01/tls_alpn_challenge.go" + text = "`idPeAcmeIdentifierV1` is a global variable" + [[issues.exclude-rules]] + path = "log/logger.go" + text = "`Logger` is a global variable" + [[issues.exclude-rules]] + path = "cmd/lego/main.go" + text = "`version` is a global variable" + [[issues.exclude-rules]] + path = "e2e/(dnschallenge/)?[\\d\\w]+_test.go" + text = "`load` is a global variable" + [[issues.exclude-rules]] + path = "providers/dns/([\\d\\w]+/)*[\\d\\w]+_test.go" + text = "`envTest` is a global variable" + [[issues.exclude-rules]] + path = "providers/dns/namecheap/namecheap_test.go" + text = "`(tldsMock|testCases)` is a global variable" + [[issues.exclude-rules]] + path = "providers/dns/acmedns/acmedns_test.go" + text = "`(errorClientErr|errorStorageErr|egTestAccount)` is a global variable" + [[issues.exclude-rules]] + path = "providers/http/memcached/memcached_test.go" + text = "`memcachedHosts` is a global variable" diff --git a/.travis.yml b/.travis.yml index cbef55ac..69e3fbd6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ before_install: - go get -u github.com/letsencrypt/pebble/... # Install linters and misspell - - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.14.0 + - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.15.0 - golangci-lint --version install: From b9c712cde6372053d224637f8c38739c5151c01e Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 18 Feb 2019 13:42:10 +0100 Subject: [PATCH 3/3] fix: wrong option. --- .golangci.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.toml b/.golangci.toml index 52a165a2..fa3097e9 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -34,7 +34,7 @@ [issues] exclude-use-default = false max-per-linter = 0 - max-same = 0 + max-same-issues = 0 exclude = [ "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked", "exported (type|method|function) (.+) should have comment or be unexported",