Merge pull request #3476 from Infisical/ENG-2625
feat(secret-sync): TeamCity App Connection & Secret Sync
@@ -1857,6 +1857,10 @@ export const AppConnections = {
|
|||||||
WINDMILL: {
|
WINDMILL: {
|
||||||
instanceUrl: "The Windmill instance URL to connect with (defaults to https://app.windmill.dev).",
|
instanceUrl: "The Windmill instance URL to connect with (defaults to https://app.windmill.dev).",
|
||||||
accessToken: "The access token to use to connect with Windmill."
|
accessToken: "The access token to use to connect with Windmill."
|
||||||
|
},
|
||||||
|
TEAMCITY: {
|
||||||
|
instanceUrl: "The TeamCity instance URL to connect with.",
|
||||||
|
accessToken: "The access token to use to connect with TeamCity."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1996,6 +2000,10 @@ export const SecretSyncs = {
|
|||||||
WINDMILL: {
|
WINDMILL: {
|
||||||
workspace: "The Windmill workspace to sync secrets to.",
|
workspace: "The Windmill workspace to sync secrets to.",
|
||||||
path: "The Windmill workspace path to sync secrets to."
|
path: "The Windmill workspace path to sync secrets to."
|
||||||
|
},
|
||||||
|
TEAMCITY: {
|
||||||
|
project: "The TeamCity project to sync secrets to.",
|
||||||
|
buildConfig: "The TeamCity build configuration to sync secrets to."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ import {
|
|||||||
PostgresConnectionListItemSchema,
|
PostgresConnectionListItemSchema,
|
||||||
SanitizedPostgresConnectionSchema
|
SanitizedPostgresConnectionSchema
|
||||||
} from "@app/services/app-connection/postgres";
|
} from "@app/services/app-connection/postgres";
|
||||||
|
import {
|
||||||
|
SanitizedTeamCityConnectionSchema,
|
||||||
|
TeamCityConnectionListItemSchema
|
||||||
|
} from "@app/services/app-connection/teamcity";
|
||||||
import {
|
import {
|
||||||
SanitizedTerraformCloudConnectionSchema,
|
SanitizedTerraformCloudConnectionSchema,
|
||||||
TerraformCloudConnectionListItemSchema
|
TerraformCloudConnectionListItemSchema
|
||||||
@@ -59,7 +63,8 @@ const SanitizedAppConnectionSchema = z.union([
|
|||||||
...SanitizedMsSqlConnectionSchema.options,
|
...SanitizedMsSqlConnectionSchema.options,
|
||||||
...SanitizedCamundaConnectionSchema.options,
|
...SanitizedCamundaConnectionSchema.options,
|
||||||
...SanitizedWindmillConnectionSchema.options,
|
...SanitizedWindmillConnectionSchema.options,
|
||||||
...SanitizedAuth0ConnectionSchema.options
|
...SanitizedAuth0ConnectionSchema.options,
|
||||||
|
...SanitizedTeamCityConnectionSchema.options
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
|
const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
|
||||||
@@ -76,7 +81,8 @@ const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
|
|||||||
MsSqlConnectionListItemSchema,
|
MsSqlConnectionListItemSchema,
|
||||||
CamundaConnectionListItemSchema,
|
CamundaConnectionListItemSchema,
|
||||||
WindmillConnectionListItemSchema,
|
WindmillConnectionListItemSchema,
|
||||||
Auth0ConnectionListItemSchema
|
Auth0ConnectionListItemSchema,
|
||||||
|
TeamCityConnectionListItemSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const registerAppConnectionRouter = async (server: FastifyZodProvider) => {
|
export const registerAppConnectionRouter = async (server: FastifyZodProvider) => {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { registerGitHubConnectionRouter } from "./github-connection-router";
|
|||||||
import { registerHumanitecConnectionRouter } from "./humanitec-connection-router";
|
import { registerHumanitecConnectionRouter } from "./humanitec-connection-router";
|
||||||
import { registerMsSqlConnectionRouter } from "./mssql-connection-router";
|
import { registerMsSqlConnectionRouter } from "./mssql-connection-router";
|
||||||
import { registerPostgresConnectionRouter } from "./postgres-connection-router";
|
import { registerPostgresConnectionRouter } from "./postgres-connection-router";
|
||||||
|
import { registerTeamCityConnectionRouter } from "./teamcity-connection-router";
|
||||||
import { registerTerraformCloudConnectionRouter } from "./terraform-cloud-router";
|
import { registerTerraformCloudConnectionRouter } from "./terraform-cloud-router";
|
||||||
import { registerVercelConnectionRouter } from "./vercel-connection-router";
|
import { registerVercelConnectionRouter } from "./vercel-connection-router";
|
||||||
import { registerWindmillConnectionRouter } from "./windmill-connection-router";
|
import { registerWindmillConnectionRouter } from "./windmill-connection-router";
|
||||||
@@ -32,5 +33,6 @@ export const APP_CONNECTION_REGISTER_ROUTER_MAP: Record<AppConnection, (server:
|
|||||||
[AppConnection.MsSql]: registerMsSqlConnectionRouter,
|
[AppConnection.MsSql]: registerMsSqlConnectionRouter,
|
||||||
[AppConnection.Camunda]: registerCamundaConnectionRouter,
|
[AppConnection.Camunda]: registerCamundaConnectionRouter,
|
||||||
[AppConnection.Windmill]: registerWindmillConnectionRouter,
|
[AppConnection.Windmill]: registerWindmillConnectionRouter,
|
||||||
[AppConnection.Auth0]: registerAuth0ConnectionRouter
|
[AppConnection.Auth0]: registerAuth0ConnectionRouter,
|
||||||
|
[AppConnection.TeamCity]: registerTeamCityConnectionRouter
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import z from "zod";
|
||||||
|
|
||||||
|
import { readLimit } from "@app/server/config/rateLimiter";
|
||||||
|
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||||
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
import {
|
||||||
|
CreateTeamCityConnectionSchema,
|
||||||
|
SanitizedTeamCityConnectionSchema,
|
||||||
|
UpdateTeamCityConnectionSchema
|
||||||
|
} from "@app/services/app-connection/teamcity";
|
||||||
|
import { AuthMode } from "@app/services/auth/auth-type";
|
||||||
|
|
||||||
|
import { registerAppConnectionEndpoints } from "./app-connection-endpoints";
|
||||||
|
|
||||||
|
export const registerTeamCityConnectionRouter = async (server: FastifyZodProvider) => {
|
||||||
|
registerAppConnectionEndpoints({
|
||||||
|
app: AppConnection.TeamCity,
|
||||||
|
server,
|
||||||
|
sanitizedResponseSchema: SanitizedTeamCityConnectionSchema,
|
||||||
|
createSchema: CreateTeamCityConnectionSchema,
|
||||||
|
updateSchema: UpdateTeamCityConnectionSchema
|
||||||
|
});
|
||||||
|
|
||||||
|
// The following endpoints are for internal Infisical App use only and not part of the public API
|
||||||
|
server.route({
|
||||||
|
method: "GET",
|
||||||
|
url: `/:connectionId/projects`,
|
||||||
|
config: {
|
||||||
|
rateLimit: readLimit
|
||||||
|
},
|
||||||
|
schema: {
|
||||||
|
params: z.object({
|
||||||
|
connectionId: z.string().uuid()
|
||||||
|
}),
|
||||||
|
response: {
|
||||||
|
200: z
|
||||||
|
.object({
|
||||||
|
id: z.string(),
|
||||||
|
name: z.string(),
|
||||||
|
buildTypes: z.object({
|
||||||
|
buildType: z
|
||||||
|
.object({
|
||||||
|
id: z.string(),
|
||||||
|
name: z.string()
|
||||||
|
})
|
||||||
|
.array()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.array()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onRequest: verifyAuth([AuthMode.JWT]),
|
||||||
|
handler: async (req) => {
|
||||||
|
const { connectionId } = req.params;
|
||||||
|
const projects = await server.services.appConnection.teamcity.listProjects(connectionId, req.permission);
|
||||||
|
|
||||||
|
return projects;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -9,6 +9,7 @@ import { registerDatabricksSyncRouter } from "./databricks-sync-router";
|
|||||||
import { registerGcpSyncRouter } from "./gcp-sync-router";
|
import { registerGcpSyncRouter } from "./gcp-sync-router";
|
||||||
import { registerGitHubSyncRouter } from "./github-sync-router";
|
import { registerGitHubSyncRouter } from "./github-sync-router";
|
||||||
import { registerHumanitecSyncRouter } from "./humanitec-sync-router";
|
import { registerHumanitecSyncRouter } from "./humanitec-sync-router";
|
||||||
|
import { registerTeamCitySyncRouter } from "./teamcity-sync-router";
|
||||||
import { registerTerraformCloudSyncRouter } from "./terraform-cloud-sync-router";
|
import { registerTerraformCloudSyncRouter } from "./terraform-cloud-sync-router";
|
||||||
import { registerVercelSyncRouter } from "./vercel-sync-router";
|
import { registerVercelSyncRouter } from "./vercel-sync-router";
|
||||||
import { registerWindmillSyncRouter } from "./windmill-sync-router";
|
import { registerWindmillSyncRouter } from "./windmill-sync-router";
|
||||||
@@ -27,5 +28,6 @@ export const SECRET_SYNC_REGISTER_ROUTER_MAP: Record<SecretSync, (server: Fastif
|
|||||||
[SecretSync.TerraformCloud]: registerTerraformCloudSyncRouter,
|
[SecretSync.TerraformCloud]: registerTerraformCloudSyncRouter,
|
||||||
[SecretSync.Camunda]: registerCamundaSyncRouter,
|
[SecretSync.Camunda]: registerCamundaSyncRouter,
|
||||||
[SecretSync.Vercel]: registerVercelSyncRouter,
|
[SecretSync.Vercel]: registerVercelSyncRouter,
|
||||||
[SecretSync.Windmill]: registerWindmillSyncRouter
|
[SecretSync.Windmill]: registerWindmillSyncRouter,
|
||||||
|
[SecretSync.TeamCity]: registerTeamCitySyncRouter
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { DatabricksSyncListItemSchema, DatabricksSyncSchema } from "@app/service
|
|||||||
import { GcpSyncListItemSchema, GcpSyncSchema } from "@app/services/secret-sync/gcp";
|
import { GcpSyncListItemSchema, GcpSyncSchema } from "@app/services/secret-sync/gcp";
|
||||||
import { GitHubSyncListItemSchema, GitHubSyncSchema } from "@app/services/secret-sync/github";
|
import { GitHubSyncListItemSchema, GitHubSyncSchema } from "@app/services/secret-sync/github";
|
||||||
import { HumanitecSyncListItemSchema, HumanitecSyncSchema } from "@app/services/secret-sync/humanitec";
|
import { HumanitecSyncListItemSchema, HumanitecSyncSchema } from "@app/services/secret-sync/humanitec";
|
||||||
|
import { TeamCitySyncListItemSchema, TeamCitySyncSchema } from "@app/services/secret-sync/teamcity";
|
||||||
import { TerraformCloudSyncListItemSchema, TerraformCloudSyncSchema } from "@app/services/secret-sync/terraform-cloud";
|
import { TerraformCloudSyncListItemSchema, TerraformCloudSyncSchema } from "@app/services/secret-sync/terraform-cloud";
|
||||||
import { VercelSyncListItemSchema, VercelSyncSchema } from "@app/services/secret-sync/vercel";
|
import { VercelSyncListItemSchema, VercelSyncSchema } from "@app/services/secret-sync/vercel";
|
||||||
import { WindmillSyncListItemSchema, WindmillSyncSchema } from "@app/services/secret-sync/windmill";
|
import { WindmillSyncListItemSchema, WindmillSyncSchema } from "@app/services/secret-sync/windmill";
|
||||||
@@ -39,7 +40,8 @@ const SecretSyncSchema = z.discriminatedUnion("destination", [
|
|||||||
TerraformCloudSyncSchema,
|
TerraformCloudSyncSchema,
|
||||||
CamundaSyncSchema,
|
CamundaSyncSchema,
|
||||||
VercelSyncSchema,
|
VercelSyncSchema,
|
||||||
WindmillSyncSchema
|
WindmillSyncSchema,
|
||||||
|
TeamCitySyncSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const SecretSyncOptionsSchema = z.discriminatedUnion("destination", [
|
const SecretSyncOptionsSchema = z.discriminatedUnion("destination", [
|
||||||
@@ -54,7 +56,8 @@ const SecretSyncOptionsSchema = z.discriminatedUnion("destination", [
|
|||||||
TerraformCloudSyncListItemSchema,
|
TerraformCloudSyncListItemSchema,
|
||||||
CamundaSyncListItemSchema,
|
CamundaSyncListItemSchema,
|
||||||
VercelSyncListItemSchema,
|
VercelSyncListItemSchema,
|
||||||
WindmillSyncListItemSchema
|
WindmillSyncListItemSchema,
|
||||||
|
TeamCitySyncListItemSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const registerSecretSyncRouter = async (server: FastifyZodProvider) => {
|
export const registerSecretSyncRouter = async (server: FastifyZodProvider) => {
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
|
import {
|
||||||
|
CreateTeamCitySyncSchema,
|
||||||
|
TeamCitySyncSchema,
|
||||||
|
UpdateTeamCitySyncSchema
|
||||||
|
} from "@app/services/secret-sync/teamcity";
|
||||||
|
|
||||||
|
import { registerSyncSecretsEndpoints } from "./secret-sync-endpoints";
|
||||||
|
|
||||||
|
export const registerTeamCitySyncRouter = async (server: FastifyZodProvider) =>
|
||||||
|
registerSyncSecretsEndpoints({
|
||||||
|
destination: SecretSync.TeamCity,
|
||||||
|
server,
|
||||||
|
responseSchema: TeamCitySyncSchema,
|
||||||
|
createSchema: CreateTeamCitySyncSchema,
|
||||||
|
updateSchema: UpdateTeamCitySyncSchema
|
||||||
|
});
|
||||||
@@ -12,7 +12,8 @@ export enum AppConnection {
|
|||||||
MsSql = "mssql",
|
MsSql = "mssql",
|
||||||
Camunda = "camunda",
|
Camunda = "camunda",
|
||||||
Windmill = "windmill",
|
Windmill = "windmill",
|
||||||
Auth0 = "auth0"
|
Auth0 = "auth0",
|
||||||
|
TeamCity = "teamcity"
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum AWSRegion {
|
export enum AWSRegion {
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ import {
|
|||||||
} from "./humanitec";
|
} from "./humanitec";
|
||||||
import { getMsSqlConnectionListItem, MsSqlConnectionMethod } from "./mssql";
|
import { getMsSqlConnectionListItem, MsSqlConnectionMethod } from "./mssql";
|
||||||
import { getPostgresConnectionListItem, PostgresConnectionMethod } from "./postgres";
|
import { getPostgresConnectionListItem, PostgresConnectionMethod } from "./postgres";
|
||||||
|
import {
|
||||||
|
getTeamCityConnectionListItem,
|
||||||
|
TeamCityConnectionMethod,
|
||||||
|
validateTeamCityConnectionCredentials
|
||||||
|
} from "./teamcity";
|
||||||
import {
|
import {
|
||||||
getTerraformCloudConnectionListItem,
|
getTerraformCloudConnectionListItem,
|
||||||
TerraformCloudConnectionMethod,
|
TerraformCloudConnectionMethod,
|
||||||
@@ -71,7 +76,8 @@ export const listAppConnectionOptions = () => {
|
|||||||
getMsSqlConnectionListItem(),
|
getMsSqlConnectionListItem(),
|
||||||
getCamundaConnectionListItem(),
|
getCamundaConnectionListItem(),
|
||||||
getWindmillConnectionListItem(),
|
getWindmillConnectionListItem(),
|
||||||
getAuth0ConnectionListItem()
|
getAuth0ConnectionListItem(),
|
||||||
|
getTeamCityConnectionListItem()
|
||||||
].sort((a, b) => a.name.localeCompare(b.name));
|
].sort((a, b) => a.name.localeCompare(b.name));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -135,7 +141,8 @@ export const validateAppConnectionCredentials = async (
|
|||||||
[AppConnection.Vercel]: validateVercelConnectionCredentials as TAppConnectionCredentialsValidator,
|
[AppConnection.Vercel]: validateVercelConnectionCredentials as TAppConnectionCredentialsValidator,
|
||||||
[AppConnection.TerraformCloud]: validateTerraformCloudConnectionCredentials as TAppConnectionCredentialsValidator,
|
[AppConnection.TerraformCloud]: validateTerraformCloudConnectionCredentials as TAppConnectionCredentialsValidator,
|
||||||
[AppConnection.Auth0]: validateAuth0ConnectionCredentials as TAppConnectionCredentialsValidator,
|
[AppConnection.Auth0]: validateAuth0ConnectionCredentials as TAppConnectionCredentialsValidator,
|
||||||
[AppConnection.Windmill]: validateWindmillConnectionCredentials as TAppConnectionCredentialsValidator
|
[AppConnection.Windmill]: validateWindmillConnectionCredentials as TAppConnectionCredentialsValidator,
|
||||||
|
[AppConnection.TeamCity]: validateTeamCityConnectionCredentials as TAppConnectionCredentialsValidator
|
||||||
};
|
};
|
||||||
|
|
||||||
return VALIDATE_APP_CONNECTION_CREDENTIALS_MAP[appConnection.app](appConnection);
|
return VALIDATE_APP_CONNECTION_CREDENTIALS_MAP[appConnection.app](appConnection);
|
||||||
@@ -167,6 +174,7 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>
|
|||||||
case MsSqlConnectionMethod.UsernameAndPassword:
|
case MsSqlConnectionMethod.UsernameAndPassword:
|
||||||
return "Username & Password";
|
return "Username & Password";
|
||||||
case WindmillConnectionMethod.AccessToken:
|
case WindmillConnectionMethod.AccessToken:
|
||||||
|
case TeamCityConnectionMethod.AccessToken:
|
||||||
return "Access Token";
|
return "Access Token";
|
||||||
case Auth0ConnectionMethod.ClientCredentials:
|
case Auth0ConnectionMethod.ClientCredentials:
|
||||||
return "Client Credentials";
|
return "Client Credentials";
|
||||||
@@ -214,5 +222,6 @@ export const TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM: Record<
|
|||||||
[AppConnection.Camunda]: platformManagedCredentialsNotSupported,
|
[AppConnection.Camunda]: platformManagedCredentialsNotSupported,
|
||||||
[AppConnection.Vercel]: platformManagedCredentialsNotSupported,
|
[AppConnection.Vercel]: platformManagedCredentialsNotSupported,
|
||||||
[AppConnection.Windmill]: platformManagedCredentialsNotSupported,
|
[AppConnection.Windmill]: platformManagedCredentialsNotSupported,
|
||||||
[AppConnection.Auth0]: platformManagedCredentialsNotSupported
|
[AppConnection.Auth0]: platformManagedCredentialsNotSupported,
|
||||||
|
[AppConnection.TeamCity]: platformManagedCredentialsNotSupported
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,5 +14,6 @@ export const APP_CONNECTION_NAME_MAP: Record<AppConnection, string> = {
|
|||||||
[AppConnection.MsSql]: "Microsoft SQL Server",
|
[AppConnection.MsSql]: "Microsoft SQL Server",
|
||||||
[AppConnection.Camunda]: "Camunda",
|
[AppConnection.Camunda]: "Camunda",
|
||||||
[AppConnection.Windmill]: "Windmill",
|
[AppConnection.Windmill]: "Windmill",
|
||||||
[AppConnection.Auth0]: "Auth0"
|
[AppConnection.Auth0]: "Auth0",
|
||||||
|
[AppConnection.TeamCity]: "TeamCity"
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ import { ValidateHumanitecConnectionCredentialsSchema } from "./humanitec";
|
|||||||
import { humanitecConnectionService } from "./humanitec/humanitec-connection-service";
|
import { humanitecConnectionService } from "./humanitec/humanitec-connection-service";
|
||||||
import { ValidateMsSqlConnectionCredentialsSchema } from "./mssql";
|
import { ValidateMsSqlConnectionCredentialsSchema } from "./mssql";
|
||||||
import { ValidatePostgresConnectionCredentialsSchema } from "./postgres";
|
import { ValidatePostgresConnectionCredentialsSchema } from "./postgres";
|
||||||
|
import { ValidateTeamCityConnectionCredentialsSchema } from "./teamcity";
|
||||||
|
import { teamcityConnectionService } from "./teamcity/teamcity-connection-service";
|
||||||
import { ValidateTerraformCloudConnectionCredentialsSchema } from "./terraform-cloud";
|
import { ValidateTerraformCloudConnectionCredentialsSchema } from "./terraform-cloud";
|
||||||
import { terraformCloudConnectionService } from "./terraform-cloud/terraform-cloud-connection-service";
|
import { terraformCloudConnectionService } from "./terraform-cloud/terraform-cloud-connection-service";
|
||||||
import { ValidateVercelConnectionCredentialsSchema } from "./vercel";
|
import { ValidateVercelConnectionCredentialsSchema } from "./vercel";
|
||||||
@@ -74,7 +76,8 @@ const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TValidateAp
|
|||||||
[AppConnection.MsSql]: ValidateMsSqlConnectionCredentialsSchema,
|
[AppConnection.MsSql]: ValidateMsSqlConnectionCredentialsSchema,
|
||||||
[AppConnection.Camunda]: ValidateCamundaConnectionCredentialsSchema,
|
[AppConnection.Camunda]: ValidateCamundaConnectionCredentialsSchema,
|
||||||
[AppConnection.Windmill]: ValidateWindmillConnectionCredentialsSchema,
|
[AppConnection.Windmill]: ValidateWindmillConnectionCredentialsSchema,
|
||||||
[AppConnection.Auth0]: ValidateAuth0ConnectionCredentialsSchema
|
[AppConnection.Auth0]: ValidateAuth0ConnectionCredentialsSchema,
|
||||||
|
[AppConnection.TeamCity]: ValidateTeamCityConnectionCredentialsSchema
|
||||||
};
|
};
|
||||||
|
|
||||||
export const appConnectionServiceFactory = ({
|
export const appConnectionServiceFactory = ({
|
||||||
@@ -450,6 +453,7 @@ export const appConnectionServiceFactory = ({
|
|||||||
camunda: camundaConnectionService(connectAppConnectionById, appConnectionDAL, kmsService),
|
camunda: camundaConnectionService(connectAppConnectionById, appConnectionDAL, kmsService),
|
||||||
vercel: vercelConnectionService(connectAppConnectionById),
|
vercel: vercelConnectionService(connectAppConnectionById),
|
||||||
windmill: windmillConnectionService(connectAppConnectionById),
|
windmill: windmillConnectionService(connectAppConnectionById),
|
||||||
auth0: auth0ConnectionService(connectAppConnectionById, appConnectionDAL, kmsService)
|
auth0: auth0ConnectionService(connectAppConnectionById, appConnectionDAL, kmsService),
|
||||||
|
teamcity: teamcityConnectionService(connectAppConnectionById)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -63,6 +63,12 @@ import {
|
|||||||
TPostgresConnectionInput,
|
TPostgresConnectionInput,
|
||||||
TValidatePostgresConnectionCredentialsSchema
|
TValidatePostgresConnectionCredentialsSchema
|
||||||
} from "./postgres";
|
} from "./postgres";
|
||||||
|
import {
|
||||||
|
TTeamCityConnection,
|
||||||
|
TTeamCityConnectionConfig,
|
||||||
|
TTeamCityConnectionInput,
|
||||||
|
TValidateTeamCityConnectionCredentialsSchema
|
||||||
|
} from "./teamcity";
|
||||||
import {
|
import {
|
||||||
TTerraformCloudConnection,
|
TTerraformCloudConnection,
|
||||||
TTerraformCloudConnectionConfig,
|
TTerraformCloudConnectionConfig,
|
||||||
@@ -97,6 +103,7 @@ export type TAppConnection = { id: string } & (
|
|||||||
| TCamundaConnection
|
| TCamundaConnection
|
||||||
| TWindmillConnection
|
| TWindmillConnection
|
||||||
| TAuth0Connection
|
| TAuth0Connection
|
||||||
|
| TTeamCityConnection
|
||||||
);
|
);
|
||||||
|
|
||||||
export type TAppConnectionRaw = NonNullable<Awaited<ReturnType<TAppConnectionDALFactory["findById"]>>>;
|
export type TAppConnectionRaw = NonNullable<Awaited<ReturnType<TAppConnectionDALFactory["findById"]>>>;
|
||||||
@@ -118,6 +125,7 @@ export type TAppConnectionInput = { id: string } & (
|
|||||||
| TCamundaConnectionInput
|
| TCamundaConnectionInput
|
||||||
| TWindmillConnectionInput
|
| TWindmillConnectionInput
|
||||||
| TAuth0ConnectionInput
|
| TAuth0ConnectionInput
|
||||||
|
| TTeamCityConnectionInput
|
||||||
);
|
);
|
||||||
|
|
||||||
export type TSqlConnectionInput = TPostgresConnectionInput | TMsSqlConnectionInput;
|
export type TSqlConnectionInput = TPostgresConnectionInput | TMsSqlConnectionInput;
|
||||||
@@ -144,7 +152,8 @@ export type TAppConnectionConfig =
|
|||||||
| TSqlConnectionConfig
|
| TSqlConnectionConfig
|
||||||
| TCamundaConnectionConfig
|
| TCamundaConnectionConfig
|
||||||
| TWindmillConnectionConfig
|
| TWindmillConnectionConfig
|
||||||
| TAuth0ConnectionConfig;
|
| TAuth0ConnectionConfig
|
||||||
|
| TTeamCityConnectionConfig;
|
||||||
|
|
||||||
export type TValidateAppConnectionCredentialsSchema =
|
export type TValidateAppConnectionCredentialsSchema =
|
||||||
| TValidateAwsConnectionCredentialsSchema
|
| TValidateAwsConnectionCredentialsSchema
|
||||||
@@ -160,7 +169,8 @@ export type TValidateAppConnectionCredentialsSchema =
|
|||||||
| TValidateTerraformCloudConnectionCredentialsSchema
|
| TValidateTerraformCloudConnectionCredentialsSchema
|
||||||
| TValidateVercelConnectionCredentialsSchema
|
| TValidateVercelConnectionCredentialsSchema
|
||||||
| TValidateWindmillConnectionCredentialsSchema
|
| TValidateWindmillConnectionCredentialsSchema
|
||||||
| TValidateAuth0ConnectionCredentialsSchema;
|
| TValidateAuth0ConnectionCredentialsSchema
|
||||||
|
| TValidateTeamCityConnectionCredentialsSchema;
|
||||||
|
|
||||||
export type TListAwsConnectionKmsKeys = {
|
export type TListAwsConnectionKmsKeys = {
|
||||||
connectionId: string;
|
connectionId: string;
|
||||||
|
|||||||
4
backend/src/services/app-connection/teamcity/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export * from "./teamcity-connection-enums";
|
||||||
|
export * from "./teamcity-connection-fns";
|
||||||
|
export * from "./teamcity-connection-schemas";
|
||||||
|
export * from "./teamcity-connection-types";
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export enum TeamCityConnectionMethod {
|
||||||
|
AccessToken = "access-token"
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import { AxiosError } from "axios";
|
||||||
|
|
||||||
|
import { request } from "@app/lib/config/request";
|
||||||
|
import { BadRequestError } from "@app/lib/errors";
|
||||||
|
import { removeTrailingSlash } from "@app/lib/fn";
|
||||||
|
import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
|
||||||
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
|
||||||
|
import { TeamCityConnectionMethod } from "./teamcity-connection-enums";
|
||||||
|
import {
|
||||||
|
TTeamCityConnection,
|
||||||
|
TTeamCityConnectionConfig,
|
||||||
|
TTeamCityListProjectsResponse
|
||||||
|
} from "./teamcity-connection-types";
|
||||||
|
|
||||||
|
export const getTeamCityInstanceUrl = async (config: TTeamCityConnectionConfig) => {
|
||||||
|
const instanceUrl = removeTrailingSlash(config.credentials.instanceUrl);
|
||||||
|
|
||||||
|
await blockLocalAndPrivateIpAddresses(instanceUrl);
|
||||||
|
|
||||||
|
return instanceUrl;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getTeamCityConnectionListItem = () => {
|
||||||
|
return {
|
||||||
|
name: "TeamCity" as const,
|
||||||
|
app: AppConnection.TeamCity as const,
|
||||||
|
methods: Object.values(TeamCityConnectionMethod) as [TeamCityConnectionMethod.AccessToken]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const validateTeamCityConnectionCredentials = async (config: TTeamCityConnectionConfig) => {
|
||||||
|
const instanceUrl = await getTeamCityInstanceUrl(config);
|
||||||
|
|
||||||
|
const { accessToken } = config.credentials;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await request.get(`${instanceUrl}/app/rest/server`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
Accept: "application/json"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof AxiosError) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: `Failed to validate credentials: ${error.message || "Unknown error"}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: "Unable to validate connection: verify credentials"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return config.credentials;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const listTeamCityProjects = async (appConnection: TTeamCityConnection) => {
|
||||||
|
const instanceUrl = await getTeamCityInstanceUrl(appConnection);
|
||||||
|
const { accessToken } = appConnection.credentials;
|
||||||
|
|
||||||
|
const resp = await request.get<TTeamCityListProjectsResponse>(
|
||||||
|
`${instanceUrl}/app/rest/projects?fields=project(id,name,buildTypes(buildType(id,name)))`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
Accept: "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Filter out the root project. Should not be seen by users.
|
||||||
|
return resp.data.project.filter((proj) => proj.id !== "_Root");
|
||||||
|
};
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import z from "zod";
|
||||||
|
|
||||||
|
import { AppConnections } from "@app/lib/api-docs";
|
||||||
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
import {
|
||||||
|
BaseAppConnectionSchema,
|
||||||
|
GenericCreateAppConnectionFieldsSchema,
|
||||||
|
GenericUpdateAppConnectionFieldsSchema
|
||||||
|
} from "@app/services/app-connection/app-connection-schemas";
|
||||||
|
|
||||||
|
import { TeamCityConnectionMethod } from "./teamcity-connection-enums";
|
||||||
|
|
||||||
|
export const TeamCityConnectionAccessTokenCredentialsSchema = z.object({
|
||||||
|
accessToken: z
|
||||||
|
.string()
|
||||||
|
.trim()
|
||||||
|
.min(1, "Access Token required")
|
||||||
|
.describe(AppConnections.CREDENTIALS.TEAMCITY.accessToken),
|
||||||
|
instanceUrl: z
|
||||||
|
.string()
|
||||||
|
.trim()
|
||||||
|
.url("Invalid Instance URL")
|
||||||
|
.min(1, "Instance URL required")
|
||||||
|
.describe(AppConnections.CREDENTIALS.TEAMCITY.instanceUrl)
|
||||||
|
});
|
||||||
|
|
||||||
|
const BaseTeamCityConnectionSchema = BaseAppConnectionSchema.extend({ app: z.literal(AppConnection.TeamCity) });
|
||||||
|
|
||||||
|
export const TeamCityConnectionSchema = BaseTeamCityConnectionSchema.extend({
|
||||||
|
method: z.literal(TeamCityConnectionMethod.AccessToken),
|
||||||
|
credentials: TeamCityConnectionAccessTokenCredentialsSchema
|
||||||
|
});
|
||||||
|
|
||||||
|
export const SanitizedTeamCityConnectionSchema = z.discriminatedUnion("method", [
|
||||||
|
BaseTeamCityConnectionSchema.extend({
|
||||||
|
method: z.literal(TeamCityConnectionMethod.AccessToken),
|
||||||
|
credentials: TeamCityConnectionAccessTokenCredentialsSchema.pick({
|
||||||
|
instanceUrl: true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
export const ValidateTeamCityConnectionCredentialsSchema = z.discriminatedUnion("method", [
|
||||||
|
z.object({
|
||||||
|
method: z
|
||||||
|
.literal(TeamCityConnectionMethod.AccessToken)
|
||||||
|
.describe(AppConnections.CREATE(AppConnection.TeamCity).method),
|
||||||
|
credentials: TeamCityConnectionAccessTokenCredentialsSchema.describe(
|
||||||
|
AppConnections.CREATE(AppConnection.TeamCity).credentials
|
||||||
|
)
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
export const CreateTeamCityConnectionSchema = ValidateTeamCityConnectionCredentialsSchema.and(
|
||||||
|
GenericCreateAppConnectionFieldsSchema(AppConnection.TeamCity)
|
||||||
|
);
|
||||||
|
|
||||||
|
export const UpdateTeamCityConnectionSchema = z
|
||||||
|
.object({
|
||||||
|
credentials: TeamCityConnectionAccessTokenCredentialsSchema.optional().describe(
|
||||||
|
AppConnections.UPDATE(AppConnection.TeamCity).credentials
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.and(GenericUpdateAppConnectionFieldsSchema(AppConnection.TeamCity));
|
||||||
|
|
||||||
|
export const TeamCityConnectionListItemSchema = z.object({
|
||||||
|
name: z.literal("TeamCity"),
|
||||||
|
app: z.literal(AppConnection.TeamCity),
|
||||||
|
methods: z.nativeEnum(TeamCityConnectionMethod).array()
|
||||||
|
});
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { OrgServiceActor } from "@app/lib/types";
|
||||||
|
|
||||||
|
import { AppConnection } from "../app-connection-enums";
|
||||||
|
import { listTeamCityProjects } from "./teamcity-connection-fns";
|
||||||
|
import { TTeamCityConnection } from "./teamcity-connection-types";
|
||||||
|
|
||||||
|
type TGetAppConnectionFunc = (
|
||||||
|
app: AppConnection,
|
||||||
|
connectionId: string,
|
||||||
|
actor: OrgServiceActor
|
||||||
|
) => Promise<TTeamCityConnection>;
|
||||||
|
|
||||||
|
export const teamcityConnectionService = (getAppConnection: TGetAppConnectionFunc) => {
|
||||||
|
const listProjects = async (connectionId: string, actor: OrgServiceActor) => {
|
||||||
|
const appConnection = await getAppConnection(AppConnection.TeamCity, connectionId, actor);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const projects = await listTeamCityProjects(appConnection);
|
||||||
|
return projects;
|
||||||
|
} catch (error) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
listProjects
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import z from "zod";
|
||||||
|
|
||||||
|
import { DiscriminativePick } from "@app/lib/types";
|
||||||
|
|
||||||
|
import { AppConnection } from "../app-connection-enums";
|
||||||
|
import {
|
||||||
|
CreateTeamCityConnectionSchema,
|
||||||
|
TeamCityConnectionSchema,
|
||||||
|
ValidateTeamCityConnectionCredentialsSchema
|
||||||
|
} from "./teamcity-connection-schemas";
|
||||||
|
|
||||||
|
export type TTeamCityConnection = z.infer<typeof TeamCityConnectionSchema>;
|
||||||
|
|
||||||
|
export type TTeamCityConnectionInput = z.infer<typeof CreateTeamCityConnectionSchema> & {
|
||||||
|
app: AppConnection.TeamCity;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TValidateTeamCityConnectionCredentialsSchema = typeof ValidateTeamCityConnectionCredentialsSchema;
|
||||||
|
|
||||||
|
export type TTeamCityConnectionConfig = DiscriminativePick<
|
||||||
|
TTeamCityConnectionInput,
|
||||||
|
"method" | "app" | "credentials"
|
||||||
|
> & {
|
||||||
|
orgId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TTeamCityProject = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TTeamCityProjectWithBuildTypes = TTeamCityProject & {
|
||||||
|
buildTypes: {
|
||||||
|
buildType: {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TTeamCityListProjectsResponse = {
|
||||||
|
project: TTeamCityProjectWithBuildTypes[];
|
||||||
|
};
|
||||||
@@ -10,7 +10,8 @@ export enum SecretSync {
|
|||||||
TerraformCloud = "terraform-cloud",
|
TerraformCloud = "terraform-cloud",
|
||||||
Camunda = "camunda",
|
Camunda = "camunda",
|
||||||
Vercel = "vercel",
|
Vercel = "vercel",
|
||||||
Windmill = "windmill"
|
Windmill = "windmill",
|
||||||
|
TeamCity = "teamcity"
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SecretSyncInitialSyncBehavior {
|
export enum SecretSyncInitialSyncBehavior {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { GCP_SYNC_LIST_OPTION } from "./gcp";
|
|||||||
import { GcpSyncFns } from "./gcp/gcp-sync-fns";
|
import { GcpSyncFns } from "./gcp/gcp-sync-fns";
|
||||||
import { HUMANITEC_SYNC_LIST_OPTION } from "./humanitec";
|
import { HUMANITEC_SYNC_LIST_OPTION } from "./humanitec";
|
||||||
import { HumanitecSyncFns } from "./humanitec/humanitec-sync-fns";
|
import { HumanitecSyncFns } from "./humanitec/humanitec-sync-fns";
|
||||||
|
import { TEAMCITY_SYNC_LIST_OPTION, TeamCitySyncFns } from "./teamcity";
|
||||||
import { TERRAFORM_CLOUD_SYNC_LIST_OPTION, TerraformCloudSyncFns } from "./terraform-cloud";
|
import { TERRAFORM_CLOUD_SYNC_LIST_OPTION, TerraformCloudSyncFns } from "./terraform-cloud";
|
||||||
import { VERCEL_SYNC_LIST_OPTION, VercelSyncFns } from "./vercel";
|
import { VERCEL_SYNC_LIST_OPTION, VercelSyncFns } from "./vercel";
|
||||||
import { WINDMILL_SYNC_LIST_OPTION, WindmillSyncFns } from "./windmill";
|
import { WINDMILL_SYNC_LIST_OPTION, WindmillSyncFns } from "./windmill";
|
||||||
@@ -43,7 +44,8 @@ const SECRET_SYNC_LIST_OPTIONS: Record<SecretSync, TSecretSyncListItem> = {
|
|||||||
[SecretSync.TerraformCloud]: TERRAFORM_CLOUD_SYNC_LIST_OPTION,
|
[SecretSync.TerraformCloud]: TERRAFORM_CLOUD_SYNC_LIST_OPTION,
|
||||||
[SecretSync.Camunda]: CAMUNDA_SYNC_LIST_OPTION,
|
[SecretSync.Camunda]: CAMUNDA_SYNC_LIST_OPTION,
|
||||||
[SecretSync.Vercel]: VERCEL_SYNC_LIST_OPTION,
|
[SecretSync.Vercel]: VERCEL_SYNC_LIST_OPTION,
|
||||||
[SecretSync.Windmill]: WINDMILL_SYNC_LIST_OPTION
|
[SecretSync.Windmill]: WINDMILL_SYNC_LIST_OPTION,
|
||||||
|
[SecretSync.TeamCity]: TEAMCITY_SYNC_LIST_OPTION
|
||||||
};
|
};
|
||||||
|
|
||||||
export const listSecretSyncOptions = () => {
|
export const listSecretSyncOptions = () => {
|
||||||
@@ -140,6 +142,8 @@ export const SecretSyncFns = {
|
|||||||
return VercelSyncFns.syncSecrets(secretSync, secretMap);
|
return VercelSyncFns.syncSecrets(secretSync, secretMap);
|
||||||
case SecretSync.Windmill:
|
case SecretSync.Windmill:
|
||||||
return WindmillSyncFns.syncSecrets(secretSync, secretMap);
|
return WindmillSyncFns.syncSecrets(secretSync, secretMap);
|
||||||
|
case SecretSync.TeamCity:
|
||||||
|
return TeamCitySyncFns.syncSecrets(secretSync, secretMap);
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unhandled sync destination for sync secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
`Unhandled sync destination for sync secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
||||||
@@ -199,6 +203,9 @@ export const SecretSyncFns = {
|
|||||||
case SecretSync.Windmill:
|
case SecretSync.Windmill:
|
||||||
secretMap = await WindmillSyncFns.getSecrets(secretSync);
|
secretMap = await WindmillSyncFns.getSecrets(secretSync);
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.TeamCity:
|
||||||
|
secretMap = await TeamCitySyncFns.getSecrets(secretSync);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unhandled sync destination for get secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
`Unhandled sync destination for get secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
||||||
@@ -252,6 +259,8 @@ export const SecretSyncFns = {
|
|||||||
return VercelSyncFns.removeSecrets(secretSync, secretMap);
|
return VercelSyncFns.removeSecrets(secretSync, secretMap);
|
||||||
case SecretSync.Windmill:
|
case SecretSync.Windmill:
|
||||||
return WindmillSyncFns.removeSecrets(secretSync, secretMap);
|
return WindmillSyncFns.removeSecrets(secretSync, secretMap);
|
||||||
|
case SecretSync.TeamCity:
|
||||||
|
return TeamCitySyncFns.removeSecrets(secretSync, secretMap);
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unhandled sync destination for remove secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
`Unhandled sync destination for remove secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ export const SECRET_SYNC_NAME_MAP: Record<SecretSync, string> = {
|
|||||||
[SecretSync.TerraformCloud]: "Terraform Cloud",
|
[SecretSync.TerraformCloud]: "Terraform Cloud",
|
||||||
[SecretSync.Camunda]: "Camunda",
|
[SecretSync.Camunda]: "Camunda",
|
||||||
[SecretSync.Vercel]: "Vercel",
|
[SecretSync.Vercel]: "Vercel",
|
||||||
[SecretSync.Windmill]: "Windmill"
|
[SecretSync.Windmill]: "Windmill",
|
||||||
|
[SecretSync.TeamCity]: "TeamCity"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
||||||
@@ -28,5 +29,6 @@ export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
|||||||
[SecretSync.TerraformCloud]: AppConnection.TerraformCloud,
|
[SecretSync.TerraformCloud]: AppConnection.TerraformCloud,
|
||||||
[SecretSync.Camunda]: AppConnection.Camunda,
|
[SecretSync.Camunda]: AppConnection.Camunda,
|
||||||
[SecretSync.Vercel]: AppConnection.Vercel,
|
[SecretSync.Vercel]: AppConnection.Vercel,
|
||||||
[SecretSync.Windmill]: AppConnection.Windmill
|
[SecretSync.Windmill]: AppConnection.Windmill,
|
||||||
|
[SecretSync.TeamCity]: AppConnection.TeamCity
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -356,8 +356,11 @@ export const secretSyncQueueFactory = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (Object.hasOwn(secretMap, key)) {
|
if (Object.hasOwn(secretMap, key)) {
|
||||||
secretsToUpdate.push(secret);
|
// Only update secrets if the source value is not empty
|
||||||
if (importBehavior === SecretSyncImportBehavior.PrioritizeDestination) importedSecretMap[key] = secretData;
|
if (value) {
|
||||||
|
secretsToUpdate.push(secret);
|
||||||
|
if (importBehavior === SecretSyncImportBehavior.PrioritizeDestination) importedSecretMap[key] = secretData;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
secretsToCreate.push(secret);
|
secretsToCreate.push(secret);
|
||||||
importedSecretMap[key] = secretData;
|
importedSecretMap[key] = secretData;
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ import {
|
|||||||
THumanitecSyncListItem,
|
THumanitecSyncListItem,
|
||||||
THumanitecSyncWithCredentials
|
THumanitecSyncWithCredentials
|
||||||
} from "./humanitec";
|
} from "./humanitec";
|
||||||
|
import {
|
||||||
|
TTeamCitySync,
|
||||||
|
TTeamCitySyncInput,
|
||||||
|
TTeamCitySyncListItem,
|
||||||
|
TTeamCitySyncWithCredentials
|
||||||
|
} from "./teamcity/teamcity-sync-types";
|
||||||
import {
|
import {
|
||||||
TTerraformCloudSync,
|
TTerraformCloudSync,
|
||||||
TTerraformCloudSyncInput,
|
TTerraformCloudSyncInput,
|
||||||
@@ -81,7 +87,8 @@ export type TSecretSync =
|
|||||||
| TTerraformCloudSync
|
| TTerraformCloudSync
|
||||||
| TCamundaSync
|
| TCamundaSync
|
||||||
| TVercelSync
|
| TVercelSync
|
||||||
| TWindmillSync;
|
| TWindmillSync
|
||||||
|
| TTeamCitySync;
|
||||||
|
|
||||||
export type TSecretSyncWithCredentials =
|
export type TSecretSyncWithCredentials =
|
||||||
| TAwsParameterStoreSyncWithCredentials
|
| TAwsParameterStoreSyncWithCredentials
|
||||||
@@ -95,7 +102,8 @@ export type TSecretSyncWithCredentials =
|
|||||||
| TTerraformCloudSyncWithCredentials
|
| TTerraformCloudSyncWithCredentials
|
||||||
| TCamundaSyncWithCredentials
|
| TCamundaSyncWithCredentials
|
||||||
| TVercelSyncWithCredentials
|
| TVercelSyncWithCredentials
|
||||||
| TWindmillSyncWithCredentials;
|
| TWindmillSyncWithCredentials
|
||||||
|
| TTeamCitySyncWithCredentials;
|
||||||
|
|
||||||
export type TSecretSyncInput =
|
export type TSecretSyncInput =
|
||||||
| TAwsParameterStoreSyncInput
|
| TAwsParameterStoreSyncInput
|
||||||
@@ -109,7 +117,8 @@ export type TSecretSyncInput =
|
|||||||
| TTerraformCloudSyncInput
|
| TTerraformCloudSyncInput
|
||||||
| TCamundaSyncInput
|
| TCamundaSyncInput
|
||||||
| TVercelSyncInput
|
| TVercelSyncInput
|
||||||
| TWindmillSyncInput;
|
| TWindmillSyncInput
|
||||||
|
| TTeamCitySyncInput;
|
||||||
|
|
||||||
export type TSecretSyncListItem =
|
export type TSecretSyncListItem =
|
||||||
| TAwsParameterStoreSyncListItem
|
| TAwsParameterStoreSyncListItem
|
||||||
@@ -123,7 +132,8 @@ export type TSecretSyncListItem =
|
|||||||
| TTerraformCloudSyncListItem
|
| TTerraformCloudSyncListItem
|
||||||
| TCamundaSyncListItem
|
| TCamundaSyncListItem
|
||||||
| TVercelSyncListItem
|
| TVercelSyncListItem
|
||||||
| TWindmillSyncListItem;
|
| TWindmillSyncListItem
|
||||||
|
| TTeamCitySyncListItem;
|
||||||
|
|
||||||
export type TSyncOptionsConfig = {
|
export type TSyncOptionsConfig = {
|
||||||
canImportSecrets: boolean;
|
canImportSecrets: boolean;
|
||||||
|
|||||||
4
backend/src/services/secret-sync/teamcity/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export * from "./teamcity-sync-constants";
|
||||||
|
export * from "./teamcity-sync-fns";
|
||||||
|
export * from "./teamcity-sync-schemas";
|
||||||
|
export * from "./teamcity-sync-types";
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
|
import { TSecretSyncListItem } from "@app/services/secret-sync/secret-sync-types";
|
||||||
|
|
||||||
|
export const TEAMCITY_SYNC_LIST_OPTION: TSecretSyncListItem = {
|
||||||
|
name: "TeamCity",
|
||||||
|
destination: SecretSync.TeamCity,
|
||||||
|
connection: AppConnection.TeamCity,
|
||||||
|
canImportSecrets: true
|
||||||
|
};
|
||||||
183
backend/src/services/secret-sync/teamcity/teamcity-sync-fns.ts
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
import { request } from "@app/lib/config/request";
|
||||||
|
import { getTeamCityInstanceUrl } from "@app/services/app-connection/teamcity";
|
||||||
|
import { SecretSyncError } from "@app/services/secret-sync/secret-sync-errors";
|
||||||
|
import { TSecretMap } from "@app/services/secret-sync/secret-sync-types";
|
||||||
|
import {
|
||||||
|
TDeleteTeamCityVariable,
|
||||||
|
TPostTeamCityVariable,
|
||||||
|
TTeamCityListVariables,
|
||||||
|
TTeamCityListVariablesResponse,
|
||||||
|
TTeamCitySyncWithCredentials
|
||||||
|
} from "@app/services/secret-sync/teamcity/teamcity-sync-types";
|
||||||
|
|
||||||
|
// Note: Most variables won't be returned with a value due to them being a "password" type (starting with "env.").
|
||||||
|
// TeamCity API returns empty string for password-type variables for security reasons.
|
||||||
|
const listTeamCityVariables = async ({ instanceUrl, accessToken, project, buildConfig }: TTeamCityListVariables) => {
|
||||||
|
const { data } = await request.get<TTeamCityListVariablesResponse>(
|
||||||
|
buildConfig
|
||||||
|
? `${instanceUrl}/app/rest/buildTypes/${encodeURIComponent(buildConfig)}/parameters`
|
||||||
|
: `${instanceUrl}/app/rest/projects/id:${encodeURIComponent(project)}/parameters`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
Accept: "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Strips out "env." from map key, but the "name" field still has the original unaltered key.
|
||||||
|
return Object.fromEntries(
|
||||||
|
data.property.map((variable) => [
|
||||||
|
variable.name.startsWith("env.") ? variable.name.substring(4) : variable.name,
|
||||||
|
{ ...variable, value: variable.value || "" } // Password values will be empty strings from the API for security
|
||||||
|
])
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create and update both use the same method
|
||||||
|
const updateTeamCityVariable = async ({
|
||||||
|
instanceUrl,
|
||||||
|
accessToken,
|
||||||
|
project,
|
||||||
|
buildConfig,
|
||||||
|
key,
|
||||||
|
value
|
||||||
|
}: TPostTeamCityVariable) => {
|
||||||
|
return request.post(
|
||||||
|
buildConfig
|
||||||
|
? `${instanceUrl}/app/rest/buildTypes/${encodeURIComponent(buildConfig)}/parameters`
|
||||||
|
: `${instanceUrl}/app/rest/projects/id:${encodeURIComponent(project)}/parameters`,
|
||||||
|
{
|
||||||
|
name: key,
|
||||||
|
value,
|
||||||
|
type: {
|
||||||
|
rawValue: "password display='hidden'"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteTeamCityVariable = async ({
|
||||||
|
instanceUrl,
|
||||||
|
accessToken,
|
||||||
|
project,
|
||||||
|
buildConfig,
|
||||||
|
key
|
||||||
|
}: TDeleteTeamCityVariable) => {
|
||||||
|
return request.delete(
|
||||||
|
buildConfig
|
||||||
|
? `${instanceUrl}/app/rest/buildTypes/${encodeURIComponent(buildConfig)}/parameters/${encodeURIComponent(key)}`
|
||||||
|
: `${instanceUrl}/app/rest/projects/id:${encodeURIComponent(project)}/parameters/${encodeURIComponent(key)}`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${accessToken}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TeamCitySyncFns = {
|
||||||
|
syncSecrets: async (secretSync: TTeamCitySyncWithCredentials, secretMap: TSecretMap) => {
|
||||||
|
const {
|
||||||
|
connection,
|
||||||
|
destinationConfig: { project, buildConfig }
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
const instanceUrl = await getTeamCityInstanceUrl(connection);
|
||||||
|
const { accessToken } = connection.credentials;
|
||||||
|
|
||||||
|
for await (const entry of Object.entries(secretMap)) {
|
||||||
|
const [key, { value }] = entry;
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
instanceUrl,
|
||||||
|
accessToken,
|
||||||
|
project,
|
||||||
|
buildConfig,
|
||||||
|
key: `env.${key}`,
|
||||||
|
value
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Replace every secret since TeamCity does not return secret values that we can cross-check
|
||||||
|
// No need to differenciate create / update because TeamCity uses the same method for both
|
||||||
|
await updateTeamCityVariable(payload);
|
||||||
|
} catch (error) {
|
||||||
|
throw new SecretSyncError({
|
||||||
|
error,
|
||||||
|
secretKey: key
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (secretSync.syncOptions.disableSecretDeletion) return;
|
||||||
|
|
||||||
|
const variables = await listTeamCityVariables({ instanceUrl, accessToken, project, buildConfig });
|
||||||
|
|
||||||
|
for await (const [key, variable] of Object.entries(variables)) {
|
||||||
|
if (!(key in secretMap)) {
|
||||||
|
try {
|
||||||
|
await deleteTeamCityVariable({
|
||||||
|
key: variable.name, // We use variable.name instead of key because key is stripped of "env." prefix in listTeamCityVariables().
|
||||||
|
instanceUrl,
|
||||||
|
accessToken,
|
||||||
|
project,
|
||||||
|
buildConfig
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
throw new SecretSyncError({
|
||||||
|
error,
|
||||||
|
secretKey: key
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
removeSecrets: async (secretSync: TTeamCitySyncWithCredentials, secretMap: TSecretMap) => {
|
||||||
|
const {
|
||||||
|
connection,
|
||||||
|
destinationConfig: { project, buildConfig }
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
const instanceUrl = await getTeamCityInstanceUrl(connection);
|
||||||
|
const { accessToken } = connection.credentials;
|
||||||
|
|
||||||
|
const variables = await listTeamCityVariables({ instanceUrl, accessToken, project, buildConfig });
|
||||||
|
|
||||||
|
for await (const [key, variable] of Object.entries(variables)) {
|
||||||
|
if (key in secretMap) {
|
||||||
|
try {
|
||||||
|
await deleteTeamCityVariable({
|
||||||
|
key: variable.name, // We use variable.name instead of key because key is stripped of "env." prefix in listTeamCityVariables().
|
||||||
|
instanceUrl,
|
||||||
|
accessToken,
|
||||||
|
project,
|
||||||
|
buildConfig
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
throw new SecretSyncError({
|
||||||
|
error,
|
||||||
|
secretKey: key
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getSecrets: async (secretSync: TTeamCitySyncWithCredentials) => {
|
||||||
|
const {
|
||||||
|
connection,
|
||||||
|
destinationConfig: { project, buildConfig }
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
const instanceUrl = await getTeamCityInstanceUrl(connection);
|
||||||
|
const { accessToken } = connection.credentials;
|
||||||
|
|
||||||
|
return listTeamCityVariables({ instanceUrl, accessToken, project, buildConfig });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { SecretSyncs } from "@app/lib/api-docs";
|
||||||
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
|
import {
|
||||||
|
BaseSecretSyncSchema,
|
||||||
|
GenericCreateSecretSyncFieldsSchema,
|
||||||
|
GenericUpdateSecretSyncFieldsSchema
|
||||||
|
} from "@app/services/secret-sync/secret-sync-schemas";
|
||||||
|
import { TSyncOptionsConfig } from "@app/services/secret-sync/secret-sync-types";
|
||||||
|
|
||||||
|
const TeamCitySyncDestinationConfigSchema = z.object({
|
||||||
|
project: z.string().trim().min(1, "Project required").describe(SecretSyncs.DESTINATION_CONFIG.TEAMCITY.project),
|
||||||
|
buildConfig: z.string().trim().optional().describe(SecretSyncs.DESTINATION_CONFIG.TEAMCITY.buildConfig)
|
||||||
|
});
|
||||||
|
|
||||||
|
const TeamCitySyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: true };
|
||||||
|
|
||||||
|
export const TeamCitySyncSchema = BaseSecretSyncSchema(SecretSync.TeamCity, TeamCitySyncOptionsConfig).extend({
|
||||||
|
destination: z.literal(SecretSync.TeamCity),
|
||||||
|
destinationConfig: TeamCitySyncDestinationConfigSchema
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CreateTeamCitySyncSchema = GenericCreateSecretSyncFieldsSchema(
|
||||||
|
SecretSync.TeamCity,
|
||||||
|
TeamCitySyncOptionsConfig
|
||||||
|
).extend({
|
||||||
|
destinationConfig: TeamCitySyncDestinationConfigSchema
|
||||||
|
});
|
||||||
|
|
||||||
|
export const UpdateTeamCitySyncSchema = GenericUpdateSecretSyncFieldsSchema(
|
||||||
|
SecretSync.TeamCity,
|
||||||
|
TeamCitySyncOptionsConfig
|
||||||
|
).extend({
|
||||||
|
destinationConfig: TeamCitySyncDestinationConfigSchema.optional()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const TeamCitySyncListItemSchema = z.object({
|
||||||
|
name: z.literal("TeamCity"),
|
||||||
|
connection: z.literal(AppConnection.TeamCity),
|
||||||
|
destination: z.literal(SecretSync.TeamCity),
|
||||||
|
canImportSecrets: z.literal(true)
|
||||||
|
});
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { TTeamCityConnection } from "@app/services/app-connection/teamcity";
|
||||||
|
|
||||||
|
import { CreateTeamCitySyncSchema, TeamCitySyncListItemSchema, TeamCitySyncSchema } from "./teamcity-sync-schemas";
|
||||||
|
|
||||||
|
export type TTeamCitySync = z.infer<typeof TeamCitySyncSchema>;
|
||||||
|
|
||||||
|
export type TTeamCitySyncInput = z.infer<typeof CreateTeamCitySyncSchema>;
|
||||||
|
|
||||||
|
export type TTeamCitySyncListItem = z.infer<typeof TeamCitySyncListItemSchema>;
|
||||||
|
|
||||||
|
export type TTeamCitySyncWithCredentials = TTeamCitySync & {
|
||||||
|
connection: TTeamCityConnection;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TTeamCityVariable = {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
inherited?: boolean;
|
||||||
|
type: {
|
||||||
|
rawValue: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TTeamCityListVariablesResponse = {
|
||||||
|
property: (TTeamCityVariable & { value?: string })[];
|
||||||
|
count: number;
|
||||||
|
href: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TTeamCityListVariables = {
|
||||||
|
accessToken: string;
|
||||||
|
instanceUrl: string;
|
||||||
|
project: string;
|
||||||
|
buildConfig?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TPostTeamCityVariable = TTeamCityListVariables & {
|
||||||
|
key: string;
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TDeleteTeamCityVariable = TTeamCityListVariables & {
|
||||||
|
key: string;
|
||||||
|
};
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Available"
|
||||||
|
openapi: "GET /api/v1/app-connections/teamcity/available"
|
||||||
|
---
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
title: "Create"
|
||||||
|
openapi: "POST /api/v1/app-connections/teamcity"
|
||||||
|
---
|
||||||
|
|
||||||
|
<Note>
|
||||||
|
Check out the configuration docs for [TeamCity Connections](/integrations/app-connections/teamcity) to learn how to obtain
|
||||||
|
the required credentials.
|
||||||
|
</Note>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Delete"
|
||||||
|
openapi: "DELETE /api/v1/app-connections/teamcity/{connectionId}"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Get by ID"
|
||||||
|
openapi: "GET /api/v1/app-connections/teamcity/{connectionId}"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Get by Name"
|
||||||
|
openapi: "GET /api/v1/app-connections/teamcity/connection-name/{connectionName}"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "List"
|
||||||
|
openapi: "GET /api/v1/app-connections/teamcity"
|
||||||
|
---
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
title: "Update"
|
||||||
|
openapi: "PATCH /api/v1/app-connections/teamcity/{connectionId}"
|
||||||
|
---
|
||||||
|
|
||||||
|
<Note>
|
||||||
|
Check out the configuration docs for [TeamCity Connections](/integrations/app-connections/teamcity) to learn how to obtain
|
||||||
|
the required credentials.
|
||||||
|
</Note>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Create"
|
||||||
|
openapi: "POST /api/v1/secret-syncs/teamcity"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Delete"
|
||||||
|
openapi: "DELETE /api/v1/secret-syncs/teamcity/{syncId}"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Get by ID"
|
||||||
|
openapi: "GET /api/v1/secret-syncs/teamcity/{syncId}"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Get by Name"
|
||||||
|
openapi: "GET /api/v1/secret-syncs/teamcity/sync-name/{syncName}"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Import Secrets"
|
||||||
|
openapi: "POST /api/v1/secret-syncs/teamcity/{syncId}/import-secrets"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "List"
|
||||||
|
openapi: "GET /api/v1/secret-syncs/teamcity"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Remove Secrets"
|
||||||
|
openapi: "POST /api/v1/secret-syncs/teamcity/{syncId}/remove-secrets"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Sync Secrets"
|
||||||
|
openapi: "POST /api/v1/secret-syncs/teamcity/{syncId}/sync-secrets"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Update"
|
||||||
|
openapi: "PATCH /api/v1/secret-syncs/teamcity/{syncId}"
|
||||||
|
---
|
||||||
|
Before Width: | Height: | Size: 974 KiB After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 698 KiB |
|
After Width: | Height: | Size: 727 KiB |
BIN
docs/images/app-connections/teamcity/teamcity-main-page.png
Normal file
|
After Width: | Height: | Size: 252 KiB |
BIN
docs/images/app-connections/teamcity/teamcity-token-copy.png
Normal file
|
After Width: | Height: | Size: 326 KiB |
BIN
docs/images/app-connections/teamcity/teamcity-token-created.png
Normal file
|
After Width: | Height: | Size: 296 KiB |
BIN
docs/images/app-connections/teamcity/teamcity-token-page.png
Normal file
|
After Width: | Height: | Size: 239 KiB |
BIN
docs/images/app-connections/teamcity/teamcity-token-popup.png
Normal file
|
After Width: | Height: | Size: 435 KiB |
|
Before Width: | Height: | Size: 950 KiB After Width: | Height: | Size: 1.1 MiB |
BIN
docs/images/secret-syncs/teamcity/select-teamcity-option.png
Normal file
|
After Width: | Height: | Size: 696 KiB |
BIN
docs/images/secret-syncs/teamcity/teamcity-sync-created.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
BIN
docs/images/secret-syncs/teamcity/teamcity-sync-destination.png
Normal file
|
After Width: | Height: | Size: 678 KiB |
BIN
docs/images/secret-syncs/teamcity/teamcity-sync-details.png
Normal file
|
After Width: | Height: | Size: 640 KiB |
BIN
docs/images/secret-syncs/teamcity/teamcity-sync-options.png
Normal file
|
After Width: | Height: | Size: 656 KiB |
BIN
docs/images/secret-syncs/teamcity/teamcity-sync-review.png
Normal file
|
After Width: | Height: | Size: 664 KiB |
BIN
docs/images/secret-syncs/teamcity/teamcity-sync-source.png
Normal file
|
After Width: | Height: | Size: 628 KiB |
119
docs/integrations/app-connections/teamcity.mdx
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
---
|
||||||
|
title: "TeamCity Connection"
|
||||||
|
description: "Learn how to configure a TeamCity Connection for Infisical."
|
||||||
|
---
|
||||||
|
|
||||||
|
Infisical supports connecting to TeamCity using an Access Token to securely sync your secrets to TeamCity.
|
||||||
|
|
||||||
|
## Setup TeamCity Connection in Infisical
|
||||||
|
|
||||||
|
<Steps>
|
||||||
|
<Step title="Navigate to your profile on TeamCity">
|
||||||
|
Navigate to the TeamCity **Profile** page by clicking on your profile icon in the bottom-left corner.
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Select Access Tokens Tab">
|
||||||
|
Select the **Access Tokens** tab from the left sidebar navigation menu.
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Create the Access Token">
|
||||||
|
Click the **Create access token** button and provide a name for your token (e.g., "Infisical Integration"). You may set an expiration date or leave it blank for no expiry.
|
||||||
|
The permission scope can either be **Same as current user** or **Limit per project**.
|
||||||
|
|
||||||
|
If you're choosing **Limit per project**, make sure you select the relevant project and enable the permissions relevant to your use case:
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<Tab title="Secret Sync Permissions">
|
||||||
|
- View build configuration settings
|
||||||
|
- Edit project
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
<Note>
|
||||||
|
Setting your permission scope to **Same as current user** will allow your integration to access multiple projects as long as the current user has read and write access to them.
|
||||||
|
</Note>
|
||||||
|
<Note>
|
||||||
|
If you configure an expiry date for your access token, you must manually rotate to a new token before the expiration date to prevent service interruption.
|
||||||
|
</Note>
|
||||||
|
</Step>
|
||||||
|
<Step title="Copy the Access Token">
|
||||||
|
After creation, a modal with the Access Token will be displayed. Copy this token immediately and store it securely, as you won't be able to view it again after closing this dialog.
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Token Created">
|
||||||
|
You should now see your newly created token in the list of access tokens.
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Setup TeamCity Connection in Infisical">
|
||||||
|
<Tabs>
|
||||||
|
<Tab title="Infisical UI">
|
||||||
|
1. Navigate to App Connections
|
||||||
|
|
||||||
|
In your Infisical dashboard, go to **Organization Settings** and select the [**App Connections**](https://app.infisical.com/organization/app-connections) tab.
|
||||||
|

|
||||||
|
2. Add Connection
|
||||||
|
|
||||||
|
Click the **+ Add Connection** button and select the **TeamCity Connection** option from the available integrations.
|
||||||
|

|
||||||
|
3. Fill the TeamCity Connection Modal
|
||||||
|
|
||||||
|
Complete the TeamCity Connection form by entering:
|
||||||
|
- A descriptive name for the connection
|
||||||
|
- The Access Token you generated in steps 3-4
|
||||||
|
- The URL of your TeamCity instance
|
||||||
|
- An optional description for future reference
|
||||||
|
|
||||||
|

|
||||||
|
4. Connection Created
|
||||||
|
|
||||||
|
After clicking Create, your **TeamCity Connection** is established and ready to use with your Infisical projects.
|
||||||
|

|
||||||
|
</Tab>
|
||||||
|
<Tab title="API">
|
||||||
|
To create a TeamCity Connection, make an API request to the [Create TeamCity
|
||||||
|
Connection](/api-reference/endpoints/app-connections/teamcity/create) API endpoint.
|
||||||
|
|
||||||
|
### Sample request
|
||||||
|
|
||||||
|
```bash Request
|
||||||
|
curl --request POST \
|
||||||
|
--url https://app.infisical.com/api/v1/app-connections/teamcity \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{
|
||||||
|
"name": "my-teamcity-connection",
|
||||||
|
"method": "access-token",
|
||||||
|
"credentials": {
|
||||||
|
"accessToken": "...",
|
||||||
|
"instanceUrl": "https://yourcompany.teamcity.com"
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sample response
|
||||||
|
|
||||||
|
```bash Response
|
||||||
|
{
|
||||||
|
"appConnection": {
|
||||||
|
"id": "e5d18aca-86f7-4026-a95e-efb8aeb0d8e6",
|
||||||
|
"name": "my-teamcity-connection",
|
||||||
|
"description": null,
|
||||||
|
"version": 1,
|
||||||
|
"orgId": "6f03caa1-a5de-43ce-b127-95a145d3464c",
|
||||||
|
"createdAt": "2025-04-23T19:46:34.831Z",
|
||||||
|
"updatedAt": "2025-04-23T19:46:34.831Z",
|
||||||
|
"isPlatformManagedCredentials": false,
|
||||||
|
"credentialsHash": "7c2d371dec195f82a6a0d5b41c970a229cfcaf88e894a5b6395e2dbd0280661f",
|
||||||
|
"app": "teamcity",
|
||||||
|
"method": "access-token",
|
||||||
|
"credentials": {
|
||||||
|
"instanceUrl": "https://yourcompany.teamcity.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
|
</Step>
|
||||||
|
</Steps>
|
||||||
@@ -3,43 +3,6 @@ title: "TeamCity"
|
|||||||
description: "How to sync secrets from Infisical to TeamCity"
|
description: "How to sync secrets from Infisical to TeamCity"
|
||||||
---
|
---
|
||||||
|
|
||||||
Prerequisites:
|
<Note>
|
||||||
|
The TeamCity Native Integration will be deprecated in 2026. Please migrate to our new [TeamCity Sync](../secret-syncs/teamcity).
|
||||||
- Set up and add envars to [Infisical Cloud](https://app.infisical.com)
|
</Note>
|
||||||
|
|
||||||
<Steps>
|
|
||||||
<Step title="Authorize Infisical for TeamCity">
|
|
||||||
Obtain a TeamCity Access Token in Profile > Access Tokens
|
|
||||||
|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
<Note>
|
|
||||||
For this integration to work, the TeamCity Access Token must either have the
|
|
||||||
**Same as current user** account-wide permission enabled or, if **Limit per project**
|
|
||||||
is selected, then it must at minimum have the **View build configuration settings** and **Edit project** permissions enabled.
|
|
||||||
</Note>
|
|
||||||
|
|
||||||
Navigate to your project's integrations tab in Infisical.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Press on the TeamCity tile and input your TeamCity Access Token and Server URL to grant Infisical access to your TeamCity account.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
</Step>
|
|
||||||
<Step title="Start integration">
|
|
||||||
Select which Infisical environment secrets you want to sync to which TeamCity project (and optionally build configuration) and press create integration to start syncing secrets to TeamCity.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
<Note>
|
|
||||||
Infisical integrates with both TeamCity's project-level and build configuration-level environment variables.
|
|
||||||
|
|
||||||
To sync secrets to a specific build configuration in a TeamCity project, you can select a build configuration from the **TeamCity Build Config** dropdown; otherwise, leaving it empty will sync secrets to TeamCity at the project-level.
|
|
||||||
</Note>
|
|
||||||
|
|
||||||

|
|
||||||
</Step>
|
|
||||||
</Steps>
|
|
||||||
|
|||||||
@@ -3,39 +3,6 @@ title: "Windmill"
|
|||||||
description: "How to sync secrets from Infisical to Windmill"
|
description: "How to sync secrets from Infisical to Windmill"
|
||||||
---
|
---
|
||||||
|
|
||||||
Prerequisites:
|
<Note>
|
||||||
|
The Windmill Native Integration will be deprecated in 2026. Please migrate to our new [Windmill Sync](../secret-syncs/windmill).
|
||||||
- Set up and add envars to [Infisical Cloud](https://app.infisical.com)
|
</Note>
|
||||||
|
|
||||||
<Steps>
|
|
||||||
<Step title="Authorize Infisical for Windmill">
|
|
||||||
Obtain a [Windmill](https://www.windmill.dev/) access token in Access Tokens
|
|
||||||
|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
Navigate to your project's integrations tab in Infisical.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Press on the Windmill tile and input your Windmill access token to grant Infisical access to your Windmill account.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
</Step>
|
|
||||||
<Step title="Start integration">
|
|
||||||
Select which Infisical environment secrets you want to sync to which Windmill workspace and press create integration to start syncing secrets to Windmill.
|
|
||||||
|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
<Warning>
|
|
||||||
Secrets synced to Windmill are subject to the [ownership path
|
|
||||||
prefix](https://www.windmill.dev/docs/core_concepts/roles_and_permissions)
|
|
||||||
convention of Windmill. Accordingly, all secrets must be prefixed with either
|
|
||||||
`u/` or `f/` for user-based and folder-based secret along with the name of the
|
|
||||||
secret. Put differently, you must use the full path of the secret as its name
|
|
||||||
in Infisical to be considered valid such as `u/user/FOO/BAR`.
|
|
||||||
</Warning>
|
|
||||||
</Step>
|
|
||||||
</Steps>
|
|
||||||
|
|||||||
147
docs/integrations/secret-syncs/teamcity.mdx
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
---
|
||||||
|
title: "TeamCity Sync"
|
||||||
|
description: "Learn how to configure a TeamCity Sync for Infisical."
|
||||||
|
---
|
||||||
|
|
||||||
|
**Prerequisites:**
|
||||||
|
|
||||||
|
- Set up and add secrets to [Infisical Cloud](https://app.infisical.com)
|
||||||
|
- Create a [TeamCity Connection](/integrations/app-connections/teamcity) with the required **Secret Sync** permissions
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<Tab title="Infisical UI">
|
||||||
|
1. Navigate to **Project** > **Integrations** and select the **Secret Syncs** tab. Click on the **Add Sync** button.
|
||||||
|

|
||||||
|
|
||||||
|
2. Select the **TeamCity** option.
|
||||||
|

|
||||||
|
|
||||||
|
3. Configure the **Source** from where secrets should be retrieved, then click **Next**.
|
||||||
|

|
||||||
|
|
||||||
|
- **Environment**: The project environment to retrieve secrets from.
|
||||||
|
- **Secret Path**: The folder path to retrieve secrets from.
|
||||||
|
|
||||||
|
<Tip>
|
||||||
|
If you need to sync secrets from multiple folder locations, check out [secret imports](/documentation/platform/secret-reference#secret-imports).
|
||||||
|
</Tip>
|
||||||
|
|
||||||
|
4. Configure the **Destination** to where secrets should be deployed, then click **Next**.
|
||||||
|

|
||||||
|
|
||||||
|
- **TeamCity Connection**: The TeamCity Connection to authenticate with.
|
||||||
|
- **Project**: The TeamCity project to sync secrets to.
|
||||||
|
- **Build Configuration**: The build configuration to sync secrets to.
|
||||||
|
|
||||||
|
<Note>
|
||||||
|
Not including a Build Configuration will sync secrets to the entire project.
|
||||||
|
</Note>
|
||||||
|
|
||||||
|
5. Configure the **Sync Options** to specify how secrets should be synced, then click **Next**.
|
||||||
|

|
||||||
|
|
||||||
|
- **Initial Sync Behavior**: Determines how Infisical should resolve the initial sync.
|
||||||
|
- **Overwrite Destination Secrets**: Removes any secrets at the destination endpoint not present in Infisical.
|
||||||
|
- **Import Secrets (Prioritize Infisical)**: Imports secrets from the destination endpoint before syncing, prioritizing values from Infisical over TeamCity when keys conflict.
|
||||||
|
- **Import Secrets (Prioritize TeamCity)**: Imports secrets from the destination endpoint before syncing, prioritizing values from TeamCity over Infisical when keys conflict.
|
||||||
|
- **Auto-Sync Enabled**: If enabled, secrets will automatically be synced from the source location when changes occur. Disable to enforce manual syncing only.
|
||||||
|
- **Disable Secret Deletion**: If enabled, Infisical will not remove secrets from the sync destination. Enable this option if you intend to manage some secrets manually outside of Infisical.
|
||||||
|
|
||||||
|
6. Configure the **Details** of your TeamCity Sync, then click **Next**.
|
||||||
|

|
||||||
|
|
||||||
|
- **Name**: The name of your sync. Must be slug-friendly.
|
||||||
|
- **Description**: An optional description for your sync.
|
||||||
|
|
||||||
|
7. Review your TeamCity Sync configuration, then click **Create Sync**.
|
||||||
|

|
||||||
|
|
||||||
|
8. If enabled, your TeamCity Sync will begin syncing your secrets to the destination endpoint.
|
||||||
|

|
||||||
|
|
||||||
|
</Tab>
|
||||||
|
<Tab title="API">
|
||||||
|
To create a **TeamCity Sync**, make an API request to the [Create TeamCity Sync](/api-reference/endpoints/secret-syncs/teamcity/create) API endpoint.
|
||||||
|
|
||||||
|
### Sample request
|
||||||
|
|
||||||
|
```bash Request
|
||||||
|
curl --request POST \
|
||||||
|
--url https://app.infisical.com/api/v1/secret-syncs/teamcity \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{
|
||||||
|
"name": "my-teamcity-sync",
|
||||||
|
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"description": "an example sync",
|
||||||
|
"connectionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"environment": "dev",
|
||||||
|
"secretPath": "/my-secrets",
|
||||||
|
"isEnabled": true,
|
||||||
|
"syncOptions": {
|
||||||
|
"initialSyncBehavior": "overwrite-destination"
|
||||||
|
},
|
||||||
|
"destinationConfig": {
|
||||||
|
"project": "TestProject",
|
||||||
|
"buildConfig": "TestBuildConfig"
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
<Note>
|
||||||
|
The **Project** and **Build Config** parameters must use project and build configuration IDs, not their names.
|
||||||
|
</Note>
|
||||||
|
|
||||||
|
### Sample response
|
||||||
|
|
||||||
|
```bash Response
|
||||||
|
{
|
||||||
|
"secretSync": {
|
||||||
|
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"name": "my-teamcity-sync",
|
||||||
|
"description": "an example sync",
|
||||||
|
"isEnabled": true,
|
||||||
|
"version": 1,
|
||||||
|
"folderId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"connectionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"createdAt": "2023-11-07T05:31:56Z",
|
||||||
|
"updatedAt": "2023-11-07T05:31:56Z",
|
||||||
|
"syncStatus": "succeeded",
|
||||||
|
"lastSyncJobId": "123",
|
||||||
|
"lastSyncMessage": null,
|
||||||
|
"lastSyncedAt": "2023-11-07T05:31:56Z",
|
||||||
|
"importStatus": null,
|
||||||
|
"lastImportJobId": null,
|
||||||
|
"lastImportMessage": null,
|
||||||
|
"lastImportedAt": null,
|
||||||
|
"removeStatus": null,
|
||||||
|
"lastRemoveJobId": null,
|
||||||
|
"lastRemoveMessage": null,
|
||||||
|
"lastRemovedAt": null,
|
||||||
|
"syncOptions": {
|
||||||
|
"initialSyncBehavior": "overwrite-destination"
|
||||||
|
},
|
||||||
|
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"connection": {
|
||||||
|
"app": "teamcity",
|
||||||
|
"name": "my-teamcity-connection",
|
||||||
|
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"slug": "dev",
|
||||||
|
"name": "Development",
|
||||||
|
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
|
||||||
|
},
|
||||||
|
"folder": {
|
||||||
|
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"path": "/my-secrets"
|
||||||
|
},
|
||||||
|
"destination": "teamcity",
|
||||||
|
"destinationConfig": {
|
||||||
|
"project": "TestProject",
|
||||||
|
"buildConfig": "TestBuildConfig"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
@@ -435,6 +435,7 @@
|
|||||||
"integrations/app-connections/humanitec",
|
"integrations/app-connections/humanitec",
|
||||||
"integrations/app-connections/mssql",
|
"integrations/app-connections/mssql",
|
||||||
"integrations/app-connections/postgres",
|
"integrations/app-connections/postgres",
|
||||||
|
"integrations/app-connections/teamcity",
|
||||||
"integrations/app-connections/terraform-cloud",
|
"integrations/app-connections/terraform-cloud",
|
||||||
"integrations/app-connections/vercel",
|
"integrations/app-connections/vercel",
|
||||||
"integrations/app-connections/windmill"
|
"integrations/app-connections/windmill"
|
||||||
@@ -458,6 +459,7 @@
|
|||||||
"integrations/secret-syncs/gcp-secret-manager",
|
"integrations/secret-syncs/gcp-secret-manager",
|
||||||
"integrations/secret-syncs/github",
|
"integrations/secret-syncs/github",
|
||||||
"integrations/secret-syncs/humanitec",
|
"integrations/secret-syncs/humanitec",
|
||||||
|
"integrations/secret-syncs/teamcity",
|
||||||
"integrations/secret-syncs/terraform-cloud",
|
"integrations/secret-syncs/terraform-cloud",
|
||||||
"integrations/secret-syncs/vercel",
|
"integrations/secret-syncs/vercel",
|
||||||
"integrations/secret-syncs/windmill"
|
"integrations/secret-syncs/windmill"
|
||||||
@@ -567,9 +569,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"group": "Others",
|
"group": "Others",
|
||||||
"pages": [
|
"pages": ["integrations/external/backstage"]
|
||||||
"integrations/external/backstage"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"group": "",
|
"group": "",
|
||||||
@@ -1059,6 +1059,18 @@
|
|||||||
"api-reference/endpoints/app-connections/postgres/delete"
|
"api-reference/endpoints/app-connections/postgres/delete"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"group": "TeamCity",
|
||||||
|
"pages": [
|
||||||
|
"api-reference/endpoints/app-connections/teamcity/list",
|
||||||
|
"api-reference/endpoints/app-connections/teamcity/available",
|
||||||
|
"api-reference/endpoints/app-connections/teamcity/get-by-id",
|
||||||
|
"api-reference/endpoints/app-connections/teamcity/get-by-name",
|
||||||
|
"api-reference/endpoints/app-connections/teamcity/create",
|
||||||
|
"api-reference/endpoints/app-connections/teamcity/update",
|
||||||
|
"api-reference/endpoints/app-connections/teamcity/delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"group": "Terraform Cloud",
|
"group": "Terraform Cloud",
|
||||||
"pages": [
|
"pages": [
|
||||||
@@ -1224,6 +1236,20 @@
|
|||||||
"api-reference/endpoints/secret-syncs/humanitec/remove-secrets"
|
"api-reference/endpoints/secret-syncs/humanitec/remove-secrets"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"group": "TeamCity",
|
||||||
|
"pages": [
|
||||||
|
"api-reference/endpoints/secret-syncs/teamcity/list",
|
||||||
|
"api-reference/endpoints/secret-syncs/teamcity/get-by-id",
|
||||||
|
"api-reference/endpoints/secret-syncs/teamcity/get-by-name",
|
||||||
|
"api-reference/endpoints/secret-syncs/teamcity/create",
|
||||||
|
"api-reference/endpoints/secret-syncs/teamcity/update",
|
||||||
|
"api-reference/endpoints/secret-syncs/teamcity/delete",
|
||||||
|
"api-reference/endpoints/secret-syncs/teamcity/sync-secrets",
|
||||||
|
"api-reference/endpoints/secret-syncs/teamcity/import-secrets",
|
||||||
|
"api-reference/endpoints/secret-syncs/teamcity/remove-secrets"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"group": "Terraform Cloud",
|
"group": "Terraform Cloud",
|
||||||
"pages": [
|
"pages": [
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { DatabricksSyncFields } from "./DatabricksSyncFields";
|
|||||||
import { GcpSyncFields } from "./GcpSyncFields";
|
import { GcpSyncFields } from "./GcpSyncFields";
|
||||||
import { GitHubSyncFields } from "./GitHubSyncFields";
|
import { GitHubSyncFields } from "./GitHubSyncFields";
|
||||||
import { HumanitecSyncFields } from "./HumanitecSyncFields";
|
import { HumanitecSyncFields } from "./HumanitecSyncFields";
|
||||||
|
import { TeamCitySyncFields } from "./TeamCitySyncFields";
|
||||||
import { TerraformCloudSyncFields } from "./TerraformCloudSyncFields";
|
import { TerraformCloudSyncFields } from "./TerraformCloudSyncFields";
|
||||||
import { VercelSyncFields } from "./VercelSyncFields";
|
import { VercelSyncFields } from "./VercelSyncFields";
|
||||||
import { WindmillSyncFields } from "./WindmillSyncFields";
|
import { WindmillSyncFields } from "./WindmillSyncFields";
|
||||||
@@ -46,6 +47,8 @@ export const SecretSyncDestinationFields = () => {
|
|||||||
return <VercelSyncFields />;
|
return <VercelSyncFields />;
|
||||||
case SecretSync.Windmill:
|
case SecretSync.Windmill:
|
||||||
return <WindmillSyncFields />;
|
return <WindmillSyncFields />;
|
||||||
|
case SecretSync.TeamCity:
|
||||||
|
return <TeamCitySyncFields />;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unhandled Destination Config Field: ${destination}`);
|
throw new Error(`Unhandled Destination Config Field: ${destination}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,128 @@
|
|||||||
|
import { Controller, useFormContext, useWatch } from "react-hook-form";
|
||||||
|
import { SingleValue } from "react-select";
|
||||||
|
import { faCircleInfo } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
|
||||||
|
import { SecretSyncConnectionField } from "@app/components/secret-syncs/forms/SecretSyncConnectionField";
|
||||||
|
import { FilterableSelect, FormControl, Tooltip } from "@app/components/v2";
|
||||||
|
import {
|
||||||
|
TTeamCityProjectWithBuildTypes,
|
||||||
|
useTeamCityConnectionListProjects
|
||||||
|
} from "@app/hooks/api/appConnections/teamcity";
|
||||||
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
|
||||||
|
import { TSecretSyncForm } from "../schemas";
|
||||||
|
|
||||||
|
export const TeamCitySyncFields = () => {
|
||||||
|
const { control, setValue } = useFormContext<
|
||||||
|
TSecretSyncForm & { destination: SecretSync.TeamCity }
|
||||||
|
>();
|
||||||
|
|
||||||
|
const connectionId = useWatch({ name: "connection.id", control });
|
||||||
|
|
||||||
|
const { data: projects, isLoading: isProjectsLoading } = useTeamCityConnectionListProjects(
|
||||||
|
connectionId,
|
||||||
|
{
|
||||||
|
enabled: Boolean(connectionId)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// For Build Config dropdown
|
||||||
|
const selectedProjectId = useWatch({ name: "destinationConfig.project", control });
|
||||||
|
const selectedProject = projects?.find((proj) => proj.id === selectedProjectId);
|
||||||
|
|
||||||
|
const buildTypes = selectedProject?.buildTypes?.buildType || [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SecretSyncConnectionField
|
||||||
|
onChange={() => {
|
||||||
|
setValue("destinationConfig.project", "");
|
||||||
|
setValue("destinationConfig.buildConfig", "");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
name="destinationConfig.project"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
isError={Boolean(error)}
|
||||||
|
errorText={error?.message}
|
||||||
|
label="Project"
|
||||||
|
helperText={
|
||||||
|
<Tooltip
|
||||||
|
className="max-w-md"
|
||||||
|
content="Ensure the project exists in the connection's TeamCity instance URL."
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<span>Don't see the project you're looking for?</span>{" "}
|
||||||
|
<FontAwesomeIcon icon={faCircleInfo} className="text-mineshaft-400" />
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<FilterableSelect
|
||||||
|
menuPlacement="top"
|
||||||
|
isLoading={isProjectsLoading && Boolean(connectionId)}
|
||||||
|
isDisabled={!connectionId}
|
||||||
|
value={projects?.find((proj) => proj.id === value) ?? null}
|
||||||
|
onChange={(option) => {
|
||||||
|
onChange((option as SingleValue<TTeamCityProjectWithBuildTypes>)?.id ?? null);
|
||||||
|
setValue("destinationConfig.buildConfig", "");
|
||||||
|
}}
|
||||||
|
options={projects}
|
||||||
|
placeholder="Select a project..."
|
||||||
|
getOptionLabel={(option) => option.name}
|
||||||
|
getOptionValue={(option) => option.id}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
name="destinationConfig.buildConfig"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
isError={Boolean(error)}
|
||||||
|
errorText={error?.message}
|
||||||
|
isOptional
|
||||||
|
label="Build Configuration"
|
||||||
|
helperText={
|
||||||
|
<Tooltip
|
||||||
|
className="max-w-md"
|
||||||
|
content='Ensure the configuration exists in the selected project and that your Access Token has the "View build configuration settings" permission.'
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<span>Don't see the configuration you're looking for?</span>{" "}
|
||||||
|
<FontAwesomeIcon icon={faCircleInfo} className="text-mineshaft-400" />
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<FilterableSelect
|
||||||
|
menuPlacement="top"
|
||||||
|
isLoading={isProjectsLoading && Boolean(connectionId)}
|
||||||
|
isDisabled={!connectionId || !selectedProject}
|
||||||
|
value={buildTypes.find((buildType) => buildType.id === value) ?? null}
|
||||||
|
onChange={(option) => {
|
||||||
|
const selectedOption = option as SingleValue<{ id: string; name: string }>;
|
||||||
|
onChange(selectedOption?.id ?? "");
|
||||||
|
}}
|
||||||
|
options={buildTypes}
|
||||||
|
isClearable={true}
|
||||||
|
placeholder="Select a build configuration..."
|
||||||
|
getOptionLabel={(option) => option.name}
|
||||||
|
getOptionValue={(option) => option.id}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<span className="text-sm text-bunker-300">
|
||||||
|
Not selecting a Build Configuration will sync your secrets to the entire project.
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -43,6 +43,7 @@ export const SecretSyncOptionsFields = ({ hideInitialSync }: Props) => {
|
|||||||
case SecretSync.Camunda:
|
case SecretSync.Camunda:
|
||||||
case SecretSync.Vercel:
|
case SecretSync.Vercel:
|
||||||
case SecretSync.Windmill:
|
case SecretSync.Windmill:
|
||||||
|
case SecretSync.TeamCity:
|
||||||
AdditionalSyncOptionsFieldsComponent = null;
|
AdditionalSyncOptionsFieldsComponent = null;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { DatabricksSyncReviewFields } from "./DatabricksSyncReviewFields";
|
|||||||
import { GcpSyncReviewFields } from "./GcpSyncReviewFields";
|
import { GcpSyncReviewFields } from "./GcpSyncReviewFields";
|
||||||
import { GitHubSyncReviewFields } from "./GitHubSyncReviewFields";
|
import { GitHubSyncReviewFields } from "./GitHubSyncReviewFields";
|
||||||
import { HumanitecSyncReviewFields } from "./HumanitecSyncReviewFields";
|
import { HumanitecSyncReviewFields } from "./HumanitecSyncReviewFields";
|
||||||
|
import { TeamCitySyncReviewFields } from "./TeamCitySyncReviewFields";
|
||||||
import { TerraformCloudSyncReviewFields } from "./TerraformCloudSyncReviewFields";
|
import { TerraformCloudSyncReviewFields } from "./TerraformCloudSyncReviewFields";
|
||||||
import { VercelSyncReviewFields } from "./VercelSyncReviewFields";
|
import { VercelSyncReviewFields } from "./VercelSyncReviewFields";
|
||||||
import { WindmillSyncReviewFields } from "./WindmillSyncReviewFields";
|
import { WindmillSyncReviewFields } from "./WindmillSyncReviewFields";
|
||||||
@@ -88,6 +89,9 @@ export const SecretSyncReviewFields = () => {
|
|||||||
case SecretSync.Windmill:
|
case SecretSync.Windmill:
|
||||||
DestinationFieldsComponent = <WindmillSyncReviewFields />;
|
DestinationFieldsComponent = <WindmillSyncReviewFields />;
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.TeamCity:
|
||||||
|
DestinationFieldsComponent = <TeamCitySyncReviewFields />;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unhandled Destination Review Fields: ${destination}`);
|
throw new Error(`Unhandled Destination Review Fields: ${destination}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { useFormContext } from "react-hook-form";
|
||||||
|
|
||||||
|
import { TSecretSyncForm } from "@app/components/secret-syncs/forms/schemas";
|
||||||
|
import { GenericFieldLabel } from "@app/components/v2";
|
||||||
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
|
||||||
|
export const TeamCitySyncReviewFields = () => {
|
||||||
|
const { watch } = useFormContext<TSecretSyncForm & { destination: SecretSync.TeamCity }>();
|
||||||
|
const project = watch("destinationConfig.project");
|
||||||
|
const buildConfig = watch("destinationConfig.buildConfig");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<GenericFieldLabel label="Project">{project}</GenericFieldLabel>
|
||||||
|
<GenericFieldLabel label="Build Configuration">{buildConfig}</GenericFieldLabel>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -9,6 +9,7 @@ import { DatabricksSyncDestinationSchema } from "./databricks-sync-destination-s
|
|||||||
import { GcpSyncDestinationSchema } from "./gcp-sync-destination-schema";
|
import { GcpSyncDestinationSchema } from "./gcp-sync-destination-schema";
|
||||||
import { GitHubSyncDestinationSchema } from "./github-sync-destination-schema";
|
import { GitHubSyncDestinationSchema } from "./github-sync-destination-schema";
|
||||||
import { HumanitecSyncDestinationSchema } from "./humanitec-sync-destination-schema";
|
import { HumanitecSyncDestinationSchema } from "./humanitec-sync-destination-schema";
|
||||||
|
import { TeamCitySyncDestinationSchema } from "./teamcity-sync-destination-schema";
|
||||||
import { TerraformCloudSyncDestinationSchema } from "./terraform-cloud-destination-schema";
|
import { TerraformCloudSyncDestinationSchema } from "./terraform-cloud-destination-schema";
|
||||||
import { VercelSyncDestinationSchema } from "./vercel-sync-destination-schema";
|
import { VercelSyncDestinationSchema } from "./vercel-sync-destination-schema";
|
||||||
import { WindmillSyncDestinationSchema } from "./windmill-sync-destination-schema";
|
import { WindmillSyncDestinationSchema } from "./windmill-sync-destination-schema";
|
||||||
@@ -25,7 +26,8 @@ const SecretSyncUnionSchema = z.discriminatedUnion("destination", [
|
|||||||
TerraformCloudSyncDestinationSchema,
|
TerraformCloudSyncDestinationSchema,
|
||||||
CamundaSyncDestinationSchema,
|
CamundaSyncDestinationSchema,
|
||||||
VercelSyncDestinationSchema,
|
VercelSyncDestinationSchema,
|
||||||
WindmillSyncDestinationSchema
|
WindmillSyncDestinationSchema,
|
||||||
|
TeamCitySyncDestinationSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const SecretSyncFormSchema = SecretSyncUnionSchema;
|
export const SecretSyncFormSchema = SecretSyncUnionSchema;
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { BaseSecretSyncSchema } from "@app/components/secret-syncs/forms/schemas/base-secret-sync-schema";
|
||||||
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
|
||||||
|
export const TeamCitySyncDestinationSchema = BaseSecretSyncSchema().merge(
|
||||||
|
z.object({
|
||||||
|
destination: z.literal(SecretSync.TeamCity),
|
||||||
|
destinationConfig: z.object({
|
||||||
|
project: z.string().trim().min(1, "Project required"),
|
||||||
|
buildConfig: z.string().trim().optional()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
);
|
||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
MsSqlConnectionMethod,
|
MsSqlConnectionMethod,
|
||||||
PostgresConnectionMethod,
|
PostgresConnectionMethod,
|
||||||
TAppConnection,
|
TAppConnection,
|
||||||
|
TeamCityConnectionMethod,
|
||||||
TerraformCloudConnectionMethod,
|
TerraformCloudConnectionMethod,
|
||||||
VercelConnectionMethod,
|
VercelConnectionMethod,
|
||||||
WindmillConnectionMethod
|
WindmillConnectionMethod
|
||||||
@@ -43,7 +44,8 @@ export const APP_CONNECTION_MAP: Record<
|
|||||||
[AppConnection.MsSql]: { name: "Microsoft SQL Server", image: "MsSql.png" },
|
[AppConnection.MsSql]: { name: "Microsoft SQL Server", image: "MsSql.png" },
|
||||||
[AppConnection.Camunda]: { name: "Camunda", image: "Camunda.png" },
|
[AppConnection.Camunda]: { name: "Camunda", image: "Camunda.png" },
|
||||||
[AppConnection.Windmill]: { name: "Windmill", image: "Windmill.png" },
|
[AppConnection.Windmill]: { name: "Windmill", image: "Windmill.png" },
|
||||||
[AppConnection.Auth0]: { name: "Auth0", image: "Auth0.png", size: 40 }
|
[AppConnection.Auth0]: { name: "Auth0", image: "Auth0.png", size: 40 },
|
||||||
|
[AppConnection.TeamCity]: { name: "TeamCity", image: "TeamCity.png" }
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAppConnectionMethodDetails = (method: TAppConnection["method"]) => {
|
export const getAppConnectionMethodDetails = (method: TAppConnection["method"]) => {
|
||||||
@@ -71,6 +73,7 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])
|
|||||||
case PostgresConnectionMethod.UsernameAndPassword:
|
case PostgresConnectionMethod.UsernameAndPassword:
|
||||||
case MsSqlConnectionMethod.UsernameAndPassword:
|
case MsSqlConnectionMethod.UsernameAndPassword:
|
||||||
return { name: "Username & Password", icon: faLock };
|
return { name: "Username & Password", icon: faLock };
|
||||||
|
case TeamCityConnectionMethod.AccessToken:
|
||||||
case WindmillConnectionMethod.AccessToken:
|
case WindmillConnectionMethod.AccessToken:
|
||||||
return { name: "Access Token", icon: faKey };
|
return { name: "Access Token", icon: faKey };
|
||||||
case Auth0ConnectionMethod.ClientCredentials:
|
case Auth0ConnectionMethod.ClientCredentials:
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ export const SECRET_SYNC_MAP: Record<SecretSync, { name: string; image: string }
|
|||||||
[SecretSync.Windmill]: {
|
[SecretSync.Windmill]: {
|
||||||
name: "Windmill",
|
name: "Windmill",
|
||||||
image: "Windmill.png"
|
image: "Windmill.png"
|
||||||
|
},
|
||||||
|
[SecretSync.TeamCity]: {
|
||||||
|
name: "TeamCity",
|
||||||
|
image: "TeamCity.png"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,7 +58,8 @@ export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
|||||||
[SecretSync.TerraformCloud]: AppConnection.TerraformCloud,
|
[SecretSync.TerraformCloud]: AppConnection.TerraformCloud,
|
||||||
[SecretSync.Camunda]: AppConnection.Camunda,
|
[SecretSync.Camunda]: AppConnection.Camunda,
|
||||||
[SecretSync.Vercel]: AppConnection.Vercel,
|
[SecretSync.Vercel]: AppConnection.Vercel,
|
||||||
[SecretSync.Windmill]: AppConnection.Windmill
|
[SecretSync.Windmill]: AppConnection.Windmill,
|
||||||
|
[SecretSync.TeamCity]: AppConnection.TeamCity
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SECRET_SYNC_INITIAL_SYNC_BEHAVIOR_MAP: Record<
|
export const SECRET_SYNC_INITIAL_SYNC_BEHAVIOR_MAP: Record<
|
||||||
|
|||||||
@@ -12,5 +12,6 @@ export enum AppConnection {
|
|||||||
MsSql = "mssql",
|
MsSql = "mssql",
|
||||||
Camunda = "camunda",
|
Camunda = "camunda",
|
||||||
Windmill = "windmill",
|
Windmill = "windmill",
|
||||||
Auth0 = "auth0"
|
Auth0 = "auth0",
|
||||||
|
TeamCity = "teamcity"
|
||||||
}
|
}
|
||||||
|
|||||||
2
frontend/src/hooks/api/appConnections/teamcity/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "./queries";
|
||||||
|
export * from "./types";
|
||||||
37
frontend/src/hooks/api/appConnections/teamcity/queries.tsx
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
import { apiRequest } from "@app/config/request";
|
||||||
|
|
||||||
|
import { appConnectionKeys } from "../queries";
|
||||||
|
import { TTeamCityProjectWithBuildTypes } from "./types";
|
||||||
|
|
||||||
|
const teamcityConnectionKeys = {
|
||||||
|
all: [...appConnectionKeys.all, "teamcity"] as const,
|
||||||
|
listProjects: (connectionId: string) =>
|
||||||
|
[...teamcityConnectionKeys.all, "projects", connectionId] as const
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useTeamCityConnectionListProjects = (
|
||||||
|
connectionId: string,
|
||||||
|
options?: Omit<
|
||||||
|
UseQueryOptions<
|
||||||
|
TTeamCityProjectWithBuildTypes[],
|
||||||
|
unknown,
|
||||||
|
TTeamCityProjectWithBuildTypes[],
|
||||||
|
ReturnType<typeof teamcityConnectionKeys.listProjects>
|
||||||
|
>,
|
||||||
|
"queryKey" | "queryFn"
|
||||||
|
>
|
||||||
|
) => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: teamcityConnectionKeys.listProjects(connectionId),
|
||||||
|
queryFn: async () => {
|
||||||
|
const { data } = await apiRequest.get<TTeamCityProjectWithBuildTypes[]>(
|
||||||
|
`/api/v1/app-connections/teamcity/${connectionId}/projects`
|
||||||
|
);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
...options
|
||||||
|
});
|
||||||
|
};
|
||||||
13
frontend/src/hooks/api/appConnections/teamcity/types.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
export type TTeamCityProject = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TTeamCityProjectWithBuildTypes = TTeamCityProject & {
|
||||||
|
buildTypes: {
|
||||||
|
buildType: {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -67,6 +67,10 @@ export type TAuth0ConnectionOption = TAppConnectionOptionBase & {
|
|||||||
app: AppConnection.Auth0;
|
app: AppConnection.Auth0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type TTeamCityConnectionOption = TAppConnectionOptionBase & {
|
||||||
|
app: AppConnection.TeamCity;
|
||||||
|
};
|
||||||
|
|
||||||
export type TAppConnectionOption =
|
export type TAppConnectionOption =
|
||||||
| TAwsConnectionOption
|
| TAwsConnectionOption
|
||||||
| TGitHubConnectionOption
|
| TGitHubConnectionOption
|
||||||
@@ -81,7 +85,8 @@ export type TAppConnectionOption =
|
|||||||
| TMsSqlConnectionOption
|
| TMsSqlConnectionOption
|
||||||
| TCamundaConnectionOption
|
| TCamundaConnectionOption
|
||||||
| TWindmillConnectionOption
|
| TWindmillConnectionOption
|
||||||
| TAuth0ConnectionOption;
|
| TAuth0ConnectionOption
|
||||||
|
| TTeamCityConnectionOption;
|
||||||
|
|
||||||
export type TAppConnectionOptionMap = {
|
export type TAppConnectionOptionMap = {
|
||||||
[AppConnection.AWS]: TAwsConnectionOption;
|
[AppConnection.AWS]: TAwsConnectionOption;
|
||||||
@@ -98,4 +103,5 @@ export type TAppConnectionOptionMap = {
|
|||||||
[AppConnection.Camunda]: TCamundaConnectionOption;
|
[AppConnection.Camunda]: TCamundaConnectionOption;
|
||||||
[AppConnection.Windmill]: TWindmillConnectionOption;
|
[AppConnection.Windmill]: TWindmillConnectionOption;
|
||||||
[AppConnection.Auth0]: TAuth0ConnectionOption;
|
[AppConnection.Auth0]: TAuth0ConnectionOption;
|
||||||
|
[AppConnection.TeamCity]: TTeamCityConnectionOption;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { TGitHubConnection } from "./github-connection";
|
|||||||
import { THumanitecConnection } from "./humanitec-connection";
|
import { THumanitecConnection } from "./humanitec-connection";
|
||||||
import { TMsSqlConnection } from "./mssql-connection";
|
import { TMsSqlConnection } from "./mssql-connection";
|
||||||
import { TPostgresConnection } from "./postgres-connection";
|
import { TPostgresConnection } from "./postgres-connection";
|
||||||
|
import { TTeamCityConnection } from "./teamcity-connection";
|
||||||
import { TTerraformCloudConnection } from "./terraform-cloud-connection";
|
import { TTerraformCloudConnection } from "./terraform-cloud-connection";
|
||||||
import { TVercelConnection } from "./vercel-connection";
|
import { TVercelConnection } from "./vercel-connection";
|
||||||
import { TWindmillConnection } from "./windmill-connection";
|
import { TWindmillConnection } from "./windmill-connection";
|
||||||
@@ -26,6 +27,7 @@ export * from "./github-connection";
|
|||||||
export * from "./humanitec-connection";
|
export * from "./humanitec-connection";
|
||||||
export * from "./mssql-connection";
|
export * from "./mssql-connection";
|
||||||
export * from "./postgres-connection";
|
export * from "./postgres-connection";
|
||||||
|
export * from "./teamcity-connection";
|
||||||
export * from "./terraform-cloud-connection";
|
export * from "./terraform-cloud-connection";
|
||||||
export * from "./vercel-connection";
|
export * from "./vercel-connection";
|
||||||
export * from "./windmill-connection";
|
export * from "./windmill-connection";
|
||||||
@@ -44,7 +46,8 @@ export type TAppConnection =
|
|||||||
| TMsSqlConnection
|
| TMsSqlConnection
|
||||||
| TCamundaConnection
|
| TCamundaConnection
|
||||||
| TWindmillConnection
|
| TWindmillConnection
|
||||||
| TAuth0Connection;
|
| TAuth0Connection
|
||||||
|
| TTeamCityConnection;
|
||||||
|
|
||||||
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id">;
|
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id">;
|
||||||
|
|
||||||
@@ -86,4 +89,5 @@ export type TAppConnectionMap = {
|
|||||||
[AppConnection.Camunda]: TCamundaConnection;
|
[AppConnection.Camunda]: TCamundaConnection;
|
||||||
[AppConnection.Windmill]: TWindmillConnection;
|
[AppConnection.Windmill]: TWindmillConnection;
|
||||||
[AppConnection.Auth0]: TAuth0Connection;
|
[AppConnection.Auth0]: TAuth0Connection;
|
||||||
|
[AppConnection.TeamCity]: TTeamCityConnection;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||||
|
import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
|
||||||
|
|
||||||
|
export enum TeamCityConnectionMethod {
|
||||||
|
AccessToken = "access-token"
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TTeamCityConnection = TRootAppConnection & { app: AppConnection.TeamCity } & {
|
||||||
|
method: TeamCityConnectionMethod.AccessToken;
|
||||||
|
credentials: {
|
||||||
|
accessToken: string;
|
||||||
|
instanceUrl: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -10,7 +10,8 @@ export enum SecretSync {
|
|||||||
TerraformCloud = "terraform-cloud",
|
TerraformCloud = "terraform-cloud",
|
||||||
Camunda = "camunda",
|
Camunda = "camunda",
|
||||||
Vercel = "vercel",
|
Vercel = "vercel",
|
||||||
Windmill = "windmill"
|
Windmill = "windmill",
|
||||||
|
TeamCity = "teamcity"
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SecretSyncStatus {
|
export enum SecretSyncStatus {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { TDatabricksSync } from "./databricks-sync";
|
|||||||
import { TGcpSync } from "./gcp-sync";
|
import { TGcpSync } from "./gcp-sync";
|
||||||
import { TGitHubSync } from "./github-sync";
|
import { TGitHubSync } from "./github-sync";
|
||||||
import { THumanitecSync } from "./humanitec-sync";
|
import { THumanitecSync } from "./humanitec-sync";
|
||||||
|
import { TTeamCitySync } from "./teamcity-sync";
|
||||||
import { TTerraformCloudSync } from "./terraform-cloud-sync";
|
import { TTerraformCloudSync } from "./terraform-cloud-sync";
|
||||||
import { TVercelSync } from "./vercel-sync";
|
import { TVercelSync } from "./vercel-sync";
|
||||||
import { TWindmillSync } from "./windmill-sync";
|
import { TWindmillSync } from "./windmill-sync";
|
||||||
@@ -32,7 +33,8 @@ export type TSecretSync =
|
|||||||
| TTerraformCloudSync
|
| TTerraformCloudSync
|
||||||
| TCamundaSync
|
| TCamundaSync
|
||||||
| TVercelSync
|
| TVercelSync
|
||||||
| TWindmillSync;
|
| TWindmillSync
|
||||||
|
| TTeamCitySync;
|
||||||
|
|
||||||
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
|
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
|
||||||
|
|
||||||
|
|||||||
16
frontend/src/hooks/api/secretSyncs/types/teamcity-sync.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||||
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
|
||||||
|
|
||||||
|
export type TTeamCitySync = TRootSecretSync & {
|
||||||
|
destination: SecretSync.TeamCity;
|
||||||
|
destinationConfig: {
|
||||||
|
project: string;
|
||||||
|
buildConfig?: string;
|
||||||
|
};
|
||||||
|
connection: {
|
||||||
|
app: AppConnection.TeamCity;
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -20,6 +20,7 @@ import { GitHubConnectionForm } from "./GitHubConnectionForm";
|
|||||||
import { HumanitecConnectionForm } from "./HumanitecConnectionForm";
|
import { HumanitecConnectionForm } from "./HumanitecConnectionForm";
|
||||||
import { MsSqlConnectionForm } from "./MsSqlConnectionForm";
|
import { MsSqlConnectionForm } from "./MsSqlConnectionForm";
|
||||||
import { PostgresConnectionForm } from "./PostgresConnectionForm";
|
import { PostgresConnectionForm } from "./PostgresConnectionForm";
|
||||||
|
import { TeamCityConnectionForm } from "./TeamCityConnectionForm";
|
||||||
import { TerraformCloudConnectionForm } from "./TerraformCloudConnectionForm";
|
import { TerraformCloudConnectionForm } from "./TerraformCloudConnectionForm";
|
||||||
import { VercelConnectionForm } from "./VercelConnectionForm";
|
import { VercelConnectionForm } from "./VercelConnectionForm";
|
||||||
import { WindmillConnectionForm } from "./WindmillConnectionForm";
|
import { WindmillConnectionForm } from "./WindmillConnectionForm";
|
||||||
@@ -89,6 +90,8 @@ const CreateForm = ({ app, onComplete }: CreateFormProps) => {
|
|||||||
return <WindmillConnectionForm onSubmit={onSubmit} />;
|
return <WindmillConnectionForm onSubmit={onSubmit} />;
|
||||||
case AppConnection.Auth0:
|
case AppConnection.Auth0:
|
||||||
return <Auth0ConnectionForm onSubmit={onSubmit} />;
|
return <Auth0ConnectionForm onSubmit={onSubmit} />;
|
||||||
|
case AppConnection.TeamCity:
|
||||||
|
return <TeamCityConnectionForm onSubmit={onSubmit} />;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unhandled App ${app}`);
|
throw new Error(`Unhandled App ${app}`);
|
||||||
}
|
}
|
||||||
@@ -153,6 +156,8 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {
|
|||||||
return <WindmillConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
return <WindmillConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||||
case AppConnection.Auth0:
|
case AppConnection.Auth0:
|
||||||
return <Auth0ConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
return <Auth0ConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||||
|
case AppConnection.TeamCity:
|
||||||
|
return <TeamCityConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unhandled App ${(appConnection as TAppConnection).app}`);
|
throw new Error(`Unhandled App ${(appConnection as TAppConnection).app}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
import { Controller, FormProvider, useForm } from "react-hook-form";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
FormControl,
|
||||||
|
Input,
|
||||||
|
ModalClose,
|
||||||
|
SecretInput,
|
||||||
|
Select,
|
||||||
|
SelectItem
|
||||||
|
} from "@app/components/v2";
|
||||||
|
import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";
|
||||||
|
import { TeamCityConnectionMethod, TTeamCityConnection } from "@app/hooks/api/appConnections";
|
||||||
|
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||||
|
|
||||||
|
import {
|
||||||
|
genericAppConnectionFieldsSchema,
|
||||||
|
GenericAppConnectionsFields
|
||||||
|
} from "./GenericAppConnectionFields";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
appConnection?: TTeamCityConnection;
|
||||||
|
onSubmit: (formData: FormData) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const rootSchema = genericAppConnectionFieldsSchema.extend({
|
||||||
|
app: z.literal(AppConnection.TeamCity)
|
||||||
|
});
|
||||||
|
|
||||||
|
const formSchema = z.discriminatedUnion("method", [
|
||||||
|
rootSchema.extend({
|
||||||
|
method: z.literal(TeamCityConnectionMethod.AccessToken),
|
||||||
|
credentials: z.object({
|
||||||
|
accessToken: z.string().trim().min(1, "Access Token required"),
|
||||||
|
instanceUrl: z.string().trim().url("Invalid Instance URL")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
type FormData = z.infer<typeof formSchema>;
|
||||||
|
|
||||||
|
export const TeamCityConnectionForm = ({ appConnection, onSubmit }: Props) => {
|
||||||
|
const isUpdate = Boolean(appConnection);
|
||||||
|
|
||||||
|
const form = useForm<FormData>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
defaultValues: appConnection ?? {
|
||||||
|
app: AppConnection.TeamCity,
|
||||||
|
method: TeamCityConnectionMethod.AccessToken
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
handleSubmit,
|
||||||
|
control,
|
||||||
|
formState: { isSubmitting, isDirty }
|
||||||
|
} = form;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FormProvider {...form}>
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
{!isUpdate && <GenericAppConnectionsFields />}
|
||||||
|
<Controller
|
||||||
|
name="method"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
tooltipText={`The method you would like to use to connect with ${
|
||||||
|
APP_CONNECTION_MAP[AppConnection.TeamCity].name
|
||||||
|
}. This field cannot be changed after creation.`}
|
||||||
|
errorText={error?.message}
|
||||||
|
isError={Boolean(error?.message)}
|
||||||
|
label="Method"
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
isDisabled={isUpdate}
|
||||||
|
value={value}
|
||||||
|
onValueChange={(val) => onChange(val)}
|
||||||
|
className="w-full border border-mineshaft-500"
|
||||||
|
position="popper"
|
||||||
|
dropdownContainerClassName="max-w-none"
|
||||||
|
>
|
||||||
|
{Object.values(TeamCityConnectionMethod).map((method) => {
|
||||||
|
return (
|
||||||
|
<SelectItem value={method} key={method}>
|
||||||
|
{getAppConnectionMethodDetails(method).name}{" "}
|
||||||
|
</SelectItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Controller
|
||||||
|
name="credentials.instanceUrl"
|
||||||
|
control={control}
|
||||||
|
shouldUnregister
|
||||||
|
render={({ field, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
errorText={error?.message}
|
||||||
|
isError={Boolean(error?.message)}
|
||||||
|
label="Instance URL"
|
||||||
|
tooltipClassName="max-w-sm"
|
||||||
|
tooltipText="The URL at which your TeamCity instance is hosted."
|
||||||
|
>
|
||||||
|
<Input {...field} placeholder="https://yourcompany.teamcity.com" />
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Controller
|
||||||
|
name="credentials.accessToken"
|
||||||
|
control={control}
|
||||||
|
shouldUnregister
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
errorText={error?.message}
|
||||||
|
isError={Boolean(error?.message)}
|
||||||
|
label="Access Token"
|
||||||
|
>
|
||||||
|
<SecretInput
|
||||||
|
containerClassName="text-gray-400 group-focus-within:!border-primary-400/50 border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => onChange(e.target.value)}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<div className="mt-8 flex items-center">
|
||||||
|
<Button
|
||||||
|
className="mr-4"
|
||||||
|
size="sm"
|
||||||
|
type="submit"
|
||||||
|
colorSchema="secondary"
|
||||||
|
isLoading={isSubmitting}
|
||||||
|
isDisabled={isSubmitting || !isDirty}
|
||||||
|
>
|
||||||
|
{isUpdate ? "Update Credentials" : "Connect to TeamCity"}
|
||||||
|
</Button>
|
||||||
|
<ModalClose asChild>
|
||||||
|
<Button colorSchema="secondary" variant="plain">
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</ModalClose>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</FormProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -9,6 +9,7 @@ import { DatabricksSyncDestinationCol } from "./DatabricksSyncDestinationCol";
|
|||||||
import { GcpSyncDestinationCol } from "./GcpSyncDestinationCol";
|
import { GcpSyncDestinationCol } from "./GcpSyncDestinationCol";
|
||||||
import { GitHubSyncDestinationCol } from "./GitHubSyncDestinationCol";
|
import { GitHubSyncDestinationCol } from "./GitHubSyncDestinationCol";
|
||||||
import { HumanitecSyncDestinationCol } from "./HumanitecSyncDestinationCol";
|
import { HumanitecSyncDestinationCol } from "./HumanitecSyncDestinationCol";
|
||||||
|
import { TeamCitySyncDestinationCol } from "./TeamCitySyncDestinationCol";
|
||||||
import { TerraformCloudSyncDestinationCol } from "./TerraformCloudSyncDestinationCol";
|
import { TerraformCloudSyncDestinationCol } from "./TerraformCloudSyncDestinationCol";
|
||||||
import { VercelSyncDestinationCol } from "./VercelSyncDestinationCol";
|
import { VercelSyncDestinationCol } from "./VercelSyncDestinationCol";
|
||||||
import { WindmillSyncDestinationCol } from "./WindmillSyncDestinationCol";
|
import { WindmillSyncDestinationCol } from "./WindmillSyncDestinationCol";
|
||||||
@@ -43,6 +44,8 @@ export const SecretSyncDestinationCol = ({ secretSync }: Props) => {
|
|||||||
return <VercelSyncDestinationCol secretSync={secretSync} />;
|
return <VercelSyncDestinationCol secretSync={secretSync} />;
|
||||||
case SecretSync.Windmill:
|
case SecretSync.Windmill:
|
||||||
return <WindmillSyncDestinationCol secretSync={secretSync} />;
|
return <WindmillSyncDestinationCol secretSync={secretSync} />;
|
||||||
|
case SecretSync.TeamCity:
|
||||||
|
return <TeamCitySyncDestinationCol secretSync={secretSync} />;
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unhandled Secret Sync Destination Col: ${(secretSync as TSecretSync).destination}`
|
`Unhandled Secret Sync Destination Col: ${(secretSync as TSecretSync).destination}`
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { TTeamCitySync } from "@app/hooks/api/secretSyncs/types/teamcity-sync";
|
||||||
|
|
||||||
|
import { getSecretSyncDestinationColValues } from "../helpers";
|
||||||
|
import { SecretSyncTableCell } from "../SecretSyncTableCell";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
secretSync: TTeamCitySync;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TeamCitySyncDestinationCol = ({ secretSync }: Props) => {
|
||||||
|
const { primaryText, secondaryText } = getSecretSyncDestinationColValues(secretSync);
|
||||||
|
|
||||||
|
return <SecretSyncTableCell primaryText={primaryText} secondaryText={secondaryText} />;
|
||||||
|
};
|
||||||
@@ -94,6 +94,10 @@ export const getSecretSyncDestinationColValues = (secretSync: TSecretSync) => {
|
|||||||
primaryText = destinationConfig.workspace;
|
primaryText = destinationConfig.workspace;
|
||||||
secondaryText = destinationConfig.path;
|
secondaryText = destinationConfig.path;
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.TeamCity:
|
||||||
|
primaryText = destinationConfig.project;
|
||||||
|
secondaryText = destinationConfig.buildConfig;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unhandled Destination Col Values ${destination}`);
|
throw new Error(`Unhandled Destination Col Values ${destination}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { DatabricksSyncDestinationSection } from "./DatabricksSyncDestinationSec
|
|||||||
import { GcpSyncDestinationSection } from "./GcpSyncDestinationSection";
|
import { GcpSyncDestinationSection } from "./GcpSyncDestinationSection";
|
||||||
import { GitHubSyncDestinationSection } from "./GitHubSyncDestinationSection";
|
import { GitHubSyncDestinationSection } from "./GitHubSyncDestinationSection";
|
||||||
import { HumanitecSyncDestinationSection } from "./HumanitecSyncDestinationSection";
|
import { HumanitecSyncDestinationSection } from "./HumanitecSyncDestinationSection";
|
||||||
|
import { TeamCitySyncDestinationSection } from "./TeamCitySyncDestinationSection";
|
||||||
import { TerraformCloudSyncDestinationSection } from "./TerraformCloudSyncDestinationSection";
|
import { TerraformCloudSyncDestinationSection } from "./TerraformCloudSyncDestinationSection";
|
||||||
import { VercelSyncDestinationSection } from "./VercelSyncDestinationSection";
|
import { VercelSyncDestinationSection } from "./VercelSyncDestinationSection";
|
||||||
import { WindmillSyncDestinationSection } from "./WindmillSyncDestinationSection";
|
import { WindmillSyncDestinationSection } from "./WindmillSyncDestinationSection";
|
||||||
@@ -73,6 +74,9 @@ export const SecretSyncDestinationSection = ({ secretSync, onEditDestination }:
|
|||||||
case SecretSync.Windmill:
|
case SecretSync.Windmill:
|
||||||
DestinationComponents = <WindmillSyncDestinationSection secretSync={secretSync} />;
|
DestinationComponents = <WindmillSyncDestinationSection secretSync={secretSync} />;
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.TeamCity:
|
||||||
|
DestinationComponents = <TeamCitySyncDestinationSection secretSync={secretSync} />;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unhandled Destination Section components: ${destination}`);
|
throw new Error(`Unhandled Destination Section components: ${destination}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { GenericFieldLabel } from "@app/components/secret-syncs";
|
||||||
|
import { TTeamCitySync } from "@app/hooks/api/secretSyncs/types/teamcity-sync";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
secretSync: TTeamCitySync;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TeamCitySyncDestinationSection = ({ secretSync }: Props) => {
|
||||||
|
const {
|
||||||
|
destinationConfig: { project, buildConfig }
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<GenericFieldLabel label="Project">{project}</GenericFieldLabel>
|
||||||
|
<GenericFieldLabel label="Build Configuration">{buildConfig}</GenericFieldLabel>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -52,6 +52,7 @@ export const SecretSyncOptionsSection = ({ secretSync, onEditOptions }: Props) =
|
|||||||
case SecretSync.Camunda:
|
case SecretSync.Camunda:
|
||||||
case SecretSync.Vercel:
|
case SecretSync.Vercel:
|
||||||
case SecretSync.Windmill:
|
case SecretSync.Windmill:
|
||||||
|
case SecretSync.TeamCity:
|
||||||
AdditionalSyncOptionsComponent = null;
|
AdditionalSyncOptionsComponent = null;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||