@@ -73,7 +73,7 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
73
73
// function-extra-resources does not know if it has requested the resources already or not.
74
74
//
75
75
// If it has and these resources are now present, proceed with verification and conversion.
76
- if req .ExtraResources == nil {
76
+ if len ( rsp . GetRequirements (). GetExtraResources ()) > 0 && req .ExtraResources == nil {
77
77
f .log .Debug ("No extra resources present, exiting" , "requirements" , rsp .GetRequirements ())
78
78
return rsp , nil
79
79
}
@@ -124,22 +124,25 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
124
124
func buildRequirements (_ * v1alpha1.Input , xr * resource.Composite ) * fnv1.Requirements {
125
125
extraResources := make (map [string ]* fnv1.ResourceSelector )
126
126
spec := xr .Resource .Object ["spec" ].(map [string ]any )
127
- for _ , permission := range spec ["permissions" ].([]any ) {
128
- for _ , principal := range permission .(map [string ]any )["principals" ].([]any ) {
129
- user , ok := principal .(map [string ]any )["user" ]
130
- if ok {
131
- extraResources [user .(string )] = & fnv1.ResourceSelector {
132
- ApiVersion : "iam.aws.upbound.io/v1beta1" ,
133
- Kind : "User" ,
134
- Match : & fnv1.ResourceSelector_MatchLabels {
135
- MatchLabels : & fnv1.MatchLabels {
136
- Labels : map [string ]string {
137
- "crossplane.io/claim-name" : user .(string ),
138
- "crossplane.io/claim-namespace" : xr .Resource .Unstructured .GetNamespace (),
139
- "s3.statnett.no/account-name" : spec ["accountRef" ].(map [string ]any )["name" ].(string ),
127
+ permissions , ok := spec ["permissions" ].([]any )
128
+ if ok {
129
+ for _ , permission := range permissions {
130
+ for _ , principal := range permission .(map [string ]any )["principals" ].([]any ) {
131
+ user , ok := principal .(map [string ]any )["user" ]
132
+ if ok {
133
+ extraResources [user .(string )] = & fnv1.ResourceSelector {
134
+ ApiVersion : "iam.aws.upbound.io/v1beta1" ,
135
+ Kind : "User" ,
136
+ Match : & fnv1.ResourceSelector_MatchLabels {
137
+ MatchLabels : & fnv1.MatchLabels {
138
+ Labels : map [string ]string {
139
+ "crossplane.io/claim-name" : user .(string ),
140
+ "crossplane.io/claim-namespace" : xr .Resource .Unstructured .GetNamespace (),
141
+ "s3.statnett.no/account-name" : spec ["accountRef" ].(map [string ]any )["name" ].(string ),
142
+ },
140
143
},
141
144
},
142
- },
145
+ }
143
146
}
144
147
}
145
148
}
0 commit comments