Skip to content

Commit 2285d35

Browse files
committed
prepare to publish more than 1 version of a given GVK in a PublishedResource
On-behalf-of: @SAP [email protected]
1 parent ddfd0f7 commit 2285d35

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

sdk/apis/syncagent/v1alpha1/published_resource.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,19 @@ type TemplateExpression struct {
255255
Template string `json:"template,omitempty"`
256256
}
257257

258-
// SourceResourceDescriptor and ResourceProjection are very similar, but as we do not
259-
// want to burden service clusters with validation webhooks, it's easier to split them
260-
// into 2 structs here and rely on the schema for validation.
261-
262258
// SourceResourceDescriptor uniquely describes a resource type in the cluster.
263259
type SourceResourceDescriptor struct {
264260
// The API group of a resource, for example "storage.initroid.com".
265261
APIGroup string `json:"apiGroup"`
266-
// The API version, for example "v1beta1".
267-
Version string `json:"version"`
262+
// The API version, for example "v1beta1". Setting this field will only publish
263+
// the given version, otherwise all versions for the group/kind will be
264+
// published.
265+
//
266+
// Deprecated: Use .versions instead.
267+
Version string `json:"version,omitempty"`
268+
// Versions allows to select a subset of versions to publish. Leave empty
269+
// to publish all available versions.
270+
Versions []string `json:"versions,omitempty"`
268271
// The resource Kind, for example "Database".
269272
Kind string `json:"kind"`
270273
}
@@ -282,10 +285,17 @@ const (
282285

283286
// ResourceProjection describes how the source GVK should be modified before it's published in kcp.
284287
type ResourceProjection struct {
285-
// The API group, for example "myservice.example.com".
288+
// The API group, for example "myservice.example.com". Leave empty to not modify the API group.
286289
Group string `json:"group,omitempty"`
287-
// The API version, for example "v1beta1".
290+
// The API version, for example "v1beta1". Leave empty to not modify the version.
291+
//
292+
// This field must not be set when multiple versions have been selected.
293+
//
294+
// Deprecated: Use .versions instead.
288295
Version string `json:"version,omitempty"`
296+
// Versions allows to map API versions onto new values in kcp. Leave empty to not modify the
297+
// versions.
298+
Versions []VersionProjection `json:"versions,omitempty"`
289299
// Whether or not the resource is namespaced.
290300
// +kubebuilder:validation:Enum=Cluster;Namespaced
291301
Scope ResourceScope `json:"scope,omitempty"`
@@ -309,6 +319,11 @@ type ResourceProjection struct {
309319
Categories []string `json:"categories"` // not omitempty because we need to distinguish between [] and nil
310320
}
311321

322+
type VersionProjection struct {
323+
From string `json:"from"`
324+
To string `json:"to"`
325+
}
326+
312327
// ResourceFilter can be used to limit what resources should be included in an operation.
313328
type ResourceFilter struct {
314329
// When given, the namespace filter will be applied to a resource's namespace.

0 commit comments

Comments
 (0)