Skip to content

Commit

Permalink
issue-729, PG cluster configurations added to sync job
Browse files Browse the repository at this point in the history
  • Loading branch information
worryg0d committed Feb 29, 2024
1 parent 285d710 commit de70522
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 104 deletions.
14 changes: 7 additions & 7 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"filename": "apis/clusterresources/v1beta1/structs.go",
"hashed_secret": "e03127a337f643c1c0eb2b0e8683e9140e19120d",
"is_verified": false,
"line_number": 65
"line_number": 57
}
],
"apis/clusterresources/v1beta1/zz_generated.deepcopy.go": [
Expand All @@ -156,7 +156,7 @@
"filename": "apis/clusterresources/v1beta1/zz_generated.deepcopy.go",
"hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c",
"is_verified": false,
"line_number": 548
"line_number": 547
}
],
"apis/clusters/v1beta1/cadence_types.go": [
Expand Down Expand Up @@ -301,21 +301,21 @@
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 369
"line_number": 370
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "a3d7d4a96d18c8fc5a1cf9c9c01c45b4690b4008",
"is_verified": false,
"line_number": 375
"line_number": 376
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/postgresql_types.go",
"hashed_secret": "a57ce131bd944bdf8ba2f2f93e179dc416ed0315",
"is_verified": false,
"line_number": 438
"line_number": 439
}
],
"apis/clusters/v1beta1/redis_types.go": [
Expand Down Expand Up @@ -556,7 +556,7 @@
"filename": "controllers/clusters/postgresql_controller.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 1221
"line_number": 1202
}
],
"controllers/clusters/zookeeper_controller_test.go": [
Expand Down Expand Up @@ -1128,5 +1128,5 @@
}
]
},
"generated_at": "2024-02-28T14:20:52Z"
"generated_at": "2024-02-29T10:26:26Z"
}
8 changes: 0 additions & 8 deletions apis/clusterresources/v1beta1/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package v1beta1

import (
"encoding/json"

"github.com/instaclustr/operator/pkg/apiextensions"

"k8s.io/apimachinery/pkg/types"
Expand All @@ -38,12 +36,6 @@ type PeeringStatus struct {
CDCID string `json:"cdcId,omitempty"`
}

type PatchRequest struct {
Operation string `json:"op"`
Path string `json:"path"`
Value json.RawMessage `json:"value"`
}

type FirewallRuleSpec struct {
ClusterID string `json:"clusterId,omitempty"`
Type string `json:"type"`
Expand Down
21 changes: 0 additions & 21 deletions apis/clusterresources/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 19 additions & 3 deletions apis/clusters/v1beta1/postgresql_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ func (pgs *PgSpec) IsEqual(iPG PgSpec) bool {
return pgs.GenericClusterSpec.Equals(&iPG.GenericClusterSpec) &&
pgs.SynchronousModeStrict == iPG.SynchronousModeStrict &&
pgs.DCsEqual(iPG.DataCentres) &&
slices.EqualsUnordered(pgs.Extensions, iPG.Extensions)
slices.EqualsUnordered(pgs.Extensions, iPG.Extensions) &&
pgs.ClusterConfigurationsEqual(iPG.ClusterConfigurations)
}

func (pgs *PgSpec) DCsEqual(instaModels []*PgDataCentre) bool {
Expand Down Expand Up @@ -550,10 +551,10 @@ func (pdc *PgDataCentre) PGBouncerFromInstAPI(instaModels []*models.PGBouncer) {
}
}

func (pgs *PgSpec) ClusterConfigurationsFromInstAPI(instaModels []*models.ClusterConfigurations) {
func (pgs *PgSpec) ClusterConfigurationsFromInstAPI(instaModels []*models.ConfigurationProperties) {
pgs.ClusterConfigurations = make(map[string]string, len(instaModels))
for _, instaModel := range instaModels {
pgs.ClusterConfigurations[instaModel.ParameterName] = instaModel.ParameterValue
pgs.ClusterConfigurations[instaModel.Name] = instaModel.Value
}
}

Expand Down Expand Up @@ -595,3 +596,18 @@ func (pgs *PgStatus) DCsEqual(o []*PgDataCentreStatus) bool {

return true
}

func (pgs *PgSpec) ClusterConfigurationsEqual(configs map[string]string) bool {
if len(pgs.ClusterConfigurations) != len(configs) {
return false
}

for k, v := range pgs.ClusterConfigurations {
param, ok := configs[k]
if !ok || v != param {
return false
}
}

return true
}
Loading

0 comments on commit de70522

Please sign in to comment.