|
15 | 15 | package sql
|
16 | 16 |
|
17 | 17 | import (
|
| 18 | + "context" |
18 | 19 | "reflect"
|
19 | 20 | "sort"
|
20 | 21 |
|
21 | 22 | api "google.golang.org/api/sqladmin/v1beta4"
|
| 23 | + "sigs.k8s.io/controller-runtime/pkg/log" |
22 | 24 | )
|
23 | 25 |
|
24 |
| -func InstancesMatch(desired *api.DatabaseInstance, actual *api.DatabaseInstance) bool { |
| 26 | +func InstancesMatch(ctx context.Context, desired *api.DatabaseInstance, actual *api.DatabaseInstance) bool { |
| 27 | + log := log.FromContext(ctx) |
| 28 | + |
25 | 29 | if desired == nil && actual == nil {
|
26 | 30 | return true
|
27 | 31 | }
|
28 | 32 | if !PointersMatch(desired, actual) {
|
29 | 33 | return false
|
30 | 34 | }
|
31 | 35 | if desired.DatabaseVersion != actual.DatabaseVersion {
|
| 36 | + log.Info("mismatch on field DatabaseVersion", "desired", desired.DatabaseVersion, "actual", actual.DatabaseVersion) |
32 | 37 | return false
|
33 | 38 | }
|
34 | 39 | if !DiskEncryptionConfigurationsMatch(desired.DiskEncryptionConfiguration, actual.DiskEncryptionConfiguration) {
|
| 40 | + log.Info("mismatch on field DiskEncryptionConfigurations", "desired", desired.DiskEncryptionConfiguration, "actual", actual.DiskEncryptionConfiguration) |
35 | 41 | return false
|
36 | 42 | }
|
37 | 43 | // Ignore GeminiConfig. It is not supported in KRM API.
|
38 | 44 | if desired.InstanceType != actual.InstanceType {
|
| 45 | + log.Info("mismatch on field InstanceType", "desired", desired.InstanceType, "actual", actual.InstanceType) |
39 | 46 | return false
|
40 | 47 | }
|
41 | 48 | // Ignore Kind. It is sometimes not set in API responses.
|
42 | 49 | if desired.MaintenanceVersion != actual.MaintenanceVersion {
|
| 50 | + log.Info("mismatch on field MaintenanceVersion", "desired", desired.MaintenanceVersion, "actual", actual.MaintenanceVersion) |
43 | 51 | return false
|
44 | 52 | }
|
45 | 53 | if desired.MasterInstanceName != actual.MasterInstanceName {
|
| 54 | + log.Info("mismatch on field MasterInstanceName", "desired", desired.MasterInstanceName, "actual", actual.MasterInstanceName) |
46 | 55 | return false
|
47 | 56 | }
|
48 | 57 | // Ignore MaxDiskSize. It is not supported in KRM API.
|
49 | 58 | if desired.Name != actual.Name {
|
| 59 | + log.Info("mismatch on field Name", "desired", desired.Name, "actual", actual.Name) |
50 | 60 | return false
|
51 | 61 | }
|
52 | 62 | // Ignore OnPremisesConfiguration. It is not supported in KRM API.
|
53 | 63 | if desired.Region != actual.Region {
|
| 64 | + log.Info("mismatch on field Region", "desired", desired.Region, "actual", actual.Region) |
54 | 65 | return false
|
55 | 66 | }
|
56 | 67 | if !ReplicaConfigurationsMatch(desired.ReplicaConfiguration, actual.ReplicaConfiguration) {
|
| 68 | + log.Info("mismatch on field ReplicaConfigurations", "desired", desired.ReplicaConfiguration, "actual", actual.ReplicaConfiguration) |
57 | 69 | return false
|
58 | 70 | }
|
59 | 71 | // Ignore ReplicationCluster. It is not supported in KRM API.
|
60 | 72 | // Ignore RootPassword. It is not exported.
|
61 | 73 | if !SettingsMatch(desired.Settings, actual.Settings) {
|
| 74 | + log.Info("mismatch on field Settings", "desired", desired.Settings, "actual", actual.Settings) |
62 | 75 | return false
|
63 | 76 | }
|
64 | 77 | // Ignore SqlNetworkArchitecture. It is not supported in KRM API.
|
|
0 commit comments