Skip to content

Commit b32c1c6

Browse files
committed
fix controller commands
1 parent 402799c commit b32c1c6

File tree

8 files changed

+211
-55
lines changed

8 files changed

+211
-55
lines changed

api/crds/crds.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package crds
2+
3+
import (
4+
"embed"
5+
6+
crdutil "github.com/openmcp-project/controller-utils/pkg/crds"
7+
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
8+
)
9+
10+
//go:embed manifests
11+
var CRDFS embed.FS
12+
13+
func CRDs() ([]*apiextv1.CustomResourceDefinition, error) {
14+
return crdutil.CRDsFromFileSystem(CRDFS, "manifests")
15+
}

api/crds/manifests/dns.openmcp.cloud_dnsserviceconfigs.yaml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ spec:
6161
helmValues:
6262
description: HelmValues are the helm values to deploy external-dns
6363
with, if the purpose selector matches.
64+
type: string
6465
name:
6566
description: |-
6667
Name is an optional name.
@@ -72,20 +73,18 @@ spec:
7273
If not set, all Clusters are matched.
7374
properties:
7475
and:
75-
items: {}
76+
items:
77+
type: object
7678
type: array
7779
name:
7880
type: string
79-
not: {}
81+
not:
82+
type: object
8083
or:
81-
items: {}
84+
items:
85+
type: object
8286
type: array
8387
type: object
84-
x-kubernetes-validations:
85-
- message: Exactly one of 'and', 'or', 'not' or 'name' must
86-
be set
87-
rule: size(self.filter(property, size(self[property]) > 0))
88-
== 1
8988
required:
9089
- helmValues
9190
type: object
@@ -665,11 +664,6 @@ spec:
665664
required:
666665
- chartName
667666
type: object
668-
x-kubernetes-validations:
669-
- message: Exactly one of 'helm', 'git', or 'oci' must be set
670-
rule: size(self.filter(property, (property == "helm" || property
671-
== "git" || property == "oci") && (size(self[property]) > 0)))
672-
== 1
673667
helmReleaseReconciliationInterval:
674668
description: |-
675669
HelmReleaseReconciliationInterval is the interval at which the HelmRelease for external-dns is reconciled.

