Skip to content

Commit 56c4693

Browse files
authored
Merge pull request #9 from benjaminbear/fix_cname_delete
fix model validation and preloading
2 parents 79bd7fe + eb947bd commit 56c4693

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

Diff for: .travis.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
dist: bionic
2-
31
language: go
42

53
env: GO111MODULE=on
64

75
go:
8-
- 1.15.x
9-
- 1.16.x
6+
- 1.13.x
7+
- 1.14.x
108

119
git:
1210
depth: 1
1311

14-
script:
12+
before_script:
1513
- cd dyndns
14+
15+
script:
1616
- go test -v ./...
1717
- go build ./...
1818

Diff for: dyndns/handler/cname.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (h *Handler) DeleteCName(c echo.Context) (err error) {
9797
}
9898

9999
cname := &model.CName{}
100-
if err = h.DB.First(cname, id).Error; err != nil {
100+
if err = h.DB.Preload("Target").First(cname, id).Error; err != nil {
101101
return c.JSON(http.StatusBadRequest, &Error{err.Error()})
102102
}
103103

Diff for: dyndns/handler/host.go

-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
292292
}
293293

294294
func (h *Handler) checkUniqueHostname(hostname, domain string) error {
295-
fmt.Println(hostname, domain)
296295
hosts := new([]model.Host)
297296
if err := h.DB.Where(&model.Host{Hostname: hostname, Domain: domain}).Find(hosts).Error; err != nil {
298297
return err

Diff for: dyndns/model/host.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
type Host struct {
1111
gorm.Model
1212
Hostname string `gorm:"unique_index:idx_host_domain;not null" form:"hostname" validate:"required,hostname"`
13-
Domain string `gorm:"unique_index:idx_host_domain;not null" validate:"required,hostname"`
13+
Domain string `gorm:"unique_index:idx_host_domain;not null" form:"domain" validate:"required,hostname"`
1414
Ip string `form:"ip" validate:"omitempty,ipv4"`
1515
Ttl int `form:"ttl" validate:"required,min=20,max=86400"`
1616
LastUpdate time.Time `form:"lastupdate"`

0 commit comments

Comments
 (0)