Skip to content

Commit

Permalink
[IMP] Hetzner: Compare ip on create
Browse files Browse the repository at this point in the history
  • Loading branch information
lieblinger committed Oct 10, 2023
1 parent 4c7bb5d commit 17a7345
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/provider/providers/hetzner/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,17 @@ func (p *Provider) createRecord(ctx context.Context, client *http.Client, ip net
decoder := json.NewDecoder(response.Body)
var parsedJSON struct {
Record struct {
ID string `json:"id"`
ID string `json:"id"`
Value netip.Addr `json:"value"`
} `json:"record"`
}
err = decoder.Decode(&parsedJSON)
newIP := parsedJSON.Record.Value
if err != nil {
return fmt.Errorf("json decoding response body: %w", err)
} else if newIP.Compare(ip) != 0 {
return fmt.Errorf("%w: sent ip %s to update but received %s",
errors.ErrIPReceivedMismatch, ip, newIP)
}

if parsedJSON.Record.ID == "" {
Expand Down

0 comments on commit 17a7345

Please sign in to comment.