Skip to content

Commit c083316

Browse files
authored
Merge pull request #82 from kcp-dev/undeprecated-ref
Undeprecate references
2 parents c19446a + efc49d2 commit c083316

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

deploy/crd/kcp.io/syncagent.kcp.io_publishedresources.yaml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,17 @@ spec:
239239
name:
240240
description: |-
241241
The name field allows to control the name the local objects created by the Sync Agent.
242-
If left empty, "$remoteNamespaceHash-$remoteNameHash" is assumed. This guarantees unique
243-
names as long as the cluster name ($remoteClusterName) is used for the local namespace
242+
If left empty, the default value is:
243+
244+
"{{ .Object.metadata.namespace | sha3short }}-{{ .Object.metadata.name | sha3short }}"
245+
246+
This guarantees unique names as long as the cluster name is used for the local namespace
244247
(the default unless configured otherwise).
245-
This is a string with placeholders. The following placeholders can be used:
248+
249+
This value is a Go template, see the documentation for the available variables and functions.
250+
251+
Alternatively (but deprecated), this value can be a simple string using one of the following
252+
placeholders:
246253
247254
- $remoteClusterName -- the kcp workspace's cluster name (e.g. "1084s8ceexsehjm2")
248255
- $remoteNamespace -- the original namespace used by the consumer inside the kcp
@@ -252,12 +259,19 @@ spec:
252259
- $remoteName -- the original name of the object inside the kcp workspace
253260
(rarely used to construct local namespace names)
254261
- $remoteNameHash -- first 20 hex characters of the SHA-1 hash of $remoteName
262+
263+
Authors are advised to use Go templates instead, as the custom variable syntax is deprecated
264+
and will be removed from a future release of the Sync Agent.
255265
type: string
256266
namespace:
257267
description: |-
258268
For namespaced resources, the this field allows to control where the local objects will
259-
be created. If left empty, "$remoteClusterName" is assumed.
260-
This is a string with placeholders. The following placeholders can be used:
269+
be created. If left empty, "{{ .ClusterName }}" is assumed.
270+
271+
This value is a Go template, see the documentation for the available variables and functions.
272+
273+
Alternatively (but deprecated), this value can be a simple string using one of the following
274+
placeholders:
261275
262276
- $remoteClusterName -- the kcp workspace's cluster name (e.g. "1084s8ceexsehjm2")
263277
- $remoteNamespace -- the original namespace used by the consumer inside the kcp
@@ -267,6 +281,9 @@ spec:
267281
- $remoteName -- the original name of the object inside the kcp workspace
268282
(rarely used to construct local namespace names)
269283
- $remoteNameHash -- first 20 hex characters of the SHA-1 hash of $remoteName
284+
285+
Authors are advised to use Go templates instead, as the custom variable syntax is deprecated
286+
and will be removed from a future release of the Sync Agent.
270287
type: string
271288
type: object
272289
projection:
@@ -438,8 +455,6 @@ spec:
438455
description: |-
439456
Reference points to a field inside the main object. This reference is
440457
evaluated on both source and destination sides to find the related object.
441-
442-
Deprecated: Use Go templates instead.
443458
properties:
444459
path:
445460
description: |-
@@ -555,8 +570,6 @@ spec:
555570
description: |-
556571
Reference points to a field inside the main object. This reference is
557572
evaluated on both source and destination sides to find the related object.
558-
559-
Deprecated: Use Go templates instead.
560573
properties:
561574
path:
562575
description: |-

