fix(selectel): nil-guard в ApplyChanges + тесты пагинации rrset и nil-diff
This commit is contained in:
@@ -159,10 +159,16 @@ func (c *Client) ApplyChanges(ctx context.Context, creds provider.Credentials, z
|
||||
}
|
||||
switch d.Kind {
|
||||
case diff.Add:
|
||||
if d.Desired == nil {
|
||||
return fmt.Errorf("selectel: add/update diff without Desired record")
|
||||
}
|
||||
if err := c.do(ctx, http.MethodPost, base, creds.Secret, toRRSet(*d.Desired), nil); err != nil {
|
||||
return err
|
||||
}
|
||||
case diff.Update:
|
||||
if d.Desired == nil {
|
||||
return fmt.Errorf("selectel: add/update diff without Desired record")
|
||||
}
|
||||
id, ok := idByKey[d.Desired.Key()]
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot update: rrset %s not found in zone", d.Desired.Key())
|
||||
@@ -171,6 +177,9 @@ func (c *Client) ApplyChanges(ctx context.Context, creds provider.Credentials, z
|
||||
return err
|
||||
}
|
||||
case diff.Delete:
|
||||
if d.Actual == nil {
|
||||
return fmt.Errorf("selectel: delete diff without Actual record")
|
||||
}
|
||||
id, ok := idByKey[d.Actual.Key()]
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot delete: rrset %s not found in zone", d.Actual.Key())
|
||||
|
||||
Reference in New Issue
Block a user