Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces a new secrets feature, adding API types, schema definitions, routes for listing, adding, and editing secrets, and associated UI components and API calls.
- Adds new secret-related types and zod schemas
- Implements new routes and components for secret listing, detail view/editing, and addition
- Updates route configuration and API constants to support secrets
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/types/schema/apisix/type.ts | Added new secret response types |
| src/types/schema/apisix/secrets.ts | Defined zod schemas for Vault, AWS, and GCP secrets |
| src/types/schema/apisix/index.ts | Imported and merged secret types into the main APISIX export |
| src/routes/secrets/index.tsx | Added the secrets list page with pagination and detail routing |
| src/routes/secrets/detail.$manager.$id.tsx | Added detail/edit page for secrets with a read-only/edit toggle |
| src/routes/secrets/add.tsx | Added page for adding secrets with default values and mutation |
| src/routeTree.gen.ts | Updated route tree to include new secrets routes |
| src/config/constant.ts | Introduced new constant for secrets API endpoint |
| src/components/form-slice/FormSectionGeneral.tsx | Enhanced form section component with a read-only ID option |
| src/components/form-slice/FormPartSecret.tsx | Created form sections for secret configuration based on secret manager |
| src/apis/secrets.ts | Added API calls for retrieving and updating secret records |
Files not reviewed (1)
- src/locales/en/common.json: Language not supported
| const VaultSecretForm = () => { | ||
| const { t } = useTranslation(); | ||
| const { control } = useFormContext<APISIXType['Secret']>(); | ||
|
|
||
| return ( | ||
| <> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="uri" | ||
| label={t('form.secrets.vault.uri')} | ||
| /> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="prefix" | ||
| label={t('form.secrets.vault.prefix')} | ||
| /> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="token" | ||
| label={t('form.secrets.vault.token')} | ||
| /> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="namespace" | ||
| label={t('form.secrets.vault.namespace')} | ||
| /> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| const AWSSecretForm = () => { | ||
| const { t } = useTranslation(); | ||
| const { control } = useFormContext<APISIXType['Secret']>(); | ||
|
|
||
| return ( | ||
| <> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="access_key_id" | ||
| label={t('form.secrets.aws.access_key_id')} | ||
| /> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="secret_access_key" | ||
| label={t('form.secrets.aws.secret_access_key')} | ||
| /> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="session_token" | ||
| label={t('form.secrets.aws.session_token')} | ||
| /> | ||
|
|
||
| <FormItemTextInput | ||
| control={control} | ||
| name="region" | ||
| label={t('form.secrets.aws.region')} | ||
| /> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="endpoint_url" | ||
| label={t('form.secrets.aws.endpoint_url')} | ||
| /> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| const GCPSecretForm = () => { | ||
| const { t } = useTranslation(); | ||
| const { control } = useFormContext<APISIXType['Secret']>(); | ||
|
|
||
| return ( | ||
| <> | ||
| <InputWrapper label={t('form.secrets.gcp.ssl_verify')}> | ||
| <FormItemSwitch control={control} name="ssl_verify" /> | ||
| </InputWrapper> | ||
| <FormSection legend={t('form.secrets.gcp.auth')}> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="auth_file" | ||
| label={t('form.secrets.gcp.auth_file')} | ||
| /> | ||
| <Divider my="xs" label={t('or')} /> | ||
| <FormSection legend={t('form.secrets.gcp.auth_config')}> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="auth_config.client_email" | ||
| label={t('form.secrets.gcp.client_email')} | ||
| /> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="auth_config.private_key" | ||
| label={t('form.secrets.gcp.private_key')} | ||
| /> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="auth_config.project_id" | ||
| label={t('form.secrets.gcp.project_id')} | ||
| /> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="auth_config.token_uri" | ||
| label={t('form.secrets.gcp.token_uri')} | ||
| /> | ||
| <FormItemTagsInput | ||
| control={control} | ||
| name="auth_config.scope" | ||
| label={t('form.secrets.gcp.scope')} | ||
| /> | ||
| <FormItemTextInput | ||
| control={control} | ||
| name="auth_config.entries_uri" | ||
| label={t('form.secrets.gcp.entries_uri')} | ||
| /> | ||
| </FormSection> | ||
| </FormSection> | ||
| </> | ||
| ); | ||
| }; |
There was a problem hiding this comment.
Is it necessary to add a specialized form? I think using an editor with syntax highlighting and jsonschema would be sufficient.
If it doesn't exist, we'll have to add the secret provider's jsonschema export.
There was a problem hiding this comment.
I think it's necessary at the moment.
If it's needed as you said, then secrets should provide options for export and schema export, just like the way plugins do it. But these things don't exist yet, we should discuss and add these features in APISIX.
There was a problem hiding this comment.
This needs to be done before the release so no forms that shouldn't be there are added to artifacts, approved and merge it.
Please answer these questions before submitting a pull request, or your PR will get closed.
Why submit this pull request?
What changes will this PR take into?