allowed creating of multiple tags

This commit is contained in:
Vladyslav Matsiiako
2024-04-19 17:46:33 -07:00
parent a087deb1eb
commit 714a3186a9
9 changed files with 32 additions and 22 deletions

View File

@@ -585,12 +585,12 @@ export const INTEGRATION = {
region: "AWS region to sync secrets to.",
scope: "Scope of the provider. Used by Github, Qovery",
metadata: {
secretPrefix: "The prefix for the saved secret. Used by GCP",
secretSuffix: "The suffix for the saved secret. Used by GCP",
initialSyncBehavoir: "Type of syncing behavoir with the integration",
shouldAutoRedeploy: "Used by Render to trigger auto deploy",
secretGCPLabel: "The label for the GCP secrets",
secretAWSTag: "The tag for the AWS secrets"
secretPrefix: "The prefix for the saved secret. Used by GCP.",
secretSuffix: "The suffix for the saved secret. Used by GCP.",
initialSyncBehavoir: "Type of syncing behavoir with the integration.",
shouldAutoRedeploy: "Used by Render to trigger auto deploy.",
secretGCPLabel: "The label for GCP secrets.",
secretAWSTag: "The tags for AWS secrets."
}
},
UPDATE: {

View File

@@ -58,10 +58,12 @@ export const registerIntegrationRouter = async (server: FastifyZodProvider) => {
.optional()
.describe(INTEGRATION.CREATE.metadata.secretGCPLabel),
secretAWSTag: z
.object({
key: z.string(),
value: z.string()
})
.array(
z.object({
key: z.string(),
value: z.string()
})
)
.optional()
.describe(INTEGRATION.CREATE.metadata.secretAWSTag)
})

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
@@ -489,7 +490,9 @@ const syncSecretsAWSParameterStore = async ({
Type: "SecureString",
Value: secrets[key].value,
// Overwrite: true,
Tags: metadata.secretAWSTag ? [{ Key: metadata.secretAWSTag.key, Value: metadata.secretAWSTag.value }] : []
Tags: metadata.secretAWSTag
? metadata.secretAWSTag.map((tag: { key: string; value: string }) => ({ Key: tag.key, Value: tag.value }))
: []
})
.promise();
// case: secret exists in AWS parameter store
@@ -579,7 +582,9 @@ const syncSecretsAWSSecretManager = async ({
new CreateSecretCommand({
Name: integration.app as string,
SecretString: JSON.stringify(secKeyVal),
Tags: metadata.secretAWSTag ? [{ Key: metadata.secretAWSTag.key, Value: metadata.secretAWSTag.value }] : []
Tags: metadata.secretAWSTag
? metadata.secretAWSTag.map((tag: { key: string; value: string }) => ({ Key: tag.key, Value: tag.value }))
: []
})
);
}

View File

@@ -25,7 +25,7 @@ export type TCreateIntegrationDTO = {
secretAWSTag?: {
key: string;
value: string;
};
}[];
};
} & Omit<TProjectPermission, "projectId">;

View File

@@ -66,7 +66,7 @@ export const useCreateIntegration = () => {
secretAWSTag?: {
key: string;
value: string;
};
}[];
};
}) => {
const {

View File

@@ -128,10 +128,10 @@ export default function AWSParameterStoreCreateIntegrationPage() {
metadata: {
...(shouldTag
? {
secretAWSTag: {
secretAWSTag: [{
key: tagKey,
value: tagValue
}
}]
}
: {})
}
@@ -279,7 +279,7 @@ export default function AWSParameterStoreCreateIntegrationPage() {
label="Tag Value"
>
<Input
placeholder="managed-by"
placeholder="infisical"
value={tagValue}
onChange={(e) => setTagValue(e.target.value)}
/>

View File

@@ -127,10 +127,10 @@ export default function AWSSecretManagerCreateIntegrationPage() {
metadata: {
...(shouldTag
? {
secretAWSTag: {
secretAWSTag: [{
key: tagKey,
value: tagValue
}
}]
}
: {})
}
@@ -278,7 +278,7 @@ export default function AWSSecretManagerCreateIntegrationPage() {
label="Tag Value"
>
<Input
placeholder="managed-by"
placeholder="infisical"
value={tagValue}
onChange={(e) => setTagValue(e.target.value)}
/>

View File

@@ -74,7 +74,7 @@ export const IntegrationsSection = ({
</div>
)}
{!isLoading && isBotActive && (
<div className="flex flex-col space-y-4 p-6 pt-0">
<div className="flex flex-col min-w-max space-y-4 p-6 pt-0">
{integrations?.map((integration) => (
<div
className="max-w-8xl flex justify-between rounded-md border border-mineshaft-600 bg-mineshaft-800 p-3"
@@ -128,6 +128,8 @@ export const IntegrationsSection = ({
<FormLabel
label={
(integration.integration === "qovery" && integration?.scope) ||
(integration.integration === "aws-secret-manager" && "Secret") ||
(integration.integration === "aws-parameter-store" && "Path") ||
(integration?.scope === "github-org" && "Organization") ||
(["github-repo", "github-env"].includes(integration?.scope as string) &&
"Repository") ||
@@ -138,6 +140,7 @@ export const IntegrationsSection = ({
{(integration.integration === "hashicorp-vault" &&
`${integration.app} - path: ${integration.path}`) ||
(integration.scope === "github-org" && `${integration.owner}`) ||
(integration.integration === "aws-parameter-store" && `${integration.path}`) ||
(integration.scope?.startsWith("github-") &&
`${integration.owner}/${integration.app}`) ||
integration.app}

View File

@@ -8,5 +8,5 @@ export type Metadata = {
secretAWSTag?: {
key: string;
value: string;
}
}[]
}