Skip to content
Open
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
52 changes: 52 additions & 0 deletions api/v1/config/crd/eno.azure.io_compositions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,59 @@ spec:
properties:
name:
type: string
labelSelector:
description: |-
A label selector is a label query over a set of resources. The result of matchLabels and
matchExpressions are ANDed. An empty label selector matches all objects. A null
label selector matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: |-
A label selector requirement is a selector that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: |-
values is an array of string values. If the operator is In or NotIn,
the values array must be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
description: |-
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, whose key field is "key", the
operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
type: object
x-kubernetes-validations:
- message: at least one of name or labelSelector must be set
rule: has(self.name) || has(self.labelSelector)
type: object
status:
properties:
Expand Down
52 changes: 52 additions & 0 deletions api/v1/config/crd/eno.azure.io_symphonies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,59 @@ spec:
properties:
name:
type: string
labelSelector:
description: |-
A label selector is a label query over a set of resources. The result of matchLabels and
matchExpressions are ANDed. An empty label selector matches all objects. A null
label selector matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: |-
A label selector requirement is a selector that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: |-
values is an array of string values. If the operator is In or NotIn,
the values array must be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
description: |-
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, whose key field is "key", the
operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
type: object
x-kubernetes-validations:
- message: at least one of name or labelSelector must be set
rule: has(self.name) || has(self.labelSelector)
type: object
type: array
type: object
Expand Down
4 changes: 3 additions & 1 deletion api/v1/synthesizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ type PodOverrides struct {
type SynthesizerStatus struct {
}

// +kubebuilder:validation:XValidation:rule="has(self.name) || has(self.labelSelector)",message="at least one of name or labelSelector must be set"
type SynthesizerRef struct {
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty"`
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
}
9 changes: 7 additions & 2 deletions api/v1/zz_generated.deepcopy.go

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

1 change: 1 addition & 0 deletions internal/controllers/liveness/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestMissingNamespace(t *testing.T) {
comp := &apiv1.Composition{}
comp.Name = "test-composition"
comp.Finalizers = []string{"eno.azure.io/cleanup"}
comp.Spec.Synthesizer = apiv1.SynthesizerRef{Name: "some-synthesizer"}
testMissingNamespace(t, comp)
})

Expand Down
1 change: 1 addition & 0 deletions internal/controllers/resourceslice/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestResourceSliceLifecycle(t *testing.T) {
comp := &apiv1.Composition{}
comp.Name = "test-1"
comp.Namespace = "default"
comp.Spec.Synthesizer = apiv1.SynthesizerRef{Name: "some-synthesizer"}
require.NoError(t, cli.Create(ctx, comp))

testutil.Eventually(t, func() bool {
Expand Down
3 changes: 3 additions & 0 deletions internal/manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,21 @@ func TestReconcilerLimitedScope(t *testing.T) {
comp1.Name = "in-namespace-with-labels"
comp1.Namespace = ns.Name
comp1.Labels = map[string]string{"testkey": "testval"}
comp1.Spec.Synthesizer = apiv1.SynthesizerRef{Name: "some-synthesizer"}
err = mgr.GetClient().Create(ctx, comp1)
require.NoError(t, err)

comp2 := &apiv1.Composition{}
comp2.Name = "in-namespace-no-labels"
comp2.Namespace = ns.Name
comp2.Spec.Synthesizer = apiv1.SynthesizerRef{Name: "some-synthesizer"}
err = mgr.GetClient().Create(ctx, comp2)
require.NoError(t, err)

comp3 := &apiv1.Composition{}
comp3.Name = "in-different-namespace"
comp3.Namespace = "default"
comp3.Spec.Synthesizer = apiv1.SynthesizerRef{Name: "some-synthesizer"}
err = mgr.GetClient().Create(ctx, comp3)
require.NoError(t, err)

Expand Down
Loading