MCPcopy Create free account
hub / github.com/firebase/firebase-tools / grantRoleTo

Function grantRoleTo

src/gcp/cloudsql/permissionsSetup.ts:453–474  ·  view source on GitHub ↗
(
  options: Options,
  instanceId: string,
  databaseId: string,
  role: string,
  email: string,
  schema: string = DEFAULT_SCHEMA,
)

Source from the content-addressed store, hash-verified

451}
452
453export 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}

Callers 2

grantRoleToUserInSchemaFunction · 0.90

Calls 3

needProjectIdFunction · 0.90
toDatabaseUserFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…