From 6e623d8cb3c6af642e35654e60d445a19892347f Mon Sep 17 00:00:00 2001 From: Simon Bein Date: Wed, 8 Oct 2025 10:35:46 +0200 Subject: [PATCH] use strings instead of custom types when passing to templating This is required since functions like sha3 short expect a string to work properly and not the custom type --- internal/sync/templating/naming.go | 8 ++++---- internal/sync/templating/related.go | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/sync/templating/naming.go b/internal/sync/templating/naming.go index 46024f6..e3f76a9 100644 --- a/internal/sync/templating/naming.go +++ b/internal/sync/templating/naming.go @@ -35,16 +35,16 @@ type localObjectNamingContext struct { // Object is the full remote object found in a kcp workspace. Object map[string]any // ClusterName is the internal cluster identifier (e.g. "34hg2j4gh24jdfgf"). - ClusterName logicalcluster.Name + ClusterName string // ClusterPath is the workspace path (e.g. "root:customer:projectx"). - ClusterPath logicalcluster.Path + ClusterPath string } func newLocalObjectNamingContext(object *unstructured.Unstructured, clusterName logicalcluster.Name, workspacePath logicalcluster.Path) localObjectNamingContext { return localObjectNamingContext{ Object: object.Object, - ClusterName: clusterName, - ClusterPath: workspacePath, + ClusterName: clusterName.String(), + ClusterPath: workspacePath.String(), } } diff --git a/internal/sync/templating/related.go b/internal/sync/templating/related.go index 24f1d17..1097448 100644 --- a/internal/sync/templating/related.go +++ b/internal/sync/templating/related.go @@ -38,18 +38,18 @@ type relatedObjectContext struct { // ClusterName is the internal cluster identifier (e.g. "34hg2j4gh24jdfgf") // of the kcp workspace that the synchronization is currently processing. This // value is set for both evaluations, regardless of side. - ClusterName logicalcluster.Name + ClusterName string // ClusterPath is the workspace path (e.g. "root:customer:projectx"). This // value is set for both evaluations, regardless of side. - ClusterPath logicalcluster.Path + ClusterPath string } func NewRelatedObjectContext(object *unstructured.Unstructured, side syncagentv1alpha1.RelatedResourceOrigin, clusterName logicalcluster.Name, clusterPath logicalcluster.Path) relatedObjectContext { return relatedObjectContext{ Side: side, Object: object.Object, - ClusterName: clusterName, - ClusterPath: clusterPath, + ClusterName: clusterName.String(), + ClusterPath: clusterPath.String(), } } @@ -64,17 +64,17 @@ type relatedObjectLabelContext struct { // ClusterName is the internal cluster identifier (e.g. "34hg2j4gh24jdfgf") // of the kcp workspace that the synchronization is currently processing // (where the remote object exists). - ClusterName logicalcluster.Name + ClusterName string // ClusterPath is the workspace path (e.g. "root:customer:projectx"). - ClusterPath logicalcluster.Path + ClusterPath string } func NewRelatedObjectLabelContext(localObject, remoteObject *unstructured.Unstructured, clusterName logicalcluster.Name, clusterPath logicalcluster.Path) relatedObjectLabelContext { return relatedObjectLabelContext{ LocalObject: localObject.Object, RemoteObject: remoteObject.Object, - ClusterName: clusterName, - ClusterPath: clusterPath, + ClusterName: clusterName.String(), + ClusterPath: clusterPath.String(), } } @@ -103,9 +103,9 @@ type relatedObjectLabelRewriteContext struct { // ClusterName is the internal cluster identifier (e.g. "34hg2j4gh24jdfgf") // of the kcp workspace that the synchronization is currently processing // (where the remote object exists). - ClusterName logicalcluster.Name + ClusterName string // ClusterPath is the workspace path (e.g. "root:customer:projectx"). - ClusterPath logicalcluster.Path + ClusterPath string } func NewRelatedObjectLabelRewriteContext(value string, localObject, remoteObject, relatedObject *unstructured.Unstructured, clusterName logicalcluster.Name, clusterPath logicalcluster.Path) relatedObjectLabelRewriteContext { @@ -113,8 +113,8 @@ func NewRelatedObjectLabelRewriteContext(value string, localObject, remoteObject Value: value, LocalObject: localObject.Object, RemoteObject: remoteObject.Object, - ClusterName: clusterName, - ClusterPath: clusterPath, + ClusterName: clusterName.String(), + ClusterPath: clusterPath.String(), } if relatedObject != nil {