Skip to content

Conversation

SkyeYoung
Copy link
Member

@SkyeYoung SkyeYoung commented May 7, 2025

Please answer these questions before submitting a pull request, or your PR will get closed.

Why submit this pull request?

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches

What changes will this PR take into?

image image image image

@SkyeYoung SkyeYoung changed the base branch from master to dev/next May 7, 2025 07:48
@SkyeYoung SkyeYoung marked this pull request as ready for review May 7, 2025 09:11
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +11 to +128
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>
</>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

@bzp2010 bzp2010 May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be done before the release so no forms that shouldn't be there are added to artifacts, approved and merge it.

@SkyeYoung SkyeYoung requested a review from bzp2010 May 8, 2025 06:19
@SkyeYoung SkyeYoung merged commit 02b6d43 into apache:dev/next May 8, 2025
@SkyeYoung SkyeYoung deleted the young/feat/secret-list-add branch May 8, 2025 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants