Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions controllers/capabilities/activedoc_threescale_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
threescaleapi "github.com/3scale/3scale-porta-go-client/client"
"github.com/getkin/kin-openapi/openapi3"
"github.com/go-logr/logr"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
corev1 "k8s.io/api/core/v1"
apimachineryerrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -100,32 +98,27 @@ func (s *ActiveDocThreescaleReconciler) Reconcile() (*threescaleapi.ActiveDoc, e
}

if remoteActiveDoc.Element.Name == nil || *remoteActiveDoc.Element.Name != s.resource.Spec.Name {
s.logger.V(1).Info("update Name", "Difference", cmp.Diff(remoteActiveDoc.Element.Name, s.resource.Spec.Name))
updatedActiveDoc.Element.Name = &s.resource.Spec.Name
update = true
}

// s.resource.Spec.SystemName is not nil (defaults are set)
if remoteActiveDoc.Element.SystemName == nil || *remoteActiveDoc.Element.SystemName != *s.resource.Spec.SystemName {
s.logger.V(1).Info("update SystemName", "Difference", cmp.Diff(remoteActiveDoc.Element.SystemName, s.resource.Spec.SystemName))
updatedActiveDoc.Element.SystemName = s.resource.Spec.SystemName
update = true
}

if s.resource.Spec.Description != nil && !reflect.DeepEqual(s.resource.Spec.Description, remoteActiveDoc.Element.Description) {
s.logger.V(1).Info("update Description", "Difference", cmp.Diff(remoteActiveDoc.Element.Description, s.resource.Spec.Description))
updatedActiveDoc.Element.Description = s.resource.Spec.Description
update = true
}

if s.resource.Spec.Published != nil && !reflect.DeepEqual(s.resource.Spec.Published, remoteActiveDoc.Element.Published) {
s.logger.V(1).Info("update Published", "Difference", cmp.Diff(remoteActiveDoc.Element.Published, s.resource.Spec.Published))
updatedActiveDoc.Element.Published = s.resource.Spec.Published
update = true
}

if s.resource.Spec.SkipSwaggerValidations != nil && !reflect.DeepEqual(s.resource.Spec.SkipSwaggerValidations, remoteActiveDoc.Element.SkipSwaggerValidations) {
s.logger.V(1).Info("update SkipSwaggerValidations", "Difference", cmp.Diff(remoteActiveDoc.Element.SkipSwaggerValidations, s.resource.Spec.SkipSwaggerValidations))
updatedActiveDoc.Element.SkipSwaggerValidations = s.resource.Spec.SkipSwaggerValidations
update = true
}
Expand All @@ -135,7 +128,6 @@ func (s *ActiveDocThreescaleReconciler) Reconcile() (*threescaleapi.ActiveDoc, e
// If desired Product ID needs to be changed to null, the update needs a different client call
if desiredProductID != nil {
if remoteActiveDoc.Element.ServiceID == nil || *desiredProductID != *remoteActiveDoc.Element.ServiceID {
s.logger.V(1).Info("update ProductID", "Difference", cmp.Diff(remoteActiveDoc.Element.ServiceID, desiredProductID))
updatedActiveDoc.Element.ServiceID = desiredProductID
update = true
}
Expand All @@ -149,8 +141,6 @@ func (s *ActiveDocThreescaleReconciler) Reconcile() (*threescaleapi.ActiveDoc, e
// Compare parsed openapi3 objects
// Avoid detecting differences from serialization
if !reflect.DeepEqual(desiredOpenapiObj, existingOpenapiObj) {
s.logger.V(1).Info("update BODY", "Difference",
cmp.Diff(desiredOpenapiObj, existingOpenapiObj, cmpopts.IgnoreUnexported(openapi3.Schema{})))
updatedActiveDoc.Element.Body = &desiredBody
update = true
}
Expand All @@ -164,7 +154,7 @@ func (s *ActiveDocThreescaleReconciler) Reconcile() (*threescaleapi.ActiveDoc, e
}

if desiredProductID == nil && remoteActiveDoc.Element.ServiceID != nil {
s.logger.V(1).Info("Remove product relationship", "ID", remoteActiveDoc.Element.ServiceID)
s.logger.V(1).Info("Remove product relationship", "ID", *remoteActiveDoc.Element.ServiceID)
_, err := s.threescaleAPIClient.UnbindActiveDocFromProduct(*remoteActiveDoc.Element.ID)
if err != nil {
return nil, err
Expand Down
Loading