@@ -658,9 +658,9 @@ func TestRunFunction(t *testing.T) {
658
658
Environment : & v1beta1.Environment {
659
659
Patches : []v1beta1.EnvironmentPatch {
660
660
{
661
- Type : v1beta1 .PatchTypeFromEnvironmentFieldPath ,
661
+ Type : v1beta1 .PatchTypeToCompositeFieldPath ,
662
662
Patch : v1beta1.Patch {
663
- FromFieldPath : ptr.To [string ]("data. widgets" ),
663
+ FromFieldPath : ptr.To [string ]("widgets" ),
664
664
ToFieldPath : ptr.To [string ]("spec.watchers" ),
665
665
Transforms : []v1beta1.Transform {
666
666
{
@@ -713,10 +713,10 @@ func TestRunFunction(t *testing.T) {
713
713
Environment : & v1beta1.Environment {
714
714
Patches : []v1beta1.EnvironmentPatch {
715
715
{
716
- Type : v1beta1 .PatchTypeToEnvironmentFieldPath ,
716
+ Type : v1beta1 .PatchTypeFromCompositeFieldPath ,
717
717
Patch : v1beta1.Patch {
718
718
FromFieldPath : ptr.To [string ]("spec.watchers" ),
719
- ToFieldPath : ptr.To [string ]("data. widgets" ),
719
+ ToFieldPath : ptr.To [string ]("widgets" ),
720
720
Transforms : []v1beta1.Transform {
721
721
{
722
722
Type : v1beta1 .TransformTypeMath ,
@@ -764,7 +764,7 @@ func TestRunFunction(t *testing.T) {
764
764
Patches : []v1beta1.ComposedPatch {{
765
765
Type : v1beta1 .PatchTypeFromEnvironmentFieldPath ,
766
766
Patch : v1beta1.Patch {
767
- FromFieldPath : ptr.To [string ]("data. widgets" ),
767
+ FromFieldPath : ptr.To [string ]("widgets" ),
768
768
ToFieldPath : ptr.To [string ]("spec.watchers" ),
769
769
Transforms : []v1beta1.Transform {{
770
770
Type : v1beta1 .TransformTypeConvert ,
@@ -816,7 +816,7 @@ func TestRunFunction(t *testing.T) {
816
816
Patches : []v1beta1.ComposedPatch {{
817
817
Type : v1beta1 .PatchTypeFromEnvironmentFieldPath ,
818
818
Patch : v1beta1.Patch {
819
- FromFieldPath : ptr.To [string ]("data. widgets" ),
819
+ FromFieldPath : ptr.To [string ]("widgets" ),
820
820
ToFieldPath : ptr.To [string ]("spec.watchers" ),
821
821
Transforms : []v1beta1.Transform {{
822
822
Type : v1beta1 .TransformTypeConvert ,
@@ -872,7 +872,7 @@ func TestRunFunction(t *testing.T) {
872
872
Patches : []v1beta1.ComposedPatch {{
873
873
Type : v1beta1 .PatchTypeFromEnvironmentFieldPath ,
874
874
Patch : v1beta1.Patch {
875
- FromFieldPath : ptr.To [string ]("data. widgets" ),
875
+ FromFieldPath : ptr.To [string ]("widgets" ),
876
876
ToFieldPath : ptr.To [string ]("spec.watchers" ),
877
877
Transforms : []v1beta1.Transform {{
878
878
Type : v1beta1 .TransformTypeConvert ,
@@ -937,18 +937,16 @@ func TestRunFunction(t *testing.T) {
937
937
}
938
938
939
939
// Crossplane sends as context a fake resource:
940
- // { "apiVersion": "internal.crossplane.io/v1alpha1", "kind": "Environment", "data": { ... the actual environment content ...} }
940
+ // { "apiVersion": "internal.crossplane.io/v1alpha1", "kind": "Environment", ... the actual environment content ... }
941
941
// See: https://github.com/crossplane/crossplane/blob/806f0d20d146f6f4f1735c5ec6a7dc78923814b3/internal/controller/apiextensions/composite/environment_fetcher.go#L85C1-L85C1
942
942
// That's because the patching code expects a resource to be able to use
943
943
// runtime.DefaultUnstructuredConverter.FromUnstructured to convert it back to
944
- // an object. This is also why all patches need to specify the full path from data.
944
+ // an object.
945
945
func contextWithEnvironment (data map [string ]interface {}) * structpb.Struct {
946
946
if data == nil {
947
947
data = map [string ]interface {}{}
948
948
}
949
- u := unstructured.Unstructured {Object : map [string ]interface {}{
950
- "data" : data ,
951
- }}
949
+ u := unstructured.Unstructured {Object : data }
952
950
u .SetGroupVersionKind (schema.GroupVersionKind {Group : "internal.crossplane.io" , Version : "v1alpha1" , Kind : "Environment" })
953
951
d , err := structpb .NewStruct (u .UnstructuredContent ())
954
952
if err != nil {
0 commit comments