mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 15:28:42 +00:00
only sync non-inherited environment variables
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
|||||||
TTeamCitySyncWithCredentials
|
TTeamCitySyncWithCredentials
|
||||||
} from "@app/services/secret-sync/teamcity/teamcity-sync-types";
|
} 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.").
|
// Note: Most variables won't be returned with a value due to them being a "password" type.
|
||||||
// TeamCity API returns empty string for password-type variables for security reasons.
|
// TeamCity API returns empty string for password-type variables for security reasons.
|
||||||
const listTeamCityVariables = async ({ instanceUrl, accessToken, project, buildConfig }: TTeamCityListVariables) => {
|
const listTeamCityVariables = async ({ instanceUrl, accessToken, project, buildConfig }: TTeamCityListVariables) => {
|
||||||
const { data } = await request.get<TTeamCityListVariablesResponse>(
|
const { data } = await request.get<TTeamCityListVariablesResponse>(
|
||||||
@@ -25,12 +25,16 @@ const listTeamCityVariables = async ({ instanceUrl, accessToken, project, buildC
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Filters for only non-inherited environment variables
|
||||||
// Strips out "env." from map key, but the "name" field still has the original unaltered key.
|
// Strips out "env." from map key, but the "name" field still has the original unaltered key.
|
||||||
return Object.fromEntries(
|
return Object.fromEntries(
|
||||||
data.property.map((variable) => [
|
data.property
|
||||||
variable.name.startsWith("env.") ? variable.name.substring(4) : variable.name,
|
.filter((variable) => !variable.inherited)
|
||||||
{ ...variable, value: variable.value || "" } // Password values will be empty strings from the API for security
|
.filter((variable) => variable.name.startsWith("env."))
|
||||||
])
|
.map((variable) => [
|
||||||
|
variable.name.substring(4),
|
||||||
|
{ ...variable, value: variable.value || "" } // Password values will be empty strings from the API for security
|
||||||
|
])
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user