@@ -171,38 +171,29 @@ type RelatedResourceSpec struct {
171171 // ConfigMap or Secret
172172 Kind string `json:"kind"`
173173
174- // Source describes how the related resource can be found. The source expression is evaluated
175- // on both source and destination side of the sync.
174+ // Source describes how the related resource can be found on the side where it originates.
176175 Source RelatedResourceSource `json:"source"`
177176
178- // Naming is used when a label selector is used in the source expression. Since the labels do
179- // not dictate how the actual object shall be named on the destination side, and the agent also
180- // does not simply want to re-use the source side's name/namespace (these could contain private
181- // information and leak details about how the service is structured), explicit naming rules need
182- // to be provided. These naming rules are used to form the destination name/namespace for the
183- // related object.
184- // When reference-based sources are used, this field is optional as the destination name/namespace
185- // are read from the main object.
186- Naming * ResourceNaming `json:"naming"`
177+ // Destination describes where to place the copy of the object on the destination side.
178+ Destination RelatedResourceDestination `json:"destination"`
187179
188180 // Mutation configures optional transformation rules for the related resource.
189181 // Status mutations are only performed when the related resource originates in kcp.
190182 Mutation * ResourceMutationSpec `json:"mutation,omitempty"`
191183}
192184
193- // RelatedResourceSource configures how a related object can be found.
185+ // RelatedResourceSource configures how a related object can be found on its origin side .
194186type RelatedResourceSource struct {
195- // Name configures how the related object's name can be constructed or
196- // found. This must always be configured for a related resource.
197- Name RelatedResourceSourceSpec `json:"name"`
187+ RelatedResourceSourceSpec `json:",inline"`
188+
198189 // Namespace configures in what namespace the related object resides in. If
199190 // not specified, the same namespace as the main object is assumed. If the
200191 // main object is cluster-scoped, an error will be raised during syncing.
201192 Namespace * RelatedResourceSourceSpec `json:"namespace,omitempty"`
202193}
203194
204- // RelatedResourceSourceSpec configures how the related object itself or its
205- // namespace can be found. Selector and Reference are mutally exclusive.
195+ // RelatedResourceSourceSpec configures different ways an object can be located.
196+ // All fields are mutually exclusive.
206197type RelatedResourceSourceSpec struct {
207198 // Selector is a label selector that is useful if no reference is in the
208199 // main resource (i.e. if the related object links back to its parent, instead
@@ -211,8 +202,36 @@ type RelatedResourceSourceSpec struct {
211202 // Reference points to a field inside the main object. This reference is
212203 // evaluated on both source and destination sides to find the related object.
213204 Reference * RelatedResourceReference `json:"reference,omitempty"`
205+ // Expression is a Go templated string that can make use of variables to
206+ // construct the resulting string.
207+ Expression string `json:"expression,omitempty"`
208+ }
209+
210+ // RelatedResourceDestination configures where the copy of the related object on the
211+ // destination side should be created.
212+ type RelatedResourceDestination struct {
213+ RelatedResourceDestinationSpec `json:",inline"`
214+
215+ // Namespace configures in what namespace the related object should be created
216+ // in. If not specified, the same namespace as the main object is assumed.
217+ // If the main object is cluster-scoped, an error will be raised during
218+ // syncing.
219+ Namespace * RelatedResourceDestinationSpec `json:"namespace,omitempty"`
220+ }
221+
222+ // RelatedResourceDestinationSpec configures different ways an object can be located.
223+ // All fields are mutually exclusive.
224+ type RelatedResourceDestinationSpec struct {
225+ // Reference points to a field inside the main object. This reference is
226+ // evaluated on both source and destination sides to find the related object.
227+ Reference * RelatedResourceReference `json:"reference,omitempty"`
228+ // Expression is a Go templated string that can make use of variables to
229+ // construct the resulting string.
230+ Expression string `json:"expression,omitempty"`
214231}
215232
233+ // RelatedResourceReference describes a path expression that is evaluated inside
234+ // a JSON-marshalled Kubernetes object, yielding a string when evaluated.
216235type RelatedResourceReference struct {
217236 // Path is a simplified JSONPath expression like "metadata.name". A reference
218237 // must always select at least _something_ in the object, even if the value
0 commit comments