mirror of
https://github.com/joohoi/acme-dns.git
synced 2024-12-22 21:03:54 +07:00
Fix linter issues
This commit is contained in:
parent
5a16ea93e9
commit
7e121f0f3c
2
api.go
2
api.go
@ -140,7 +140,7 @@ func webDeletePost(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(delStatus)
|
||||
w.Write(del)
|
||||
_, _ = w.Write(del)
|
||||
}
|
||||
|
||||
// Endpoint used to check the readiness and/or liveness (health) of the server.
|
||||
|
13
api_test.go
13
api_test.go
@ -515,10 +515,6 @@ func TestApiManyUpdateWithCredentials(t *testing.T) {
|
||||
func TestApiManyDeleteWithCredentials(t *testing.T) {
|
||||
validTxtData := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
|
||||
updateJSON := map[string]interface{}{
|
||||
"subdomain": "",
|
||||
"txt": ""}
|
||||
|
||||
router := setupRouter(true, false)
|
||||
server := httptest.NewServer(router)
|
||||
defer server.Close()
|
||||
@ -560,7 +556,7 @@ func TestApiManyDeleteWithCredentials(t *testing.T) {
|
||||
{newUserWithValidCIDR.Username.String(), newUserWithValidCIDR.Password, newUserWithValidCIDR.Subdomain, validTxtData, 200},
|
||||
{newUser.Username.String(), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", newUser.Subdomain, validTxtData, 401},
|
||||
} {
|
||||
updateJSON = map[string]interface{}{
|
||||
updateJSON := map[string]interface{}{
|
||||
"subdomain": test.subdomain,
|
||||
"txt": test.txt}
|
||||
e.POST("/delete").
|
||||
@ -626,11 +622,6 @@ func TestApiManyUpdateWithIpCheckHeaders(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApiManyDeleteWithIpCheckHeaders(t *testing.T) {
|
||||
|
||||
updateJSON := map[string]interface{}{
|
||||
"subdomain": "",
|
||||
"txt": ""}
|
||||
|
||||
router := setupRouter(false, false)
|
||||
server := httptest.NewServer(router)
|
||||
defer server.Close()
|
||||
@ -667,7 +658,7 @@ func TestApiManyDeleteWithIpCheckHeaders(t *testing.T) {
|
||||
{newUserWithIP6CIDR, "2002:c0a7:0ff::0", 401},
|
||||
{newUserWithIP6CIDR, "2002:c0a8:d3ad:b33f:c0ff:33b4:dc0d:3b4d", 200},
|
||||
} {
|
||||
updateJSON = map[string]interface{}{
|
||||
updateJSON := map[string]interface{}{
|
||||
"subdomain": test.user.Subdomain,
|
||||
"txt": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}
|
||||
e.POST("/delete").
|
||||
|
23
db.go
23
db.go
@ -114,28 +114,7 @@ func (d *acmedb) handleDBUpgrades(version int) error {
|
||||
|
||||
func (d *acmedb) handleDBUpgradeTo1() error {
|
||||
var err error
|
||||
var subdomains []string
|
||||
log.Info("Upgrading db to version 1")
|
||||
rows, err := d.DB.Query("SELECT Subdomain FROM records")
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{"error": err.Error()}).Error("Error in DB upgrade")
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
var subdomain string
|
||||
err = rows.Scan(&subdomain)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{"error": err.Error()}).Error("Error in DB upgrade while reading values")
|
||||
return err
|
||||
}
|
||||
subdomains = append(subdomains, subdomain)
|
||||
}
|
||||
err = rows.Err()
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{"error": err.Error()}).Error("Error in DB upgrade while inserting values")
|
||||
return err
|
||||
}
|
||||
tx, err := d.DB.Begin()
|
||||
// Rollback if errored, commit if not
|
||||
defer func() {
|
||||
@ -312,10 +291,10 @@ func (d *acmedb) Update(a ACMETxtPost) error {
|
||||
|
||||
lastUsedSQL := `UPDATE records SET LastUsed = $1 WHERE Subdomain = $2`
|
||||
lastUsedStmt, err := d.DB.Prepare(lastUsedSQL)
|
||||
defer lastUsedStmt.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer lastUsedStmt.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -356,7 +356,6 @@ func TestResolveTXT(t *testing.T) {
|
||||
t.Fatalf("Test %d: %s", seq, err)
|
||||
return
|
||||
}
|
||||
seq++
|
||||
}
|
||||
|
||||
func TestCaseInsensitiveResolveA(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user