Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlT
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sap/go-generics v0.2.53 h1:C5MltWIx6MxpgPxQJa2eupGm3Jim4jIfwm/2KOT1BQM=
github.com/sap/go-generics v0.2.53/go.mod h1:xqWmp3jVLGNTmTuPjwdWgNk11pzi0zarA1iqV0om24c=
github.com/sap/go-generics v0.2.54 h1:NbWwKMH4w6Gmts2ilvhmKthwMbzHjJn3zDeh4940T5Q=
github.com/sap/go-generics v0.2.54/go.mod h1:xqWmp3jVLGNTmTuPjwdWgNk11pzi0zarA1iqV0om24c=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
Expand Down
10 changes: 5 additions & 5 deletions internal/kustomize/kustomization.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"k8s.io/client-go/discovery"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/kustomize/api/konfig"
kustypes "sigs.k8s.io/kustomize/api/types"
kusttypes "sigs.k8s.io/kustomize/api/types"
kustfsys "sigs.k8s.io/kustomize/kyaml/filesys"
kyaml "sigs.k8s.io/yaml"

Expand Down Expand Up @@ -408,10 +408,10 @@ func generateKustomization(fsys kustfsys.FileSystem, kustomizationPath string) (
return nil, err
}

kustomization := kustypes.Kustomization{
TypeMeta: kustypes.TypeMeta{
APIVersion: kustypes.KustomizationVersion,
Kind: kustypes.KustomizationKind,
kustomization := kusttypes.Kustomization{
TypeMeta: kusttypes.TypeMeta{
APIVersion: kusttypes.KustomizationVersion,
Kind: kusttypes.KustomizationKind,
},
Resources: resources,
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/manifests/kustomize/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
utilyaml "k8s.io/apimachinery/pkg/util/yaml"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/kustomize/api/krusty"
kustypes "sigs.k8s.io/kustomize/api/types"
kusttypes "sigs.k8s.io/kustomize/api/types"
kustfsys "sigs.k8s.io/kustomize/kyaml/filesys"

"github.com/sap/component-operator-runtime/internal/kustomize"
Expand Down Expand Up @@ -65,8 +65,8 @@ func NewKustomizeGenerator(fsys fs.FS, kustomizationPath string, _ client.Client
}

kustomizerOptions := &krusty.Options{
LoadRestrictions: kustypes.LoadRestrictionsNone,
PluginConfig: kustypes.DisabledPluginConfig(),
LoadRestrictions: kusttypes.LoadRestrictionsNone,
PluginConfig: kusttypes.DisabledPluginConfig(),
}
kustomizer := krusty.MakeKustomizer(kustomizerOptions)

Expand Down
25 changes: 25 additions & 0 deletions pkg/manifests/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/Masterminds/sprig/v3"

"sigs.k8s.io/controller-runtime/pkg/client"
kyaml "sigs.k8s.io/yaml"

"github.com/sap/component-operator-runtime/internal/templatex"
Expand Down Expand Up @@ -70,3 +71,27 @@ func (t *TemplateParameterTransformer) TransformParameters(namespace string, nam
}
return transformedParameters, nil
}

type SubstitutionObjectTransformer struct{}

var _ ObjectTransformer = &SubstitutionObjectTransformer{}

func NewSubstitutionObjectTransformer(substitutions map[string]string, selector types.Selector[client.Object]) (*SubstitutionObjectTransformer, error) {
return &SubstitutionObjectTransformer{}, nil
}

func (t *SubstitutionObjectTransformer) TransformObjects(namespace string, name string, objects []client.Object) ([]client.Object, error) {
return objects, nil
}

type KustomizeObjectTransformer struct{}

var _ ObjectTransformer = &KustomizeObjectTransformer{}

func NewKustomizeObjectTransformer(patches []KustomizePatch, images []KustomizeImage) (*KustomizeObjectTransformer, error) {
return &KustomizeObjectTransformer{}, nil
}

func (t *KustomizeObjectTransformer) TransformObjects(namespace string, name string, objects []client.Object) ([]client.Object, error) {
return objects, nil
}
31 changes: 31 additions & 0 deletions pkg/manifests/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,34 @@ type ObjectTransformer interface {
type Decryptor interface {
Decrypt(input []byte, path string) ([]byte, error)
}

// +kubebuilder:object:generate=true

// Kustomize patch specification, basically a subset of sigs.k8s.io/kustomize/api/types#Patch
type KustomizePatch struct {
Patch string `json:"patch,omitempty"`
Target *KustomizeSelector `json:"target,omitempty"`
}

// +kubebuilder:object:generate=true

// Kustomize object selector; corresponds to sigs.k8s.io/kustomize/api/types#Selector
type KustomizeSelector struct {
Group string `json:"group,omitempty"`
Version string `json:"version,omitempty"`
Kind string `json:"kind,omitempty"`
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
AnnotationSelector string `json:"annotationSelector,omitempty"`
LabelSelector string `json:"labelSelector,omitempty"`
}

// +kubebuilder:object:generate=true

// Kustomize image modifier specification, basically a subset of sigs.k8s.io/kustomize/api/types#Image
type KustomizeImage struct {
Name string `json:"name"`
NewName string `json:"newName,omitempty"`
NewTag string `json:"newTag,omitempty"`
Digest string `json:"digest,omitempty"`
}
62 changes: 62 additions & 0 deletions pkg/manifests/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions pkg/types/selector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and component-operator-runtime contributors
SPDX-License-Identifier: Apache-2.0
*/

package types

type Selector[T any] interface {
Matches(object T) bool
}

type SelectorFunc[T any] func(object T) bool

func (s SelectorFunc[T]) Matches(object T) bool {
return s(object)
}

var _ Selector[any] = SelectorFunc[any](nil)