added cmp function
This commit is contained in:
@@ -250,3 +250,54 @@ func (obj *CloudflareDNSRes) CheckApply(ctx context.Context, apply bool) (bool,
|
|||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (obj *CloudflareDNSRes) Cmp(r engine.Res) error {
|
||||||
|
if obj == nil && r == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj == nil) != (r == nil) {
|
||||||
|
return fmt.Errorf("one resource is empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
res, ok := r.(*CloudflareDNSRes)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("not a %s", obj.Kind())
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.APIToken != res.APIToken {
|
||||||
|
return fmt.Errorf("apitoken differs")
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.Proxied != res.Proxied {
|
||||||
|
return fmt.Errorf("proxied values differ")
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.RecordName != res.RecordName {
|
||||||
|
return fmt.Errorf("record name differs")
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.Purged != res.Purged {
|
||||||
|
return fmt.Errorf("purge value differs")
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.State != res.State {
|
||||||
|
return fmt.Errorf("state differs")
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.TTL != res.TTL {
|
||||||
|
return fmt.Errorf("ttl differs")
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.Type != res.Type {
|
||||||
|
return fmt.Errorf("record type differs")
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.Zone != res.Zone {
|
||||||
|
return fmt.Errorf("zone differs")
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.zoneID != res.zoneID {
|
||||||
|
return fmt.Errorf("zoneid differs")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user