Skip to content

Commit

Permalink
Allign after rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
mvshao committed Oct 18, 2023
1 parent d1240e1 commit 901be9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions controllers/compassmanager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ func (cm *CompassManagerReconciler) Reconcile(ctx context.Context, req ctrl.Requ

compassRuntimeID, err := cm.getRuntimeIDFromCompassMapping(req.Name, req.Namespace)

kymaLabels := kymaCR.Labels
kymaAnnotations := kymaCR.Annotations

if migrationCompassRuntimeID, ok := kymaAnnotations[AnnotationIDForMigration]; compassRuntimeID == "" && ok {
cm.Log.Infof("Configuring compass for already registered Kyma resource %s.", req.Name)
cmerr := cm.upsertCompassMappingResource(migrationCompassRuntimeID, req.Namespace, kymaLabels)
Expand All @@ -150,8 +153,6 @@ func (cm *CompassManagerReconciler) Reconcile(ctx context.Context, req ctrl.Requ
return ctrl.Result{}, errors.Wrapf(err, "failed to obtain Compass Runtime ID from Kyma resource %s", req.Name)
}

kymaLabels := kymaCR.Labels

if compassRuntimeID == "" {
newCompassRuntimeID, regErr := cm.Registrator.RegisterInCompass(createCompassRuntimeLabels(kymaLabels))
if regErr != nil {
Expand Down Expand Up @@ -280,7 +281,7 @@ func (cm *CompassManagerReconciler) getRuntimeIDFromCompassMapping(kymaName, nam
func (cm *CompassManagerReconciler) getGlobalAccountFromCompassMapping(kymaName, namespace string) (string, error) {
mappingList := &v1beta1.CompassManagerMappingList{}
labelSelector := labels.SelectorFromSet(map[string]string{
KymaNameLabel: kymaName,
LabelKymaName: kymaName,
})

err := cm.Client.List(context.Background(), mappingList, &client.ListOptions{
Expand All @@ -296,7 +297,7 @@ func (cm *CompassManagerReconciler) getGlobalAccountFromCompassMapping(kymaName,
return "", nil
}

return mappingList.Items[0].GetLabels()[GlobalAccountIDLabel], nil
return mappingList.Items[0].GetLabels()[LabelGlobalAccountID], nil
}

func (cm *CompassManagerReconciler) handleKymaDeletion(kymaName, namespace string) error {
Expand Down
4 changes: 2 additions & 2 deletions controllers/compassmanager_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ var _ = Describe("Compass Manager controller", func() {
Expect(k8sClient.Create(context.Background(), &kymaCR)).To(Succeed())

Eventually(func() bool {
label, err := getCompassMappingLabel(kymaCR.Name, ComppassIDLabel, kymaCustomResourceNamespace)
label, err := getCompassMappingCompassID(kymaCR.Name)

return err == nil && label != ""
}, clientTimeout, clientInterval).Should(BeTrue())
Expand All @@ -117,7 +117,7 @@ var _ = Describe("Compass Manager controller", func() {
Expect(k8sClient.Delete(context.Background(), &kymaCR)).To(Succeed())

Eventually(func() bool {
label, err := getCompassMappingLabel(kymaCR.Name, ComppassIDLabel, kymaCustomResourceNamespace)
label, err := getCompassMappingCompassID(kymaCR.Name)

return errors.IsNotFound(err) && label == ""
}, clientTimeout, clientInterval).Should(BeTrue())
Expand Down

0 comments on commit 901be9d

Please sign in to comment.