@@ -202,16 +202,14 @@ func (b *Builder) NewResourceGraphDefinition(originalCR *v1alpha1.ResourceGraphD
202202 }
203203 }
204204
205- // include the instance spec schema in the context as "schema". This will let us
206- // validate expressions such as ${schema.spec.someField}.
207- //
208- // not that we only include the spec and metadata fields, instance status references
209- // are not allowed in RGDs (yet)
210- schemaWithoutStatus , err := getSchemaWithoutStatus (instance .crd )
205+ // include the instance schema in the context as "schema". This will let us
206+ // validate expressions such as ${schema.spec.someField}, ${schema.metadata.name},
207+ // and ${schema.status.someField}.
208+ instanceSchema , err := getInstanceSchema (instance .crd )
211209 if err != nil {
212- return nil , fmt .Errorf ("failed to get schema without status : %w" , err )
210+ return nil , fmt .Errorf ("failed to get instance schema : %w" , err )
213211 }
214- schemas ["schema" ] = schemaWithoutStatus
212+ schemas ["schema" ] = instanceSchema
215213
216214 // First, build the dependency graph by inspecting CEL expressions.
217215 // This extracts all resource dependencies and validates that:
@@ -831,8 +829,10 @@ func validateReadyWhenExpressions(env *cel.Env, resource *Resource) error {
831829 return nil
832830}
833831
834- // getSchemaWithoutStatus returns a schema from the CRD with the status field removed.
835- func getSchemaWithoutStatus (crd * extv1.CustomResourceDefinition ) (* spec.Schema , error ) {
832+ // getInstanceSchema returns a schema from the CRD including spec, status, and metadata fields.
833+ // This schema is used for CEL expression validation, allowing references to instance fields like
834+ // ${schema.spec.field}, ${schema.status.field}, and ${schema.metadata.name}.
835+ func getInstanceSchema (crd * extv1.CustomResourceDefinition ) (* spec.Schema , error ) {
836836 crdCopy := crd .DeepCopy ()
837837
838838 // TODO(a-hilaly) expand this function when we start support CRD upgrades.
@@ -846,8 +846,6 @@ func getSchemaWithoutStatus(crd *extv1.CustomResourceDefinition) (*spec.Schema,
846846 openAPISchema .Properties = make (map [string ]extv1.JSONSchemaProps )
847847 }
848848
849- delete (openAPISchema .Properties , "status" )
850-
851849 specSchema , err := schema .ConvertJSONSchemaPropsToSpecSchema (openAPISchema )
852850 if err != nil {
853851 return nil , err
0 commit comments