@@ -196,25 +196,26 @@ export async function ensureGenkitMonitoringRoles(
196
196
dryRun ?: boolean ,
197
197
) : Promise < void > {
198
198
const wantEndpoints = backend . allEndpoints ( want ) . filter ( isGenkitEndpoint ) ;
199
- const haveEndpoints = backend . allEndpoints ( have ) . filter ( isGenkitEndpoint ) ;
200
- const newEndpoints = wantEndpoints . filter (
201
- ( wantE ) => ! haveEndpoints . find ( ( haveE ) => haveE . id === wantE . id ) ,
202
- ) ;
199
+ const newEndpoints = wantEndpoints . filter ( backend . missingEndpoint ( have ) ) ;
203
200
204
201
if ( newEndpoints . length === 0 ) {
205
202
return ;
206
203
}
207
204
208
- const defaultComputeServiceAgent = await gce . getDefaultServiceAccount ( projectNumber ) ;
209
205
const serviceAccounts = newEndpoints
210
- . map ( ( endpoint ) => endpoint . serviceAccount || defaultComputeServiceAgent )
211
- . filter ( ( value , index , self ) => self . indexOf ( value ) === index )
212
- . map ( ( sa ) => `serviceAccount:${ sa } ` ) ;
206
+ . map ( ( endpoint ) => endpoint . serviceAccount || "" )
207
+ . filter ( ( value , index , self ) => self . indexOf ( value ) === index ) ;
208
+ const defaultServiceAccountIndex = serviceAccounts . indexOf ( "" ) ;
209
+ if ( defaultServiceAccountIndex ) {
210
+ serviceAccounts [ defaultServiceAccountIndex ] = await gce . getDefaultServiceAccount ( projectNumber ) ;
211
+ }
212
+
213
+ const members = serviceAccounts . map ( ( sa ) => `serviceAccount:${ sa } ` ) ;
213
214
const requiredBindings : iam . Binding [ ] = [ ] ;
214
215
for ( const monitoringRole of GENKIT_MONITORING_ROLES ) {
215
216
requiredBindings . push ( {
216
217
role : monitoringRole ,
217
- members : serviceAccounts ,
218
+ members : members ,
218
219
} ) ;
219
220
}
220
221
await ensureBindings (
@@ -288,7 +289,7 @@ async function ensureBindings(
288
289
iam . printManualIamConfig ( requiredBindings , projectId , "functions" ) ;
289
290
utils . logLabeledBullet (
290
291
"functions" ,
291
- "Could not verify the necessary IAM configuration for the following newly-integrated services or endpoints : " +
292
+ "Could not verify the necessary IAM configuration for the following newly-integrated services: " +
292
293
`${ newServicesOrEndpoints . join ( ", " ) } ` +
293
294
". Deployment may fail." ,
294
295
"warn" ,
0 commit comments