File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,21 @@ func (c *Cmd) Run(k *kong.Context, log logging.Logger) error { //nolint:gocognit
159159 return errors .Wrapf (errs .ToAggregate (), "invalid Composition %q" , comp .GetName ())
160160 }
161161
162+ // check if XR's matchLabels have corresponding label at composition
163+ xrSelector := xr .GetCompositionSelector ()
164+ if xrSelector != nil {
165+ for key , value := range xrSelector .MatchLabels {
166+ compValue , exists := comp .Labels [key ]
167+ if ! exists {
168+ return fmt .Errorf ("composition %q is missing required label %q" , comp .GetName (), key )
169+ }
170+ if compValue != value {
171+ return fmt .Errorf ("composition %q has incorrect value for label %q: want %q, got %q" ,
172+ comp .GetName (), key , value , compValue )
173+ }
174+ }
175+ }
176+
162177 if m := comp .Spec .Mode ; m == nil || * m != v1 .CompositionModePipeline {
163178 return errors .Errorf ("render only supports Composition Function pipelines: Composition %q must use spec.mode: Pipeline" , comp .GetName ())
164179 }
You can’t perform that action at this time.
0 commit comments