api/dns/v1alpha1/config_types.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type DNSServiceConfigSpec struct {
3232
// ExternalDNSSource defines the source of the external-dns helm chart in form of a Flux source.
3333
// Exactly one of 'HelmRepository', 'GitRepository' or 'OCIRepository' must be set.
3434
// If 'copyAuthSecret' is set, the referenced source secret is copied into the namespace where the Flux resources are created with the specified target name.
35-
// +kubebuilder:validation:XValidation:rule=`size(self.filter(property, (property == "helm" || property == "git" || property == "oci") && (size(self[property]) > 0))) == 1`, message="Exactly one of 'helm', 'git', or 'oci' must be set"
35+
// +kubebuilder:validation:ExactlyOneOf=helm;git;oci
3636
type ExternalDNSSource struct {
3737
// ChartName specifies the name of the external-dns chart.
3838
// Depending on the source, this can also be a relative path within the repository.
@@ -70,6 +70,7 @@ type ExternalDNSPurposeConfig struct {
7070
HelmReleaseReconciliationInterval *metav1.Duration `json:"helmReleaseReconciliationInterval,omitempty"`
7171

7272
// HelmValues are the helm values to deploy external-dns with, if the purpose selector matches.
73+
// +kubebuilder:validation:Type=string
7374
// +kubebuilder:validation:Schemaless
7475
HelmValues *apiextensionsv1.JSON `json:"helmValues"`
7576
}
@@ -81,17 +82,23 @@ type PurposeSelector struct {
8182

8283
// PurposeSelectorRequirement is a selector to select purposes to apply the configuration to.
8384
// The struct can be combined recursively using "and", "or" and "not" to build complex selectors.
84-
// Exactly one of the fields must be set.
85+
// Exactly one of the fields must be set, otherwise only one of them is evaluated in the order: name, not, and, or.
8586
// If name is set, the selector matches if the Cluster's purposes contain the given name.
8687
// If and is set, the selector matches if all of the contained selectors match.
8788
// If or is set, the selector matches if any of the contained selectors match.
8889
// If not is set, the selector matches if the contained selector does not match.
89-
// +kubebuilder:validation:XValidation:rule=`size(self.filter(property, size(self[property]) > 0)) == 1`, message="Exactly one of 'and', 'or', 'not' or 'name' must be set"
9090
type PurposeSelectorRequirement struct {
91-
And []PurposeSelectorRequirement `json:"and,omitempty"`
92-
Or []PurposeSelectorRequirement `json:"or,omitempty"`
93-
Not *PurposeSelectorRequirement `json:"not,omitempty"`
94-
Name string `json:"name,omitempty"`
91+
// +kubebuilder:validation:items:Type=object
92+
// +optional
93+
And []PurposeSelectorRequirement `json:"and,omitempty"`
94+
// +kubebuilder:validation:items:Type=object
95+
// +optional
96+
Or []PurposeSelectorRequirement `json:"or,omitempty"`
97+
// +kubebuilder:validation:Type=object
98+
// +optional
99+
Not *PurposeSelectorRequirement `json:"not,omitempty"`
100+
// +optional
101+
Name string `json:"name,omitempty"`
95102
}
96103

97104
// +kubebuilder:object:root=true
@@ -142,6 +149,9 @@ func requirementMatches(r *PurposeSelectorRequirement, purposes []string, seenRe
142149
if r.Name != "" {
143150
return slices.Contains(purposes, r.Name)
144151
}
152+
if r.Not != nil {
153+
return !requirementMatches(r.Not, purposes, seenRequirements)
154+
}
145155
if len(r.And) > 0 {
146156
for i := range r.And {
147157
if !requirementMatches(&r.And[i], purposes, seenRequirements) {
@@ -158,8 +168,5 @@ func requirementMatches(r *PurposeSelectorRequirement, purposes []string, seenRe
158168
}
159169
return false
160170
}
161-
if r.Not != nil {
162-
return !requirementMatches(r.Not, purposes, seenRequirements)
163-
}
164171
return false
165172
}

api/go.mod

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,57 @@ require (
1212
sigs.k8s.io/controller-runtime v0.22.1
1313
)
1414

15+
require (
16+
github.com/beorn7/perks v1.0.1 // indirect
17+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
18+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
19+
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
20+
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
21+
github.com/fsnotify/fsnotify v1.9.0 // indirect
22+
github.com/go-logr/zapr v1.3.0 // indirect
23+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
24+
github.com/go-openapi/jsonreference v0.21.0 // indirect
25+
github.com/go-openapi/swag v0.23.0 // indirect
26+
github.com/google/btree v1.1.3 // indirect
27+
github.com/google/gnostic-models v0.7.0 // indirect
28+
github.com/google/go-cmp v0.7.0 // indirect
29+
github.com/google/uuid v1.6.0 // indirect
30+
github.com/josharian/intern v1.0.0 // indirect
31+
github.com/mailru/easyjson v0.9.0 // indirect
32+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
33+
github.com/pkg/errors v0.9.1 // indirect
34+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
35+
github.com/prometheus/client_golang v1.22.0 // indirect
36+
github.com/prometheus/client_model v0.6.1 // indirect
37+
github.com/prometheus/common v0.62.0 // indirect
38+
github.com/prometheus/procfs v0.15.1 // indirect
39+
github.com/spf13/pflag v1.0.9 // indirect
40+
go.uber.org/multierr v1.11.0 // indirect
41+
go.uber.org/zap v1.27.0 // indirect
42+
go.yaml.in/yaml/v3 v3.0.4 // indirect
43+
golang.org/x/oauth2 v0.27.0 // indirect
44+
golang.org/x/sync v0.16.0 // indirect
45+
golang.org/x/sys v0.35.0 // indirect
46+
golang.org/x/term v0.34.0 // indirect
47+
golang.org/x/time v0.10.0 // indirect
48+
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
49+
google.golang.org/protobuf v1.36.7 // indirect
50+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
51+
gopkg.in/yaml.v3 v3.0.1 // indirect
52+
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
53+
)
54+
1555
require (
1656
github.com/fluxcd/pkg/apis/acl v0.7.0 // indirect
17-
github.com/fluxcd/pkg/apis/kustomize v1.10.0 // indirect
57+
github.com/fluxcd/pkg/apis/kustomize v1.12.0 // indirect
1858
github.com/fluxcd/pkg/apis/meta v1.12.0 // indirect
1959
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
2060
github.com/go-logr/logr v1.4.3 // indirect
2161
github.com/gogo/protobuf v1.3.2 // indirect
2262
github.com/json-iterator/go v1.1.12 // indirect
2363
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2464
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
65+
github.com/openmcp-project/controller-utils v0.19.0
2566
github.com/x448/float16 v0.8.4 // indirect
2667
go.yaml.in/yaml/v2 v2.4.2 // indirect
2768
golang.org/x/net v0.43.0 // indirect

0 commit comments

Comments
 (0)