diff --git a/deploy/crd/kcp.io/syncagent.kcp.io_publishedresources.yaml b/deploy/crd/kcp.io/syncagent.kcp.io_publishedresources.yaml index 6db24cf..9fd7551 100644 --- a/deploy/crd/kcp.io/syncagent.kcp.io_publishedresources.yaml +++ b/deploy/crd/kcp.io/syncagent.kcp.io_publishedresources.yaml @@ -149,6 +149,84 @@ spec: type: object x-kubernetes-map-type: atomic type: object + mutation: + description: |- + Mutation allows to configure "rewrite rules" to modify the objects in both + directions during the synchronization. + properties: + spec: + items: + properties: + delete: + properties: + path: + type: string + required: + - path + type: object + regex: + properties: + path: + type: string + pattern: + description: |- + Pattern can be left empty to simply replace the entire value with the + replacement. + type: string + replacement: + type: string + required: + - path + type: object + template: + properties: + path: + type: string + template: + type: string + required: + - path + - template + type: object + type: object + type: array + status: + items: + properties: + delete: + properties: + path: + type: string + required: + - path + type: object + regex: + properties: + path: + type: string + pattern: + description: |- + Pattern can be left empty to simply replace the entire value with the + replacement. + type: string + replacement: + type: string + required: + - path + type: object + template: + properties: + path: + type: string + template: + type: string + required: + - path + - template + type: object + type: object + type: array + type: object naming: description: |- Naming can be used to control how the namespace and names for local objects @@ -251,6 +329,84 @@ spec: kind: description: ConfigMap or Secret type: string + mutation: + description: |- + Mutation configures optional transformation rules for the related resource. + Status mutations are only performed when the related resource originates in kcp. + properties: + spec: + items: + properties: + delete: + properties: + path: + type: string + required: + - path + type: object + regex: + properties: + path: + type: string + pattern: + description: |- + Pattern can be left empty to simply replace the entire value with the + replacement. + type: string + replacement: + type: string + required: + - path + type: object + template: + properties: + path: + type: string + template: + type: string + required: + - path + - template + type: object + type: object + type: array + status: + items: + properties: + delete: + properties: + path: + type: string + required: + - path + type: object + regex: + properties: + path: + type: string + pattern: + description: |- + Pattern can be left empty to simply replace the entire value with the + replacement. + type: string + replacement: + type: string + required: + - path + type: object + template: + properties: + path: + type: string + template: + type: string + required: + - path + - template + type: object + type: object + type: array + type: object origin: description: '"service" or "kcp"' type: string diff --git a/docs/publish-resources.md b/docs/publish-resources.md index 12e8fdb..6c1af28 100644 --- a/docs/publish-resources.md +++ b/docs/publish-resources.md @@ -150,7 +150,6 @@ spec: name: "cert-$remoteNamespaceHash-$remoteNameHash" ``` - - ### Related Resources The processing of resources on the service cluster often leads to additional resources being diff --git a/go.mod b/go.mod index 2d5a191..d948c4d 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,6 @@ require ( github.com/tidwall/gjson v1.18.0 github.com/tidwall/sjson v1.2.5 go.uber.org/zap v1.27.0 - go.xrstf.de/rudi v0.0.9 k8c.io/reconciler v0.5.0 k8s.io/api v0.31.2 k8s.io/apiextensions-apiserver v0.31.2 diff --git a/go.sum b/go.sum index deb7aaf..eca7d59 100644 --- a/go.sum +++ b/go.sum @@ -359,8 +359,6 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -go.xrstf.de/rudi v0.0.9 h1:ACTYQJcq8Kk24yPGDhApMVwGH5JrgBLQdvkrwJXUt3c= -go.xrstf.de/rudi v0.0.9/go.mod h1:ERo0X1RhWc5J8FFlNWx9i0j3ZEvrRD/YXqVvo+q1rfo= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/internal/controller/sync/controller.go b/internal/controller/sync/controller.go index 51f8778..4c9d5b4 100644 --- a/internal/controller/sync/controller.go +++ b/internal/controller/sync/controller.go @@ -93,7 +93,7 @@ func Create( } // create the syncer that holds the meat&potatoes of the synchronization logic - mutator := mutation.NewMutator(nil) // pubRes.Spec.Mutation + mutator := mutation.NewMutator(pubRes.Spec.Mutation) syncer, err := sync.NewResourceSyncer(log, localManager.GetClient(), virtualWorkspaceCluster.GetClient(), pubRes, localCRD, apiExportName, mutator, stateNamespace, agentName) if err != nil { return nil, fmt.Errorf("failed to create syncer: %w", err) diff --git a/internal/mutation/mutation.go b/internal/mutation/mutation.go index fa07ad2..ef1a566 100644 --- a/internal/mutation/mutation.go +++ b/internal/mutation/mutation.go @@ -28,7 +28,6 @@ import ( "github.com/Masterminds/sprig/v3" "github.com/tidwall/gjson" "github.com/tidwall/sjson" - "go.xrstf.de/rudi" syncagentv1alpha1 "github.com/kcp-dev/api-syncagent/sdk/apis/syncagent/v1alpha1" ) @@ -46,11 +45,6 @@ func ApplyResourceMutations(value any, mutations []syncagentv1alpha1.ResourceMut } func ApplyResourceMutation(value any, mut syncagentv1alpha1.ResourceMutation, ctx *TemplateMutationContext) (any, error) { - // for Rudi scripts we can skip all the JSON encoding/decoding - if mut.Rudi != nil { - return applyResourceRudiMigration(value, *mut.Rudi, ctx) - } - // encode current value as JSON encoded, err := json.Marshal(value) if err != nil { @@ -82,33 +76,10 @@ func applyResourceMutationToJSON(jsonData string, mut syncagentv1alpha1.Resource case mut.Regex != nil: return applyResourceRegexMutation(jsonData, *mut.Regex) default: - return "", errors.New("must use either Rudi, regex, template or delete mutation") + return "", errors.New("must use either regex, template or delete mutation") } } -func applyResourceRudiMigration(value any, mut syncagentv1alpha1.ResourceRudiMutation, ctx *TemplateMutationContext) (any, error) { - program, err := rudi.Parse("myscript", mut.Script) - if err != nil { - return nil, fmt.Errorf("invalid script: %w", err) - } - - funcs := rudi.NewBuiltInFunctions() - vars := rudi.NewVariables() - - if ctx != nil { - vars. - Set("localObj", ctx.LocalObject). - Set("remoteObj", ctx.RemoteObject) - } - - processed, _, err := program.Run(value, vars, funcs) - if err != nil { - return nil, fmt.Errorf("script failed: %w", err) - } - - return processed, nil -} - func applyResourceDeleteMutation(jsonData string, mut syncagentv1alpha1.ResourceDeleteMutation) (string, error) { jsonData, err := sjson.Delete(jsonData, mut.Path) if err != nil { diff --git a/internal/mutation/mutation_test.go b/internal/mutation/mutation_test.go index 23427e9..cdcb574 100644 --- a/internal/mutation/mutation_test.go +++ b/internal/mutation/mutation_test.go @@ -187,89 +187,6 @@ func TestApplyResourceMutation(t *testing.T) { }, expected: `{"spec":[1,3]}`, }, - - // Rudi - - { - name: "Rudi: empty script", - inputData: `{"spec":{"secretName":"foo"}}`, - mutation: syncagentv1alpha1.ResourceMutation{ - Rudi: &syncagentv1alpha1.ResourceRudiMutation{ - Script: `.`, - }, - }, - expected: `{"spec":{"secretName":"foo"}}`, - }, - { - name: "Rudi: set one new key", - inputData: `{"spec":{"secretName":"foo"}}`, - mutation: syncagentv1alpha1.ResourceMutation{ - Rudi: &syncagentv1alpha1.ResourceRudiMutation{ - Script: `(set! .foo "bar")`, - }, - }, - expected: `{"foo":"bar","spec":{"secretName":"foo"}}`, - }, - { - name: "Rudi: update existing key", - inputData: `{"spec":{"secretName":"foo"}}`, - mutation: syncagentv1alpha1.ResourceMutation{ - Rudi: &syncagentv1alpha1.ResourceRudiMutation{ - Script: `(set! .spec.secretName "bar")`, - }, - }, - expected: `{"spec":{"secretName":"bar"}}`, - }, - { - name: "Rudi: remove a key", - inputData: `{"spec":{"secretName":"foo"}}`, - mutation: syncagentv1alpha1.ResourceMutation{ - Rudi: &syncagentv1alpha1.ResourceRudiMutation{ - Script: `(delete! .spec.secretName)`, - }, - }, - expected: `{"spec":{}}`, - }, - { - name: "Rudi: result value is ignored, only document counts", - inputData: `{"spec":{"secretName":"foo"}}`, - mutation: syncagentv1alpha1.ResourceMutation{ - Rudi: &syncagentv1alpha1.ResourceRudiMutation{ - Script: `(delete! .spec.secretName) false`, - }, - }, - expected: `{"spec":{}}`, - }, - { - name: "Rudi: local object becomes $localObj", - inputData: `{"spec":{"secretName":"foo"}}`, - mutation: syncagentv1alpha1.ResourceMutation{ - Rudi: &syncagentv1alpha1.ResourceRudiMutation{ - Script: `(set! .spec $localObj.local)`, - }, - }, - ctx: &TemplateMutationContext{ - LocalObject: map[string]any{ - "local": "data", - }, - }, - expected: `{"spec":"data"}`, - }, - { - name: "Rudi: remote object becomes $remoteObj", - inputData: `{"spec":{"secretName":"foo"}}`, - mutation: syncagentv1alpha1.ResourceMutation{ - Rudi: &syncagentv1alpha1.ResourceRudiMutation{ - Script: `(set! .spec $remoteObj.remote)`, - }, - }, - ctx: &TemplateMutationContext{ - RemoteObject: map[string]any{ - "remote": "data", - }, - }, - expected: `{"spec":"data"}`, - }, } for _, testcase := range testcases { diff --git a/internal/sync/syncer_related.go b/internal/sync/syncer_related.go index 87d3978..fd4155c 100644 --- a/internal/sync/syncer_related.go +++ b/internal/sync/syncer_related.go @@ -150,7 +150,7 @@ func (s *ResourceSyncer) processRelatedResource(log *zap.SugaredLogger, stateSto // sure we can clean up properly blockSourceDeletion: relRes.Origin == "kcp", // apply mutation rules configured for the related resource - mutator: mutation.NewMutator(nil), // relRes.Mutation + mutator: mutation.NewMutator(relRes.Mutation), } requeue, err = syncer.Sync(log, sourceSide, destSide) diff --git a/sdk/apis/syncagent/v1alpha1/published_resource.go b/sdk/apis/syncagent/v1alpha1/published_resource.go index 8cd6e03..1abe61a 100644 --- a/sdk/apis/syncagent/v1alpha1/published_resource.go +++ b/sdk/apis/syncagent/v1alpha1/published_resource.go @@ -85,9 +85,7 @@ type PublishedResourceSpec struct { // Mutation allows to configure "rewrite rules" to modify the objects in both // directions during the synchronization. - // This is currently disabled in order not to introduce too much freedom in the MVP - // and instead rely on Crossplane or other solutions. - // Mutation *ResourceMutationSpec `json:"mutation,omitempty"` + Mutation *ResourceMutationSpec `json:"mutation,omitempty"` Related []RelatedResourceSpec `json:"related,omitempty"` } @@ -138,16 +136,11 @@ type ResourceMutation struct { // Must use exactly one of these options, never more, never fewer. // TODO: Add validation code for this somewhere. - Rudi *ResourceRudiMutation `json:"rudi,omitempty"` Delete *ResourceDeleteMutation `json:"delete,omitempty"` Regex *ResourceRegexMutation `json:"regex,omitempty"` Template *ResourceTemplateMutation `json:"template,omitempty"` } -type ResourceRudiMutation struct { - Script string `json:"script"` -} - type ResourceDeleteMutation struct { Path string `json:"path"` } @@ -181,9 +174,8 @@ type RelatedResourceSpec struct { Reference RelatedResourceReference `json:"reference"` // Mutation configures optional transformation rules for the related resource. - // Status mutations are not supported and are ignored. - // This is disabled for the same reason the mutations for the main resource are disabled. - // Mutation *ResourceMutationSpec `json:"mutation,omitempty"` + // Status mutations are only performed when the related resource originates in kcp. + Mutation *ResourceMutationSpec `json:"mutation,omitempty"` } type RelatedResourceReference struct { diff --git a/sdk/apis/syncagent/v1alpha1/zz_generated.deepcopy.go b/sdk/apis/syncagent/v1alpha1/zz_generated.deepcopy.go index bc5e7eb..6ee4a74 100644 --- a/sdk/apis/syncagent/v1alpha1/zz_generated.deepcopy.go +++ b/sdk/apis/syncagent/v1alpha1/zz_generated.deepcopy.go @@ -103,6 +103,11 @@ func (in *PublishedResourceSpec) DeepCopyInto(out *PublishedResourceSpec) { *out = new(ResourceProjection) (*in).DeepCopyInto(*out) } + if in.Mutation != nil { + in, out := &in.Mutation, &out.Mutation + *out = new(ResourceMutationSpec) + (*in).DeepCopyInto(*out) + } if in.Related != nil { in, out := &in.Related, &out.Related *out = make([]RelatedResourceSpec, len(*in)) @@ -177,6 +182,11 @@ func (in *RelatedResourceReference) DeepCopy() *RelatedResourceReference { func (in *RelatedResourceSpec) DeepCopyInto(out *RelatedResourceSpec) { *out = *in in.Reference.DeepCopyInto(&out.Reference) + if in.Mutation != nil { + in, out := &in.Mutation, &out.Mutation + *out = new(ResourceMutationSpec) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RelatedResourceSpec. @@ -252,11 +262,6 @@ func (in *ResourceLocator) DeepCopy() *ResourceLocator { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceMutation) DeepCopyInto(out *ResourceMutation) { *out = *in - if in.Rudi != nil { - in, out := &in.Rudi, &out.Rudi - *out = new(ResourceRudiMutation) - **out = **in - } if in.Delete != nil { in, out := &in.Delete, &out.Delete *out = new(ResourceDeleteMutation) @@ -368,21 +373,6 @@ func (in *ResourceRegexMutation) DeepCopy() *ResourceRegexMutation { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceRudiMutation) DeepCopyInto(out *ResourceRudiMutation) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceRudiMutation. -func (in *ResourceRudiMutation) DeepCopy() *ResourceRudiMutation { - if in == nil { - return nil - } - out := new(ResourceRudiMutation) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceTemplateMutation) DeepCopyInto(out *ResourceTemplateMutation) { *out = *in diff --git a/sdk/applyconfiguration/syncagent/v1alpha1/publishedresourcespec.go b/sdk/applyconfiguration/syncagent/v1alpha1/publishedresourcespec.go index e242b4a..c9a9697 100644 --- a/sdk/applyconfiguration/syncagent/v1alpha1/publishedresourcespec.go +++ b/sdk/applyconfiguration/syncagent/v1alpha1/publishedresourcespec.go @@ -26,6 +26,7 @@ type PublishedResourceSpecApplyConfiguration struct { Naming *ResourceNamingApplyConfiguration `json:"naming,omitempty"` EnableWorkspacePaths *bool `json:"enableWorkspacePaths,omitempty"` Projection *ResourceProjectionApplyConfiguration `json:"projection,omitempty"` + Mutation *ResourceMutationSpecApplyConfiguration `json:"mutation,omitempty"` Related []RelatedResourceSpecApplyConfiguration `json:"related,omitempty"` } @@ -75,6 +76,14 @@ func (b *PublishedResourceSpecApplyConfiguration) WithProjection(value *Resource return b } +// WithMutation sets the Mutation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Mutation field is set to the value of the last call. +func (b *PublishedResourceSpecApplyConfiguration) WithMutation(value *ResourceMutationSpecApplyConfiguration) *PublishedResourceSpecApplyConfiguration { + b.Mutation = value + return b +} + // WithRelated adds the given value to the Related field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the Related field. diff --git a/sdk/applyconfiguration/syncagent/v1alpha1/relatedresourcespec.go b/sdk/applyconfiguration/syncagent/v1alpha1/relatedresourcespec.go index 3eb9eb8..3ac0143 100644 --- a/sdk/applyconfiguration/syncagent/v1alpha1/relatedresourcespec.go +++ b/sdk/applyconfiguration/syncagent/v1alpha1/relatedresourcespec.go @@ -25,6 +25,7 @@ type RelatedResourceSpecApplyConfiguration struct { Origin *string `json:"origin,omitempty"` Kind *string `json:"kind,omitempty"` Reference *RelatedResourceReferenceApplyConfiguration `json:"reference,omitempty"` + Mutation *ResourceMutationSpecApplyConfiguration `json:"mutation,omitempty"` } // RelatedResourceSpecApplyConfiguration constructs a declarative configuration of the RelatedResourceSpec type for use with @@ -64,3 +65,11 @@ func (b *RelatedResourceSpecApplyConfiguration) WithReference(value *RelatedReso b.Reference = value return b } + +// WithMutation sets the Mutation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Mutation field is set to the value of the last call. +func (b *RelatedResourceSpecApplyConfiguration) WithMutation(value *ResourceMutationSpecApplyConfiguration) *RelatedResourceSpecApplyConfiguration { + b.Mutation = value + return b +} diff --git a/sdk/applyconfiguration/syncagent/v1alpha1/resourcedeletemutation.go b/sdk/applyconfiguration/syncagent/v1alpha1/resourcedeletemutation.go new file mode 100644 index 0000000..9a88dba --- /dev/null +++ b/sdk/applyconfiguration/syncagent/v1alpha1/resourcedeletemutation.go @@ -0,0 +1,39 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// ResourceDeleteMutationApplyConfiguration represents a declarative configuration of the ResourceDeleteMutation type for use +// with apply. +type ResourceDeleteMutationApplyConfiguration struct { + Path *string `json:"path,omitempty"` +} + +// ResourceDeleteMutationApplyConfiguration constructs a declarative configuration of the ResourceDeleteMutation type for use with +// apply. +func ResourceDeleteMutation() *ResourceDeleteMutationApplyConfiguration { + return &ResourceDeleteMutationApplyConfiguration{} +} + +// WithPath sets the Path field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Path field is set to the value of the last call. +func (b *ResourceDeleteMutationApplyConfiguration) WithPath(value string) *ResourceDeleteMutationApplyConfiguration { + b.Path = &value + return b +} diff --git a/sdk/applyconfiguration/syncagent/v1alpha1/resourcemutation.go b/sdk/applyconfiguration/syncagent/v1alpha1/resourcemutation.go new file mode 100644 index 0000000..da33a22 --- /dev/null +++ b/sdk/applyconfiguration/syncagent/v1alpha1/resourcemutation.go @@ -0,0 +1,57 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// ResourceMutationApplyConfiguration represents a declarative configuration of the ResourceMutation type for use +// with apply. +type ResourceMutationApplyConfiguration struct { + Delete *ResourceDeleteMutationApplyConfiguration `json:"delete,omitempty"` + Regex *ResourceRegexMutationApplyConfiguration `json:"regex,omitempty"` + Template *ResourceTemplateMutationApplyConfiguration `json:"template,omitempty"` +} + +// ResourceMutationApplyConfiguration constructs a declarative configuration of the ResourceMutation type for use with +// apply. +func ResourceMutation() *ResourceMutationApplyConfiguration { + return &ResourceMutationApplyConfiguration{} +} + +// WithDelete sets the Delete field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Delete field is set to the value of the last call. +func (b *ResourceMutationApplyConfiguration) WithDelete(value *ResourceDeleteMutationApplyConfiguration) *ResourceMutationApplyConfiguration { + b.Delete = value + return b +} + +// WithRegex sets the Regex field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Regex field is set to the value of the last call. +func (b *ResourceMutationApplyConfiguration) WithRegex(value *ResourceRegexMutationApplyConfiguration) *ResourceMutationApplyConfiguration { + b.Regex = value + return b +} + +// WithTemplate sets the Template field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Template field is set to the value of the last call. +func (b *ResourceMutationApplyConfiguration) WithTemplate(value *ResourceTemplateMutationApplyConfiguration) *ResourceMutationApplyConfiguration { + b.Template = value + return b +} diff --git a/sdk/applyconfiguration/syncagent/v1alpha1/resourcemutationspec.go b/sdk/applyconfiguration/syncagent/v1alpha1/resourcemutationspec.go new file mode 100644 index 0000000..60dce42 --- /dev/null +++ b/sdk/applyconfiguration/syncagent/v1alpha1/resourcemutationspec.go @@ -0,0 +1,58 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// ResourceMutationSpecApplyConfiguration represents a declarative configuration of the ResourceMutationSpec type for use +// with apply. +type ResourceMutationSpecApplyConfiguration struct { + Spec []ResourceMutationApplyConfiguration `json:"spec,omitempty"` + Status []ResourceMutationApplyConfiguration `json:"status,omitempty"` +} + +// ResourceMutationSpecApplyConfiguration constructs a declarative configuration of the ResourceMutationSpec type for use with +// apply. +func ResourceMutationSpec() *ResourceMutationSpecApplyConfiguration { + return &ResourceMutationSpecApplyConfiguration{} +} + +// WithSpec adds the given value to the Spec field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Spec field. +func (b *ResourceMutationSpecApplyConfiguration) WithSpec(values ...*ResourceMutationApplyConfiguration) *ResourceMutationSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithSpec") + } + b.Spec = append(b.Spec, *values[i]) + } + return b +} + +// WithStatus adds the given value to the Status field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Status field. +func (b *ResourceMutationSpecApplyConfiguration) WithStatus(values ...*ResourceMutationApplyConfiguration) *ResourceMutationSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithStatus") + } + b.Status = append(b.Status, *values[i]) + } + return b +} diff --git a/sdk/applyconfiguration/syncagent/v1alpha1/resourceregexmutation.go b/sdk/applyconfiguration/syncagent/v1alpha1/resourceregexmutation.go new file mode 100644 index 0000000..7ee07b0 --- /dev/null +++ b/sdk/applyconfiguration/syncagent/v1alpha1/resourceregexmutation.go @@ -0,0 +1,57 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// ResourceRegexMutationApplyConfiguration represents a declarative configuration of the ResourceRegexMutation type for use +// with apply. +type ResourceRegexMutationApplyConfiguration struct { + Path *string `json:"path,omitempty"` + Pattern *string `json:"pattern,omitempty"` + Replacement *string `json:"replacement,omitempty"` +} + +// ResourceRegexMutationApplyConfiguration constructs a declarative configuration of the ResourceRegexMutation type for use with +// apply. +func ResourceRegexMutation() *ResourceRegexMutationApplyConfiguration { + return &ResourceRegexMutationApplyConfiguration{} +} + +// WithPath sets the Path field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Path field is set to the value of the last call. +func (b *ResourceRegexMutationApplyConfiguration) WithPath(value string) *ResourceRegexMutationApplyConfiguration { + b.Path = &value + return b +} + +// WithPattern sets the Pattern field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Pattern field is set to the value of the last call. +func (b *ResourceRegexMutationApplyConfiguration) WithPattern(value string) *ResourceRegexMutationApplyConfiguration { + b.Pattern = &value + return b +} + +// WithReplacement sets the Replacement field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Replacement field is set to the value of the last call. +func (b *ResourceRegexMutationApplyConfiguration) WithReplacement(value string) *ResourceRegexMutationApplyConfiguration { + b.Replacement = &value + return b +} diff --git a/sdk/applyconfiguration/syncagent/v1alpha1/resourcetemplatemutation.go b/sdk/applyconfiguration/syncagent/v1alpha1/resourcetemplatemutation.go new file mode 100644 index 0000000..2630631 --- /dev/null +++ b/sdk/applyconfiguration/syncagent/v1alpha1/resourcetemplatemutation.go @@ -0,0 +1,48 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// ResourceTemplateMutationApplyConfiguration represents a declarative configuration of the ResourceTemplateMutation type for use +// with apply. +type ResourceTemplateMutationApplyConfiguration struct { + Path *string `json:"path,omitempty"` + Template *string `json:"template,omitempty"` +} + +// ResourceTemplateMutationApplyConfiguration constructs a declarative configuration of the ResourceTemplateMutation type for use with +// apply. +func ResourceTemplateMutation() *ResourceTemplateMutationApplyConfiguration { + return &ResourceTemplateMutationApplyConfiguration{} +} + +// WithPath sets the Path field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Path field is set to the value of the last call. +func (b *ResourceTemplateMutationApplyConfiguration) WithPath(value string) *ResourceTemplateMutationApplyConfiguration { + b.Path = &value + return b +} + +// WithTemplate sets the Template field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Template field is set to the value of the last call. +func (b *ResourceTemplateMutationApplyConfiguration) WithTemplate(value string) *ResourceTemplateMutationApplyConfiguration { + b.Template = &value + return b +} diff --git a/sdk/applyconfiguration/utils.go b/sdk/applyconfiguration/utils.go index 57bd7a0..2b1822b 100644 --- a/sdk/applyconfiguration/utils.go +++ b/sdk/applyconfiguration/utils.go @@ -46,14 +46,24 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &syncagentv1alpha1.RelatedResourceReferenceApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("RelatedResourceSpec"): return &syncagentv1alpha1.RelatedResourceSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ResourceDeleteMutation"): + return &syncagentv1alpha1.ResourceDeleteMutationApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("ResourceFilter"): return &syncagentv1alpha1.ResourceFilterApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("ResourceLocator"): return &syncagentv1alpha1.ResourceLocatorApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ResourceMutation"): + return &syncagentv1alpha1.ResourceMutationApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ResourceMutationSpec"): + return &syncagentv1alpha1.ResourceMutationSpecApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("ResourceNaming"): return &syncagentv1alpha1.ResourceNamingApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("ResourceProjection"): return &syncagentv1alpha1.ResourceProjectionApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ResourceRegexMutation"): + return &syncagentv1alpha1.ResourceRegexMutationApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ResourceTemplateMutation"): + return &syncagentv1alpha1.ResourceTemplateMutationApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("SourceResourceDescriptor"): return &syncagentv1alpha1.SourceResourceDescriptorApplyConfiguration{}