Skip to content

Commit

Permalink
Merge branch 'master' into dualstack-support
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Nov 19, 2024
2 parents 03c2436 + 3c22c0d commit e726090
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/metal-api/internal/datastore/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,8 @@ func (rs *RethinkStore) GetSwitchStatus(id string) (*metal.SwitchStatus, error)
func (rs *RethinkStore) SetSwitchStatus(state *metal.SwitchStatus) error {
return rs.upsertEntity(rs.switchStatusTable(), state)
}

// DeleteSwitchStatus delete SwitchStatus
func (rs *RethinkStore) DeleteSwitchStatus(status *metal.SwitchStatus) error {
return rs.deleteEntity(rs.switchStatusTable(), status)
}
12 changes: 12 additions & 0 deletions cmd/metal-api/internal/service/switch-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,18 @@ func (r *switchResource) deleteSwitch(request *restful.Request, response *restfu
return
}

status, err := r.ds.GetSwitchStatus(id)
if err == nil {
err = r.ds.DeleteSwitchStatus(status)
if err != nil {
r.sendError(request, response, defaultError(err))
return
}
} else if !metal.IsNotFound(err) {
r.sendError(request, response, defaultError(err))
return
}

resp, err := r.makeSwitchResponse(s)
if err != nil {
r.sendError(request, response, defaultError(err))
Expand Down

0 comments on commit e726090

Please sign in to comment.