( options: Options, instanceId: string, databaseId: string, role: string, email: string, schema: string = DEFAULT_SCHEMA, )
| 451 | } |
| 452 | |
| 453 | export async function grantRoleTo( |
| 454 | options: Options, |
| 455 | instanceId: string, |
| 456 | databaseId: string, |
| 457 | role: string, |
| 458 | email: string, |
| 459 | schema: string = DEFAULT_SCHEMA, |
| 460 | ): Promise<void> { |
| 461 | // Upsert new user account into the database. |
| 462 | const projectId = needProjectId(options); |
| 463 | const { user, mode } = toDatabaseUser(email); |
| 464 | await cloudSqlAdminClient.createUser(projectId, instanceId, mode, user); |
| 465 | |
| 466 | const fdcSqlRole = fdcSqlRoleMap[role as keyof typeof fdcSqlRoleMap](databaseId, schema); |
| 467 | await executeSqlCmdsAsSuperUser( |
| 468 | options, |
| 469 | instanceId, |
| 470 | databaseId, |
| 471 | /** cmds= */ [`GRANT "${fdcSqlRole}" TO "${user}"`], |
| 472 | /** silent= */ false, |
| 473 | ); |
| 474 | } |
no test coverage detected
searching dependent graphs…