Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve utils/providerHelper.ts #1187

Closed
umrkhn opened this issue Nov 10, 2023 · 1 comment · Fixed by #1369
Closed

Improve utils/providerHelper.ts #1187

umrkhn opened this issue Nov 10, 2023 · 1 comment · Fixed by #1369
Assignees
Labels
enhancement New feature or request feature

Comments

@umrkhn
Copy link
Contributor

umrkhn commented Nov 10, 2023

Is your feature request related to a problem? Please describe.
Currently there is a lot of duplicated code as you can see below:

export type Provider =
| 'aws'
| 'gcp'
| 'digitalocean'
| 'azure'
| 'civo'
| 'kubernetes'
| 'linode'
| 'tencent'
| 'oci'
| 'scaleway'
| 'mongodbatlas'
| 'ovh'
| 'pulumi'
| 'terraform';
type ProviderKey =
| 'AWS'
| 'GCP'
| 'DIGITAL_OCEAN'
| 'AZURE'
| 'CIVO'
| 'KUBERNETES'
| 'LINODE'
| 'TENCENT'
| 'OCI'
| 'SCALE_WAY'
| 'MONGODB_ATLAS'
| 'OVH'
| 'PULUMI'
| 'TERRAFORM';
export const allProviders: { [key in ProviderKey]: Provider } = {
AWS: 'aws',
GCP: 'gcp',
DIGITAL_OCEAN: 'digitalocean',
AZURE: 'azure',
CIVO: 'civo',
KUBERNETES: 'kubernetes',
LINODE: 'linode',
TENCENT: 'tencent',
OCI: 'oci',
SCALE_WAY: 'scaleway',
MONGODB_ATLAS: 'mongodbatlas',
OVH: 'ovh',
TERRAFORM: 'terraform',
PULUMI: 'pulumi'
};
export type DBProvider = 'postgres' | 'sqlite';
type DBProviderKey = 'POSTGRES' | 'SQLITE';
export const allDBProviders: { [key in DBProviderKey]: DBProvider } = {
POSTGRES: 'postgres',
SQLITE: 'sqlite'
};

Describe the solution you'd like
we can improve it by converting Provider and DBProvider into an enum as was suggested in the PR #1125 for IntegrationProvider
export enum IntegrationProvider {
SLACK = 'slack',
WEBHOOK = 'webhook'
}

Why should we implement this?
It would reduce code duplication and runtime errors, for ex: instead of hard-coding the values like 'postgres' we can import the enum and reference the property name as shown in the screenshot below:

issue

Would you like to work on this issue?
Yes, once approved I'll start working on it.

@umrkhn umrkhn added enhancement New feature or request feature labels Nov 10, 2023
Copy link

Hey, thank you for opening your first Issue! 🙂 While a Tailwarden team member takes a look at your issue we would like to invite you to join our official Discord server, where you can interact directly with other contributors and Tailwarden team members. Link here: https://discord.tailwarden.com

@Azanul Azanul self-assigned this Mar 8, 2024
@Azanul Azanul mentioned this issue Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants