chore: go1.16 and linter update
This commit is contained in:
parent
c1eebcb16e
commit
0c0662615b
2
.github/workflows/go-cross.yml
vendored
2
.github/workflows/go-cross.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [ 1.14, 1.15, 1.x ]
|
||||
go-version: [ 1.16, 1.x ]
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
|
||||
steps:
|
||||
|
||||
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
@ -14,9 +14,9 @@ jobs:
|
||||
name: Main Process
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GO_VERSION: 1.15
|
||||
GOLANGCI_LINT_VERSION: v1.33.0
|
||||
SEIHON_VERSION: v0.5.1
|
||||
GO_VERSION: 1.16
|
||||
GOLANGCI_LINT_VERSION: v1.38.0
|
||||
SEIHON_VERSION: v0.8.3
|
||||
CGO_ENABLED: 0
|
||||
|
||||
steps:
|
||||
@ -44,10 +44,10 @@ jobs:
|
||||
|
||||
- name: Check and get dependencies
|
||||
run: |
|
||||
go mod download
|
||||
go mod tidy
|
||||
git diff --exit-code go.mod
|
||||
git diff --exit-code go.sum
|
||||
go mod download
|
||||
|
||||
# https://golangci-lint.run/usage/install#other-ci
|
||||
- name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }}
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
[run]
|
||||
timeout = "5m"
|
||||
skip-files = []
|
||||
|
||||
[linters-settings]
|
||||
|
||||
[linters-settings.govet]
|
||||
check-shadowing = true
|
||||
|
||||
[linters-settings.gocyclo]
|
||||
min-complexity = 12.0
|
||||
|
||||
[linters-settings.maligned]
|
||||
suggest-new = true
|
||||
|
||||
[linters-settings.goconst]
|
||||
min-len = 3.0
|
||||
min-occurrences = 3.0
|
||||
|
||||
[linters-settings.misspell]
|
||||
locale = "US"
|
||||
|
||||
[linters]
|
||||
enable-all = true
|
||||
disable = [
|
||||
"maligned",
|
||||
"lll",
|
||||
"gosec",
|
||||
"dupl",
|
||||
"prealloc",
|
||||
"scopelint",
|
||||
"wsl",
|
||||
"nlreturn",
|
||||
"gomnd",
|
||||
"testpackage",
|
||||
"paralleltest",
|
||||
"tparallel",
|
||||
"goerr113",
|
||||
"wrapcheck",
|
||||
"exhaustive",
|
||||
"exhaustivestruct",
|
||||
]
|
||||
|
||||
[issues]
|
||||
exclude-use-default = false
|
||||
max-per-linter = 0
|
||||
max-same-issues = 0
|
||||
exclude = ["ST1000: at least one file in a package should have a package comment"]
|
||||
[[issues.exclude-rules]]
|
||||
path = "cmd/"
|
||||
linters = ["gochecknoglobals", "gochecknoinits"]
|
||||
82
.golangci.yml
Normal file
82
.golangci.yml
Normal file
@ -0,0 +1,82 @@
|
||||
run:
|
||||
timeout: 5m
|
||||
skip-files: []
|
||||
|
||||
linters-settings:
|
||||
govet:
|
||||
check-shadowing: true
|
||||
gocyclo:
|
||||
min-complexity: 12
|
||||
maligned:
|
||||
suggest-new: true
|
||||
goconst:
|
||||
min-len: 3
|
||||
min-occurrences: 3
|
||||
misspell:
|
||||
locale: US
|
||||
gofumpt:
|
||||
extra-rules: true
|
||||
depguard:
|
||||
list-type: blacklist
|
||||
include-go-root: false
|
||||
packages:
|
||||
- github.com/pkg/errors
|
||||
godox:
|
||||
keywords:
|
||||
- FIXME
|
||||
gocritic:
|
||||
enabled-tags:
|
||||
- diagnostic
|
||||
- style
|
||||
- performance
|
||||
disabled-checks:
|
||||
- sloppyReassign
|
||||
- rangeValCopy
|
||||
- octalLiteral
|
||||
- paramTypeCombine # already handle by gofumpt.extra-rules
|
||||
settings:
|
||||
hugeParam:
|
||||
sizeThreshold: 100
|
||||
forbidigo:
|
||||
forbid:
|
||||
- '^print(ln)?$'
|
||||
- '^spew\.Print(f|ln)?$'
|
||||
- '^spew\.Dump$'
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- scopelint # deprecated
|
||||
- interfacer # deprecated
|
||||
- maligned # deprecated
|
||||
- sqlclosecheck # not relevant (SQL)
|
||||
- rowserrcheck # not relevant (SQL)
|
||||
- cyclop # duplicate of gocyclo
|
||||
- lll
|
||||
- gas
|
||||
- dupl
|
||||
- prealloc
|
||||
- scopelint
|
||||
- wsl
|
||||
- nlreturn
|
||||
- gomnd
|
||||
- testpackage
|
||||
- paralleltest
|
||||
- tparallel
|
||||
- goerr113
|
||||
- wrapcheck
|
||||
- exhaustive
|
||||
- exhaustivestruct
|
||||
- ifshort
|
||||
|
||||
issues:
|
||||
exclude-use-default: false
|
||||
max-per-linter: 0
|
||||
max-same-issues: 0
|
||||
exclude:
|
||||
- 'ST1000: at least one file in a package should have a package comment'
|
||||
exclude-rules:
|
||||
- path: cmd/
|
||||
linters:
|
||||
- gochecknoglobals
|
||||
- gochecknoinits
|
||||
12
cmd/kv.go
12
cmd/kv.go
@ -4,7 +4,6 @@ import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
@ -87,7 +86,7 @@ func createTLSConfig(cmd *cobra.Command) (*tls.Config, error) {
|
||||
privateKey := cmd.Flag("tls.key").Value.String()
|
||||
certContent := cmd.Flag("tls.cert").Value.String()
|
||||
|
||||
if !insecureSkipVerify && (len(certContent) == 0 || len(privateKey) == 0) {
|
||||
if !insecureSkipVerify && (certContent == "" || privateKey == "") {
|
||||
return nil, fmt.Errorf("TLS Certificate or Key file must be set when TLS configuration is created")
|
||||
}
|
||||
|
||||
@ -122,11 +121,14 @@ func getCertPool(ca string) (*x509.CertPool, error) {
|
||||
}
|
||||
|
||||
func getCAContent(ca string) ([]byte, error) {
|
||||
if _, errCA := os.Stat(ca); errCA != nil {
|
||||
return []byte(ca), nil
|
||||
if _, err := os.Stat(ca); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return []byte(ca), nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
caContent, err := ioutil.ReadFile(filepath.Clean(ca))
|
||||
caContent, err := os.ReadFile(filepath.Clean(ca))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -2,14 +2,13 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/ldez/traefik-certs-dumper/v2/dumper"
|
||||
homedir "github.com/mitchellh/go-homedir"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
@ -117,7 +116,7 @@ func tree(root, indent string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
fis, err := ioutil.ReadDir(root)
|
||||
fis, err := os.ReadDir(root)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not read dir %s: %w", root, err)
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/ldez/traefik-certs-dumper/v2/dumper"
|
||||
@ -35,9 +33,7 @@ func TestDump(t *testing.T) {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
dir, err := ioutil.TempDir("", "traefik-cert-dumper")
|
||||
require.NoError(t, err)
|
||||
defer func() { _ = os.RemoveAll(dir) }()
|
||||
dir := t.TempDir()
|
||||
|
||||
cfg := &dumper.BaseConfig{
|
||||
DumpPath: dir,
|
||||
@ -53,7 +49,7 @@ func TestDump(t *testing.T) {
|
||||
Version: test.version,
|
||||
}
|
||||
|
||||
err = Dump(test.acmeFile, cfg)
|
||||
err := Dump(test.acmeFile, cfg)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import (
|
||||
"compress/gzip"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
@ -83,7 +83,7 @@ func getStoredDataFromGzip(pair *store.KVPair) (*v1.StoredData, error) {
|
||||
return nil, fmt.Errorf("fail to create GZip reader: %w", err)
|
||||
}
|
||||
|
||||
acmeData, err := ioutil.ReadAll(reader)
|
||||
acmeData, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to read the pair content: %w", err)
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ package v1
|
||||
import (
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -52,7 +51,7 @@ func Dump(data *StoredData, baseConfig *dumper.BaseConfig) error {
|
||||
}
|
||||
|
||||
privateKeyPem := extractPEMPrivateKey(data.Account)
|
||||
return ioutil.WriteFile(filepath.Join(baseConfig.DumpPath, keysSubDir, "letsencrypt"+baseConfig.KeyInfo.Ext), privateKeyPem, 0600)
|
||||
return os.WriteFile(filepath.Join(baseConfig.DumpPath, keysSubDir, "letsencrypt"+baseConfig.KeyInfo.Ext), privateKeyPem, 0600)
|
||||
}
|
||||
|
||||
func writeCert(dumpPath string, cert *Certificate, info dumper.FileInfo, domainSubDir bool) error {
|
||||
@ -64,7 +63,7 @@ func writeCert(dumpPath string, cert *Certificate, info dumper.FileInfo, domainS
|
||||
}
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(certPath, cert.Certificate, 0666)
|
||||
return os.WriteFile(certPath, cert.Certificate, 0666)
|
||||
}
|
||||
|
||||
func writeKey(dumpPath string, cert *Certificate, info dumper.FileInfo, domainSubDir bool) error {
|
||||
@ -76,7 +75,7 @@ func writeKey(dumpPath string, cert *Certificate, info dumper.FileInfo, domainSu
|
||||
}
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(keyPath, cert.Key, 0600)
|
||||
return os.WriteFile(keyPath, cert.Key, 0600)
|
||||
}
|
||||
|
||||
func extractPEMPrivateKey(account *Account) []byte {
|
||||
@ -109,7 +108,7 @@ func cleanDir(dumpPath string) error {
|
||||
return errExists
|
||||
}
|
||||
|
||||
dir, err := ioutil.ReadDir(dumpPath)
|
||||
dir, err := os.ReadDir(dumpPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ package v2
|
||||
import (
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -55,7 +54,7 @@ func Dump(data map[string]*acme.StoredData, baseConfig *dumper.BaseConfig) error
|
||||
|
||||
privateKeyPem := extractPEMPrivateKey(store.Account)
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(baseConfig.DumpPath, keysSubDir, "letsencrypt"+baseConfig.KeyInfo.Ext), privateKeyPem, 0600)
|
||||
err := os.WriteFile(filepath.Join(baseConfig.DumpPath, keysSubDir, "letsencrypt"+baseConfig.KeyInfo.Ext), privateKeyPem, 0600)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write private key: %w", err)
|
||||
}
|
||||
@ -73,7 +72,7 @@ func writeCert(dumpPath string, cert acme.Certificate, info dumper.FileInfo, dom
|
||||
}
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(certPath, cert.Certificate, 0666)
|
||||
return os.WriteFile(certPath, cert.Certificate, 0666)
|
||||
}
|
||||
|
||||
func writeKey(dumpPath string, cert acme.Certificate, info dumper.FileInfo, domainSubDir bool) error {
|
||||
@ -85,7 +84,7 @@ func writeKey(dumpPath string, cert acme.Certificate, info dumper.FileInfo, doma
|
||||
}
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(keyPath, cert.Key, 0600)
|
||||
return os.WriteFile(keyPath, cert.Key, 0600)
|
||||
}
|
||||
|
||||
func extractPEMPrivateKey(account *acme.Account) []byte {
|
||||
@ -118,7 +117,7 @@ func cleanDir(dumpPath string) error {
|
||||
return errExists
|
||||
}
|
||||
|
||||
dir, err := ioutil.ReadDir(dumpPath)
|
||||
dir, err := os.ReadDir(dumpPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
||||
module github.com/ldez/traefik-certs-dumper/v2
|
||||
|
||||
go 1.14
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/abronan/valkeyrie v0.1.0
|
||||
|
||||
2
go.sum
2
go.sum
@ -85,7 +85,6 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/sarama v1.23.1/go.mod h1:XLH1GYJnLVE0XCr6KdJGVJRTwY30moWNJ4sERjXX6fs=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE=
|
||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
||||
github.com/abronan/valkeyrie v0.0.0-20200127174252-ef4277a138cd/go.mod h1:2RUNONRAQ8bS1QcVJF3dYO/faiEro6NAAIQ6CqBkpD0=
|
||||
github.com/abronan/valkeyrie v0.1.0 h1:xhyFvo2Gh+P8KPauMERFDOcVVB0LKU1UgXrVB0jwjH4=
|
||||
@ -599,7 +598,6 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE
|
||||
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
|
||||
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
|
||||
github.com/nrdcg/auroradns v1.0.1 h1:m/kBq83Xvy3cU261MOknd8BdnOk12q4lAWM+kOdsC2Y=
|
||||
github.com/nrdcg/auroradns v1.0.1/go.mod h1:y4pc0i9QXYlFCWrhWrUSIETnZgrf4KuwjDIWmmXo3JI=
|
||||
|
||||
@ -3,8 +3,8 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
@ -92,7 +92,7 @@ func putData(backend store.Backend, addrs []string, content []byte) error {
|
||||
}
|
||||
|
||||
func readFile(source string) ([]byte, error) {
|
||||
content, err := ioutil.ReadFile(filepath.Clean(source))
|
||||
content, err := os.ReadFile(filepath.Clean(source))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user