mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 07:27:43 +00:00
Merge pull request #2529 from Infisical/databricks-integration
Databricks integration
This commit is contained in:
@@ -455,6 +455,31 @@ const getAppsCircleCI = async ({ accessToken }: { accessToken: string }) => {
|
||||
return apps;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return list of projects for Databricks integration
|
||||
*/
|
||||
const getAppsDatabricks = async ({ url, accessToken }: { url?: string | null; accessToken: string }) => {
|
||||
const databricksApiUrl = `${url}/api`;
|
||||
|
||||
const res = await request.get<{ scopes: { name: string; backend_type: string }[] }>(
|
||||
`${databricksApiUrl}/2.0/secrets/scopes/list`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Accept-Encoding": "application/json"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const scopes =
|
||||
res.data?.scopes?.map((a) => ({
|
||||
name: a.name, // name maps to unique scope name in Databricks
|
||||
backend_type: a.backend_type
|
||||
})) ?? [];
|
||||
|
||||
return scopes;
|
||||
};
|
||||
|
||||
const getAppsTravisCI = async ({ accessToken }: { accessToken: string }) => {
|
||||
const res = (
|
||||
await request.get<{ id: string; slug: string }[]>(`${IntegrationUrls.TRAVISCI_API_URL}/repos`, {
|
||||
@@ -1104,6 +1129,12 @@ export const getApps = async ({
|
||||
accessToken
|
||||
});
|
||||
|
||||
case Integrations.DATABRICKS:
|
||||
return getAppsDatabricks({
|
||||
url,
|
||||
accessToken
|
||||
});
|
||||
|
||||
case Integrations.LARAVELFORGE:
|
||||
return getAppsLaravelForge({
|
||||
accessToken,
|
||||
|
||||
@@ -15,6 +15,7 @@ export enum Integrations {
|
||||
FLYIO = "flyio",
|
||||
LARAVELFORGE = "laravel-forge",
|
||||
CIRCLECI = "circleci",
|
||||
DATABRICKS = "databricks",
|
||||
TRAVISCI = "travisci",
|
||||
TEAMCITY = "teamcity",
|
||||
SUPABASE = "supabase",
|
||||
@@ -73,6 +74,7 @@ export enum IntegrationUrls {
|
||||
RAILWAY_API_URL = "https://backboard.railway.app/graphql/v2",
|
||||
FLYIO_API_URL = "https://api.fly.io/graphql",
|
||||
CIRCLECI_API_URL = "https://circleci.com/api",
|
||||
DATABRICKS_API_URL = "https:/xxxx.com/api",
|
||||
TRAVISCI_API_URL = "https://api.travis-ci.com",
|
||||
SUPABASE_API_URL = "https://api.supabase.com",
|
||||
LARAVELFORGE_API_URL = "https://forge.laravel.com",
|
||||
@@ -210,6 +212,15 @@ export const getIntegrationOptions = async () => {
|
||||
clientId: "",
|
||||
docsLink: ""
|
||||
},
|
||||
{
|
||||
name: "Databricks",
|
||||
slug: "databricks",
|
||||
image: "Databricks.png",
|
||||
isAvailable: true,
|
||||
type: "pat",
|
||||
clientId: "",
|
||||
docsLink: ""
|
||||
},
|
||||
{
|
||||
name: "GitLab",
|
||||
slug: "gitlab",
|
||||
|
||||
@@ -2085,6 +2085,80 @@ const syncSecretsCircleCI = async ({
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sync/push [secrets] to Databricks project
|
||||
*/
|
||||
const syncSecretsDatabricks = async ({
|
||||
integration,
|
||||
integrationAuth,
|
||||
secrets,
|
||||
accessToken
|
||||
}: {
|
||||
integration: TIntegrations;
|
||||
integrationAuth: TIntegrationAuths;
|
||||
secrets: Record<string, { value: string; comment?: string }>;
|
||||
accessToken: string;
|
||||
}) => {
|
||||
const databricksApiUrl = `${integrationAuth.url}/api`;
|
||||
|
||||
// sync secrets to Databricks
|
||||
await Promise.all(
|
||||
Object.keys(secrets).map(async (key) =>
|
||||
request.post(
|
||||
`${databricksApiUrl}/2.0/secrets/put`,
|
||||
{
|
||||
scope: integration.app,
|
||||
key,
|
||||
string_value: secrets[key].value
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Accept-Encoding": "application/json"
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// get secrets from Databricks
|
||||
const getSecretsRes = (
|
||||
await request.get<{ secrets: { key: string; last_updated_timestamp: number }[] }>(
|
||||
`${databricksApiUrl}/2.0/secrets/list`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
params: {
|
||||
scope: integration.app
|
||||
}
|
||||
}
|
||||
)
|
||||
).data.secrets;
|
||||
|
||||
// delete secrets from Databricks
|
||||
await Promise.all(
|
||||
getSecretsRes.map(async (sec) => {
|
||||
if (!(sec.key in secrets)) {
|
||||
return request.post(
|
||||
`${databricksApiUrl}/2.0/secrets/delete`,
|
||||
{
|
||||
scope: integration.app,
|
||||
key: sec.key
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sync/push [secrets] to TravisCI project
|
||||
*/
|
||||
@@ -4021,6 +4095,14 @@ export const syncIntegrationSecrets = async ({
|
||||
accessToken
|
||||
});
|
||||
break;
|
||||
case Integrations.DATABRICKS:
|
||||
await syncSecretsDatabricks({
|
||||
integration,
|
||||
integrationAuth,
|
||||
secrets,
|
||||
accessToken
|
||||
});
|
||||
break;
|
||||
case Integrations.LARAVELFORGE:
|
||||
await syncSecretsLaravelForge({
|
||||
integration,
|
||||
|
||||
Reference in New Issue
Block a user