File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,22 @@ func (c *Cmd) Run(k *kong.Context, log logging.Logger) error { //nolint:gocognit
150150 return errors .Wrapf (errs .ToAggregate (), "invalid Composition %q" , comp .GetName ())
151151 }
152152
153+ // check if XR's matchLabels have corresponding label at composition
154+ xrSelector := xr .GetCompositionSelector ()
155+ if xrSelector != nil {
156+ for key , value := range xrSelector .MatchLabels {
157+ compValue , exists := comp .Labels [key ]
158+ if ! exists {
159+ return fmt .Errorf ("composition %q is missing required label %q" , comp .GetName (), key )
160+ }
161+ fmt .Println ("compValue: " , compValue , "value: " , value )
162+ if compValue != value {
163+ return fmt .Errorf ("composition %q has incorrect value for label %q: want %q, got %q" ,
164+ comp .GetName (), key , value , compValue )
165+ }
166+ }
167+ }
168+
153169 if m := comp .Spec .Mode ; m == nil || * m != v1 .CompositionModePipeline {
154170 return errors .Errorf ("render only supports Composition Function pipelines: Composition %q must use spec.mode: Pipeline" , comp .GetName ())
155171 }
You can’t perform that action at this time.
0 commit comments