Fix golang-ci linter errors (#10128)
* Fix golang-ci linter errors Signed-off-by: z1cheng <imchench@gmail.com> * Fix gofmt errors Signed-off-by: z1cheng <imchench@gmail.com> * Add nolint comment to defaults.Backend in Configuration Signed-off-by: z1cheng <imchench@gmail.com> * Add #nosec comment to rand.New func Signed-off-by: z1cheng <imchench@gmail.com> * Fix errcheck warnings Signed-off-by: z1cheng <imchench@gmail.com> * Fix gofmt check Signed-off-by: z1cheng <imchench@gmail.com> * Fix unit tests and comments Signed-off-by: z1cheng <imchench@gmail.com> --------- Signed-off-by: z1cheng <imchench@gmail.com>
This commit is contained in:
parent
f50431a9f9
commit
d44a8e0045
37 changed files with 206 additions and 162 deletions
|
|
@ -40,13 +40,16 @@ func TestGetDNSServers(t *testing.T) {
|
|||
defer f.Close()
|
||||
defer os.Remove(f.Name())
|
||||
|
||||
os.WriteFile(f.Name(), []byte(`
|
||||
err = os.WriteFile(f.Name(), []byte(`
|
||||
# comment
|
||||
; comment
|
||||
nameserver 2001:4860:4860::8844
|
||||
nameserver 2001:4860:4860::8888
|
||||
nameserver 8.8.8.8
|
||||
`), file.ReadWriteByUser)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
defResolvConf = f.Name()
|
||||
s, err = GetSystemNameServers()
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ func ConfigureCRL(name string, crl []byte, sslCert *ingress.SSLCert) error {
|
|||
return fmt.Errorf("CRL file %v contains invalid data, and must be created only with PEM formatted certificates", name)
|
||||
}
|
||||
|
||||
_, err := x509.ParseCRL(pemCRLBlock.Bytes)
|
||||
_, err := x509.ParseRevocationList(pemCRLBlock.Bytes)
|
||||
if err != nil {
|
||||
return fmt.Errorf(err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -397,7 +397,9 @@ func newFakeCertificate(t *testing.T) ([]byte, string, string) {
|
|||
t.Errorf("failed to write test key: %v", err)
|
||||
}
|
||||
|
||||
certFile.Write(cert)
|
||||
if _, err := certFile.Write(cert); err != nil {
|
||||
t.Errorf("failed to write cert: %v", err)
|
||||
}
|
||||
defer certFile.Close()
|
||||
|
||||
keyFile, err := os.CreateTemp("", "key-")
|
||||
|
|
@ -405,7 +407,9 @@ func newFakeCertificate(t *testing.T) ([]byte, string, string) {
|
|||
t.Errorf("failed to write test key: %v", err)
|
||||
}
|
||||
|
||||
keyFile.Write(key)
|
||||
if _, err := keyFile.Write(key); err != nil {
|
||||
t.Errorf("failed to write key: %v", err)
|
||||
}
|
||||
defer keyFile.Close()
|
||||
|
||||
return cert, certFile.Name(), keyFile.Name()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue