From 6cafb0fe4566fce75a8ce946e22047859905a209 Mon Sep 17 00:00:00 2001 From: Nicolas Bigler Date: Mon, 21 Mar 2022 16:33:31 +0100 Subject: [PATCH] Fix wrong retrieval of the cluster_name when creating a new binding Signed-off-by: Nicolas Bigler --- pkg/crossplane/service_mariadb_database.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/crossplane/service_mariadb_database.go b/pkg/crossplane/service_mariadb_database.go index e11cc34..b86c6e5 100644 --- a/pkg/crossplane/service_mariadb_database.go +++ b/pkg/crossplane/service_mariadb_database.go @@ -96,7 +96,11 @@ func (msb MariadbDatabaseServiceBinder) Bind(ctx context.Context, bindingID stri return nil, err } - cn := msb.instance.GetClusterName() + parent := composite.New(composite.WithGroupVersionKind(mariaDBGroupVersionKind)) + if err := msb.cp.client.Get(ctx, types.NamespacedName{Name: msb.instance.Labels.ParentID}, parent); err != nil { + return nil, fmt.Errorf("Could not get parent instance: %w", err) + } + cn := parent.GetLabels()["service.syn.tools/cluster"] creds := createCredentials(endpoint, bindingID, pw, msb.instance.ID(), cn, msb.cp.config.EnableMetrics, msb.cp.config.MetricsDomain) return creds, nil