@dataroadinc/setup-auth
Version:
CLI tool and programmatic API for automated OAuth setup across cloud platforms
23 lines (22 loc) • 1.22 kB
JavaScript
import { gcpCheckOauthOrganizationId } from "../../../providers/gcp/organization.js";
import { gcpCheckOauthProjectId } from "../../../providers/gcp/project/index.js";
import { GCP_OAUTH_ORGANIZATION_ID, GCP_OAUTH_PROJECT_ID, updateOrAddEnvVariable, } from "../../../utils/env-handler.js";
import { SetupAuthError } from "../../../utils/error.js";
export async function gcpCheckServiceAccountOptions(options) {
const result1 = await gcpCheckOauthProjectId({
gcpOauthProjectId: options.gcpOauthProjectId,
});
if (!result1.success)
throw new SetupAuthError(result1.error);
const result2 = await gcpCheckOauthOrganizationId({
gcpOauthOrganizationId: options.gcpOauthOrganizationId,
});
if (!result2.success)
throw new SetupAuthError(result2.error);
console.log("Storing GCP project ID and organization ID in environment...");
await updateOrAddEnvVariable(GCP_OAUTH_PROJECT_ID, options.gcpOauthProjectId);
console.log("Stored GCP project ID in environment...");
await updateOrAddEnvVariable(GCP_OAUTH_ORGANIZATION_ID, options.gcpOauthOrganizationId);
console.log("Stored GCP organization ID in environment...");
return { success: true };
}