Skip to content

Commit eda7b86

Browse files
committed
split source and destination config for RR's, everything else is just confusing
This is because now, with support for label selectors, we need explicit naming on the destination side, which means the old idea of "the same thing is done on both sides to figure out the names on origin and destination" doesn't apply anymore, because the logic is now slightly different between both sides. To not ack this in the CRD will just create endless confusion. On-behalf-of: @SAP [email protected]
1 parent e8859e6 commit eda7b86

File tree

9 files changed

+393
-166
lines changed

9 files changed

+393
-166
lines changed

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

Lines changed: 163 additions & 125 deletions
Large diffs are not rendered by default.

sdk/apis/syncagent/v1alpha1/published_resource.go

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
194186
type 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.
206197
type 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.
216235
type 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

sdk/apis/syncagent/v1alpha1/zz_generated.deepcopy.go

Lines changed: 43 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/applyconfiguration/syncagent/v1alpha1/relatedresourcedestination.go

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/applyconfiguration/syncagent/v1alpha1/relatedresourcedestinationspec.go

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/applyconfiguration/syncagent/v1alpha1/relatedresourcesource.go

Lines changed: 22 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/applyconfiguration/syncagent/v1alpha1/relatedresourcesourcespec.go

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/applyconfiguration/syncagent/v1alpha1/relatedresourcespec.go

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/applyconfiguration/utils.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)