@@ -887,7 +887,7 @@ func (f *Function) validateAndPrepareInput(_ context.Context, req *fnv1.RunFunct
887887 return true
888888}
889889
890- // processReferences handles resolving references like groupRef, groupsRef, and usersRef
890+ // processReferences handles resolving references like groupRef, groupsRef, usersRef, and servicePrincipalsRef
891891func (f * Function ) processReferences (req * fnv1.RunFunctionRequest , in * v1beta1.Input , rsp * fnv1.RunFunctionResponse ) bool {
892892 // Process references based on query type
893893 switch in .QueryType {
@@ -897,6 +897,8 @@ func (f *Function) processReferences(req *fnv1.RunFunctionRequest, in *v1beta1.I
897897 return f .processGroupsRef (req , in , rsp )
898898 case "UserValidation" :
899899 return f .processUsersRef (req , in , rsp )
900+ case "ServicePrincipalDetails" :
901+ return f .processServicePrincipalsRef (req , in , rsp )
900902 }
901903 return true
902904}
@@ -949,6 +951,22 @@ func (f *Function) processUsersRef(req *fnv1.RunFunctionRequest, in *v1beta1.Inp
949951 return true
950952}
951953
954+ // processServicePrincipalsRef handles resolving the servicePrincipalsRef reference for ServicePrincipalDetails query type
955+ func (f * Function ) processServicePrincipalsRef (req * fnv1.RunFunctionRequest , in * v1beta1.Input , rsp * fnv1.RunFunctionResponse ) bool {
956+ if in .ServicePrincipalsRef == nil || * in .ServicePrincipalsRef == "" {
957+ return true
958+ }
959+
960+ spNames , err := f .resolveServicePrincipalsRef (req , in .ServicePrincipalsRef )
961+ if err != nil {
962+ response .Fatal (rsp , err )
963+ return false
964+ }
965+ in .ServicePrincipals = spNames
966+ f .log .Info ("Resolved ServicePrincipalsRef to service principals" , "spCount" , len (spNames ), "servicePrincipalsRef" , * in .ServicePrincipalsRef )
967+ return true
968+ }
969+
952970// executeAndProcessQuery executes the query and processes the results
953971func (f * Function ) executeAndProcessQuery (ctx context.Context , req * fnv1.RunFunctionRequest , in * v1beta1.Input , azureCreds map [string ]string , rsp * fnv1.RunFunctionResponse ) bool {
954972 // Execute the query
@@ -1114,6 +1132,11 @@ func (f *Function) resolveUsersRef(req *fnv1.RunFunctionRequest, usersRef *strin
11141132 return f .resolveStringArrayRef (req , usersRef , "usersRef" )
11151133}
11161134
1135+ // resolveServicePrincipalsRef resolves a list of service principal names from a reference in status or context
1136+ func (f * Function ) resolveServicePrincipalsRef (req * fnv1.RunFunctionRequest , servicePrincipalsRef * string ) ([]* string , error ) {
1137+ return f .resolveStringArrayRef (req , servicePrincipalsRef , "servicePrincipalsRef" )
1138+ }
1139+
11171140// extractStringArrayFromMap extracts a string array from a map using nested key
11181141func (f * Function ) extractStringArrayFromMap (dataMap map [string ]interface {}, field , refKey string ) ([]* string , error ) {
11191142 parts , err := ParseNestedKey (field )
0 commit comments