internal/sync/syncer_related.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,8 @@ func resolveRelatedResourceObjects(relatedOrigin, relatedDest syncSide, relRes s
250250

251251
func resolveRelatedResourceOriginNamespaces(relatedOrigin, relatedDest syncSide, origin syncagentv1alpha1.RelatedResourceOrigin, spec syncagentv1alpha1.RelatedResourceObjectSpec) (map[string]string, error) {
252252
switch {
253-
//nolint:staticcheck // .Reference is deprecated, but we still support it for now.
254253
case spec.Reference != nil:
255-
originNamespace, err := resolveObjectReference(relatedOrigin.object, *spec.Reference) //nolint:staticcheck
254+
originNamespace, err := resolveObjectReference(relatedOrigin.object, *spec.Reference)
256255
if err != nil {
257256
return nil, err
258257
}
@@ -261,7 +260,7 @@ func resolveRelatedResourceOriginNamespaces(relatedOrigin, relatedDest syncSide,
261260
return nil, nil
262261
}
263262

264-
destNamespace, err := resolveObjectReference(relatedDest.object, *spec.Reference) //nolint:staticcheck
263+
destNamespace, err := resolveObjectReference(relatedDest.object, *spec.Reference)
265264
if err != nil {
266265
return nil, err
267266
}
@@ -368,9 +367,8 @@ func resolveRelatedResourceObjectsInNamespaces(relatedOrigin, relatedDest syncSi
368367

369368
func resolveRelatedResourceObjectsInNamespace(relatedOrigin, relatedDest syncSide, relRes syncagentv1alpha1.RelatedResourceSpec, spec syncagentv1alpha1.RelatedResourceObjectSpec, namespace string) (map[string]string, error) {
370369
switch {
371-
//nolint:staticcheck
372370
case spec.Reference != nil:
373-
originName, err := resolveObjectReference(relatedOrigin.object, *spec.Reference) //nolint:staticcheck
371+
originName, err := resolveObjectReference(relatedOrigin.object, *spec.Reference)
374372
if err != nil {
375373
return nil, err
376374
}
@@ -379,7 +377,7 @@ func resolveRelatedResourceObjectsInNamespace(relatedOrigin, relatedDest syncSid
379377
return nil, nil
380378
}
381379

382-
destName, err := resolveObjectReference(relatedDest.object, *spec.Reference) //nolint:staticcheck
380+
destName, err := resolveObjectReference(relatedDest.object, *spec.Reference)
383381
if err != nil {
384382
return nil, err
385383
}

sdk/apis/syncagent/v1alpha1/published_resource.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,17 @@ type PublishedResourceSpec struct {
102102
// ResourceNaming describes how the names for local objects should be formed.
103103
type ResourceNaming struct {
104104
// The name field allows to control the name the local objects created by the Sync Agent.
105-
// If left empty, "$remoteNamespaceHash-$remoteNameHash" is assumed. This guarantees unique
106-
// names as long as the cluster name ($remoteClusterName) is used for the local namespace
105+
// If left empty, the default value is:
106+
//
107+
// "{{ .Object.metadata.namespace | sha3short }}-{{ .Object.metadata.name | sha3short }}"
108+
//
109+
// This guarantees unique names as long as the cluster name is used for the local namespace
107110
// (the default unless configured otherwise).
108-
// This is a string with placeholders. The following placeholders can be used:
111+
//
112+
// This value is a Go template, see the documentation for the available variables and functions.
113+
//
114+
// Alternatively (but deprecated), this value can be a simple string using one of the following
115+
// placeholders:
109116
//
110117
// - $remoteClusterName -- the kcp workspace's cluster name (e.g. "1084s8ceexsehjm2")
111118
// - $remoteNamespace -- the original namespace used by the consumer inside the kcp
@@ -116,11 +123,17 @@ type ResourceNaming struct {
116123
// (rarely used to construct local namespace names)
117124
// - $remoteNameHash -- first 20 hex characters of the SHA-1 hash of $remoteName
118125
//
126+
// Authors are advised to use Go templates instead, as the custom variable syntax is deprecated
127+
// and will be removed from a future release of the Sync Agent.
119128
Name string `json:"name,omitempty"`
120129

121130
// For namespaced resources, the this field allows to control where the local objects will
122-
// be created. If left empty, "$remoteClusterName" is assumed.
123-
// This is a string with placeholders. The following placeholders can be used:
131+
// be created. If left empty, "{{ .ClusterName }}" is assumed.
132+
//
133+
// This value is a Go template, see the documentation for the available variables and functions.
134+
//
135+
// Alternatively (but deprecated), this value can be a simple string using one of the following
136+
// placeholders:
124137
//
125138
// - $remoteClusterName -- the kcp workspace's cluster name (e.g. "1084s8ceexsehjm2")
126139
// - $remoteNamespace -- the original namespace used by the consumer inside the kcp
@@ -131,6 +144,8 @@ type ResourceNaming struct {
131144
// (rarely used to construct local namespace names)
132145
// - $remoteNameHash -- first 20 hex characters of the SHA-1 hash of $remoteName
133146
//
147+
// Authors are advised to use Go templates instead, as the custom variable syntax is deprecated
148+
// and will be removed from a future release of the Sync Agent.
134149
Namespace string `json:"namespace,omitempty"`
135150
}
136151

@@ -217,8 +232,6 @@ type RelatedResourceObjectSpec struct {
217232
Selector *RelatedResourceObjectSelector `json:"selector,omitempty"`
218233
// Reference points to a field inside the main object. This reference is
219234
// evaluated on both source and destination sides to find the related object.
220-
//
221-
// Deprecated: Use Go templates instead.
222235
Reference *RelatedResourceObjectReference `json:"reference,omitempty"`
223236
// Template is a Go templated string that can make use of variables to
224237
// construct the resulting string.

0 commit comments

Comments
 (0)