Skip to main content

testPermissions()

EXPERIMENTAL

调用 GCP 中资源管理器 API 的 Test Iam Permissions 方法,该方法返回服务账号在 GCP 项目上的权限列表。然后将其与 Remotion 版本所需的权限列表进行验证。

🌐 Makes a call to the Test Iam Permissions method of the Resource Manager API in GCP, which returns the list of permissions the Service Account has on the GCP Project. This is then validated against the list of permissions required for the version of Remotion.

CLI 等效项是 npx remotion cloudrun permissions

🌐 The CLI equivalent is npx remotion cloudrun permissions.

如果缺少权限,该函数不会因错误而拒绝,而是会在返回值中指示缺少的权限。

🌐 The function does not reject with an error if a permission is missing, rather the missing permission is indicated in the return value.

示例

🌐 Example

import {testPermissions} from '@remotion/cloudrun';

const {results} = await testPermissions();

for (const result of results) {
  console.log(result.decision); // "allowed"
  console.log(result.permissionName); // "iam.serviceAccounts.actAs"
}

参数

🌐 Arguments

一个具有以下属性的对象:

🌐 An object with the following property:

onTest?

每当执行新的测试时都会调用的回调函数。这允许你比等待函数的返回值更快地对新的测试结果做出反应。例如:

🌐 A callback function that gets called every time a new test has been executed. This allows you to react to new test results coming in much faster than waiting for the return value of the function. Example:

import {testPermissions} from '@remotion/cloudrun';

const {results} = await testPermissions({
  onTest: (result) => {
    console.log(result.decision); // "allowed"
    console.log(result.permissionName); // "iam.serviceAccounts.actAs"
  },
});

返回值

🌐 Return value

包含模拟每个必要权限结果的对象数组。这些对象包含以下键:

decision

要么 true,要么 false

🌐 Either true or false.

permissionName

所需权限的标识符。请参阅权限页面以查看所需权限的列表。

🌐 The identifier of the required permission. See the Permissions page to see a list of required permissions.

另请参阅

🌐 See also